diff --git a/lib/platform-bible-react/src/components/advanced/book-chapter-control/book-chapter-control.component.tsx b/lib/platform-bible-react/src/components/advanced/book-chapter-control/book-chapter-control.component.tsx index 2de0da7db4..0c25bf9eab 100644 --- a/lib/platform-bible-react/src/components/advanced/book-chapter-control/book-chapter-control.component.tsx +++ b/lib/platform-bible-react/src/components/advanced/book-chapter-control/book-chapter-control.component.tsx @@ -5,12 +5,13 @@ import BookMenuItem, { import ChapterSelect from '@/components/advanced/book-chapter-control/chapter-select.component'; import GoToMenuItem from '@/components/advanced/book-chapter-control/go-to-menu-item.component'; import { - DropdownMenu as ShadDropdownMenu, - DropdownMenuContent as ShadDropdownMenuContent, - DropdownMenuLabel as ShadDropdownMenuLabel, - DropdownMenuSeparator as ShadDropdownMenuSeparator, - DropdownMenuTrigger as ShadDropdownMenuTrigger, + DropdownMenu, + DropdownMenuContent, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger, } from '@/components/shadcn-ui/dropdown-menu'; +import { cn } from '@/utils/shadcn-ui.util'; import { Canon } from '@sillsdev/scripture'; import { ScriptureReference, getChaptersForBook } from 'platform-bible-utils'; import { @@ -28,6 +29,8 @@ type BookTypeLabels = { type BookChapterControlProps = { scrRef: ScriptureReference; handleSubmit: (scrRef: ScriptureReference) => void; + /** Text and layout direction */ + direction?: 'rtl' | 'ltr'; }; const ALL_BOOK_IDS = Canon.allBookIds; @@ -101,7 +104,7 @@ function getBookIdFromEnglishName(bookName: string): string | undefined { return undefined; } -function BookChapterControl({ scrRef, handleSubmit }: BookChapterControlProps) { +function BookChapterControl({ scrRef, handleSubmit, direction }: BookChapterControlProps) { const [searchQuery, setSearchQuery] = useState(''); const [selectedBookId, setSelectedBookId] = useState( Canon.bookNumberToId(scrRef.bookNum), @@ -259,15 +262,23 @@ function BookChapterControl({ scrRef, handleSubmit }: BookChapterControlProps) { return; } + const upOneChapter = + (key === 'ArrowRight' && !direction) || + (key === 'ArrowRight' && direction === 'ltr') || + (key === 'ArrowLeft' && direction === 'rtl'); + const downOneChapter = + (key === 'ArrowLeft' && !direction) || + (key === 'ArrowLeft' && direction === 'ltr') || + (key === 'ArrowRight' && direction === 'rtl'); let chapterOffSet = 0; - if (key === 'ArrowRight') { + if (upOneChapter) { if (highlightedChapter < fetchEndChapter(highlightedBookId)) { chapterOffSet = 1; } else { event.preventDefault(); return; } - } else if (key === 'ArrowLeft') { + } else if (downOneChapter) { if (highlightedChapter > 1) { chapterOffSet = -1; } else { @@ -324,8 +335,8 @@ function BookChapterControl({ scrRef, handleSubmit }: BookChapterControlProps) { return (
- - + + - - + - console.log('sorting')} - handleLocationHistory={() => console.log('location history')} - handleBookmarks={() => console.log('bookmarks')} - /> - {BOOK_TYPE_ARRAY.map( - (bookType, bookTypeIndex) => - fetchFilteredBooks(bookType).length > 0 && ( -
- - {BOOK_TYPE_LABELS[bookType]} - + {/* work around until DropdownMenuContent supports a dir prop */} +
+ console.log('sorting')} + handleLocationHistory={() => console.log('location history')} + handleBookmarks={() => console.log('bookmarks')} + /> + {BOOK_TYPE_ARRAY.map( + (bookType, bookTypeIndex) => + fetchFilteredBooks(bookType).length > 0 && ( +
+ + {BOOK_TYPE_LABELS[bookType]} + - {fetchFilteredBooks(bookType).map((bookId) => ( -
- updateReference(bookId, false)} - isSelected={selectedBookId === bookId} - handleHighlightBook={() => setHighlightedBookId(bookId)} - handleKeyDown={handleKeyDownMenuItem} - bookType={bookType} - ref={(element: HTMLDivElement) => { - if (selectedBookId === bookId) menuItemRef.current = element; - }} - > - { - setHighlightedChapter(chapterNumber); + {fetchFilteredBooks(bookType).map((bookId) => ( +
+ updateReference(bookId, false)} + isSelected={selectedBookId === bookId} + handleHighlightBook={() => setHighlightedBookId(bookId)} + handleKeyDown={handleKeyDownMenuItem} + bookType={bookType} + ref={(element: HTMLDivElement) => { + if (selectedBookId === bookId) menuItemRef.current = element; }} - /> - -
- ))} - {BOOK_TYPE_ARRAY.length - 1 !== bookTypeIndex ? ( - - ) : undefined} -
- ), - )} - - + direction={direction} + > + { + setHighlightedChapter(chapterNumber); + }} + /> + +
+ ))} + {BOOK_TYPE_ARRAY.length - 1 !== bookTypeIndex ? ( + + ) : undefined} +
+ ), + )} +
+
+
); } diff --git a/lib/platform-bible-react/src/components/advanced/book-chapter-control/book-chapter-input.component.tsx b/lib/platform-bible-react/src/components/advanced/book-chapter-control/book-chapter-input.component.tsx index d7c885f3d2..36e4a5daf5 100644 --- a/lib/platform-bible-react/src/components/advanced/book-chapter-control/book-chapter-input.component.tsx +++ b/lib/platform-bible-react/src/components/advanced/book-chapter-control/book-chapter-input.component.tsx @@ -1,6 +1,7 @@ import { FocusEventHandler, forwardRef, KeyboardEvent, MouseEventHandler } from 'react'; import { History } from 'lucide-react'; -import { Input as ShadInput } from '@/components/shadcn-ui/input'; +import { Input } from '@/components/shadcn-ui/input'; +import { cn } from '@/utils/shadcn-ui.util'; export type BookChapterInputProps = { handleSearch: (searchString: string) => void; @@ -10,20 +11,31 @@ export type BookChapterInputProps = { onFocus?: FocusEventHandler; value: string; placeholder: string; + /** Text and layout direction */ + direction?: 'rtl' | 'ltr'; }; // Shadcn Input sets type to "button"- HAVE to prop spread before setting type const BookChapterInput = forwardRef( ( - { handleSearch, handleKeyDown, handleOnClick, handleSubmit, ...props }: BookChapterInputProps, + { + handleSearch, + handleKeyDown, + handleOnClick, + handleSubmit, + direction = 'ltr', + ...props + }: BookChapterInputProps, ref, ) => { return (
- handleSearch(event.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') { @@ -35,7 +47,11 @@ const BookChapterInput = forwardRef( ref={ref} /> { // eslint-disable-next-line no-console console.log('back in history'); diff --git a/lib/platform-bible-react/src/components/advanced/book-chapter-control/book-menu-item.component.tsx b/lib/platform-bible-react/src/components/advanced/book-chapter-control/book-menu-item.component.tsx index 5eecea3f98..e8b70d3512 100644 --- a/lib/platform-bible-react/src/components/advanced/book-chapter-control/book-menu-item.component.tsx +++ b/lib/platform-bible-react/src/components/advanced/book-chapter-control/book-menu-item.component.tsx @@ -1,6 +1,6 @@ import { Canon } from '@sillsdev/scripture'; import { PropsWithChildren, KeyboardEvent, forwardRef } from 'react'; -import { DropdownMenuItem as ShadDropdownMenuItem } from '@/components/shadcn-ui/dropdown-menu'; +import { DropdownMenuItem } from '@/components/shadcn-ui/dropdown-menu'; import { cn } from '@/utils/shadcn-ui.util'; export type BookType = 'OT' | 'NT' | 'DC'; @@ -25,6 +25,8 @@ type BookMenuItemProps = PropsWithChildren<{ * coordinated to genre */ bookType: BookType; + /** Text and layout direction */ + direction?: 'rtl' | 'ltr'; }>; const BookMenuItem = forwardRef( @@ -37,11 +39,12 @@ const BookMenuItem = forwardRef( handleKeyDown, bookType, children, + direction, }: BookMenuItemProps, ref, ) => { return ( - ( }} onFocus={handleHighlightBook} onMouseMove={handleHighlightBook} + dir={direction} > {Canon.bookIdToEnglishName(bookId)} {isSelected &&
{children}
} -
+ ); }, ); diff --git a/lib/platform-bible-react/src/components/advanced/book-chapter-control/go-to-menu-item.component.tsx b/lib/platform-bible-react/src/components/advanced/book-chapter-control/go-to-menu-item.component.tsx index 29b95460aa..8ed2dc23ec 100644 --- a/lib/platform-bible-react/src/components/advanced/book-chapter-control/go-to-menu-item.component.tsx +++ b/lib/platform-bible-react/src/components/advanced/book-chapter-control/go-to-menu-item.component.tsx @@ -1,4 +1,4 @@ -import { DropdownMenuLabel as ShadDropdownMenuLabel } from '@/components/shadcn-ui/dropdown-menu'; +import { DropdownMenuLabel } from '@/components/shadcn-ui/dropdown-menu'; import { Bookmark, Clock, ArrowDownWideNarrow } from 'lucide-react'; export type GoToMenuItemProps = { @@ -9,7 +9,7 @@ export type GoToMenuItemProps = { function GoToMenuItem({ handleSort, handleLocationHistory, handleBookmarks }: GoToMenuItemProps) { return ( - +

Go To

-
+ ); } diff --git a/lib/platform-bible-react/src/components/advanced/book-selector.component.tsx b/lib/platform-bible-react/src/components/advanced/book-selector.component.tsx index cabd4c47fe..59630006e1 100644 --- a/lib/platform-bible-react/src/components/advanced/book-selector.component.tsx +++ b/lib/platform-bible-react/src/components/advanced/book-selector.component.tsx @@ -62,6 +62,7 @@ export default function BookSelector({ startChapter, handleSelectStartChapter, localizedStrings, + direction, }: BookSelectorProps) { const currentBookText = localizeString(localizedStrings, '%webView_bookSelector_currentBook%'); const chooseText = localizeString(localizedStrings, '%webView_bookSelector_choose%'); @@ -83,12 +84,13 @@ export default function BookSelector({ // value is always a string but we need it to be BookSelectionMode // eslint-disable-next-line no-type-assertion/no-type-assertion onValueChange={(value: string) => onSelectionModeChange(value as BookSelectionMode)} + dir={direction} >
- +
@@ -99,13 +101,14 @@ export default function BookSelector({ chapterCount={chapterCount} startChapter={startChapter} endChapter={endChapter} + direction={direction} />
- +
{option.label}
{getEntriesCount && ( -
{count}
+
{count}
)} ); diff --git a/lib/platform-bible-react/src/components/advanced/scripture-results-viewer/scripture-results-viewer.component.tsx b/lib/platform-bible-react/src/components/advanced/scripture-results-viewer/scripture-results-viewer.component.tsx index 8bd58c76a5..c4f74ae548 100644 --- a/lib/platform-bible-react/src/components/advanced/scripture-results-viewer/scripture-results-viewer.component.tsx +++ b/lib/platform-bible-react/src/components/advanced/scripture-results-viewer/scripture-results-viewer.component.tsx @@ -379,6 +379,7 @@ export default function ScriptureResultsViewer({ onValueChange={(value) => { handleSelectChange(value); }} + dir={direction} > diff --git a/lib/platform-bible-react/src/components/advanced/scroll-group-selector.component.tsx b/lib/platform-bible-react/src/components/advanced/scroll-group-selector.component.tsx index 5afef5b7f0..4751fd51f3 100644 --- a/lib/platform-bible-react/src/components/advanced/scroll-group-selector.component.tsx +++ b/lib/platform-bible-react/src/components/advanced/scroll-group-selector.component.tsx @@ -91,6 +91,8 @@ export type ScrollGroupSelectorProps = { * ``` */ localizedStrings?: LanguageStrings; + /** Text and layout direction */ + direction?: 'rtl' | 'ltr'; }; /** Selector component for choosing a scroll group */ @@ -99,6 +101,7 @@ export default function ScrollGroupSelector({ scrollGroupId, onChangeScrollGroupId, localizedStrings = {}, + direction = 'ltr', }: ScrollGroupSelectorProps) { const localizedStringsDefaulted = { ...DEFAULT_SCROLL_GROUP_LOCALIZED_STRINGS, @@ -122,6 +125,7 @@ export default function ScrollGroupSelector({ newScrollGroupString === 'undefined' ? undefined : parseInt(newScrollGroupString, 10), ) } + dir={direction} >
diff --git a/lib/platform-bible-react/src/components/basics/chapter-range-selector.component.tsx b/lib/platform-bible-react/src/components/basics/chapter-range-selector.component.tsx index 2f21e8952f..b66cd45e82 100644 --- a/lib/platform-bible-react/src/components/basics/chapter-range-selector.component.tsx +++ b/lib/platform-bible-react/src/components/basics/chapter-range-selector.component.tsx @@ -9,6 +9,8 @@ export type ChapterRangeSelectorProps = { handleSelectEndChapter: (chapter: number) => void; isDisabled?: boolean; chapterCount: number; + /** Text and layout direction */ + direction?: 'rtl' | 'ltr'; }; export default function ChapterRangeSelector({ @@ -18,6 +20,7 @@ export default function ChapterRangeSelector({ handleSelectEndChapter, isDisabled = false, chapterCount, + direction = 'ltr', }: ChapterRangeSelectorProps) { const chapterOptions = useMemo( () => Array.from({ length: chapterCount }, (_, index) => index + 1), @@ -44,22 +47,24 @@ export default function ChapterRangeSelector({ option.toString()} value={startChapter} + dir={direction} /> option.toString()} value={endChapter} + dir={direction} /> ); diff --git a/lib/platform-bible-react/src/components/basics/checklist.component.tsx b/lib/platform-bible-react/src/components/basics/checklist.component.tsx index 0b52e37803..25b9131779 100644 --- a/lib/platform-bible-react/src/components/basics/checklist.component.tsx +++ b/lib/platform-bible-react/src/components/basics/checklist.component.tsx @@ -41,7 +41,7 @@ export default function Checklist({ {listItems.map((item) => (
handleSelectListItem(item, value)} /> diff --git a/lib/platform-bible-react/src/components/basics/combo-box.component.tsx b/lib/platform-bible-react/src/components/basics/combo-box.component.tsx index 6a53827420..5bc0b4f39e 100644 --- a/lib/platform-bible-react/src/components/basics/combo-box.component.tsx +++ b/lib/platform-bible-react/src/components/basics/combo-box.component.tsx @@ -108,7 +108,7 @@ function ComboBox({ disabled={isDisabled} >
- {icon &&
{icon}
} + {icon &&
{icon}
} {value ? getOptionLabel(value) : buttonPlaceholder} diff --git a/lib/platform-bible-react/src/components/basics/search-bar.component.tsx b/lib/platform-bible-react/src/components/basics/search-bar.component.tsx index f97d8f2d0c..d6f2b87d47 100644 --- a/lib/platform-bible-react/src/components/basics/search-bar.component.tsx +++ b/lib/platform-bible-react/src/components/basics/search-bar.component.tsx @@ -21,6 +21,9 @@ export type SearchBarProps = { /** Additional css classes to help with unique styling of the search bar */ className?: string; + + /** Text and layout direction */ + direction?: 'rtl' | 'ltr'; }; export default function SearchBar({ @@ -28,6 +31,7 @@ export default function SearchBar({ placeholder, isFullWidth, className, + direction = 'ltr', }: SearchBarProps) { const [searchQuery, setSearchQuery] = useState(''); @@ -38,12 +42,17 @@ export default function SearchBar({ return (
- + (({ className, ...props }, ref) => { - return ( - - ); -}); +const Spinner = forwardRef( + ({ className, direction, ...props }, ref) => { + return ( + + ); + }, +); Spinner.displayName = 'Spinner'; diff --git a/lib/platform-bible-react/src/components/shadcn-ui/dialog.tsx b/lib/platform-bible-react/src/components/shadcn-ui/dialog.tsx index 56a61f4a4f..ec044c9a71 100644 --- a/lib/platform-bible-react/src/components/shadcn-ui/dialog.tsx +++ b/lib/platform-bible-react/src/components/shadcn-ui/dialog.tsx @@ -27,6 +27,7 @@ const DialogOverlay = React.forwardRef< )); DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; +/* TODO: bug in shadcn dialog: header and x icon do not make use of the dir prop */ const DialogContent = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef @@ -50,7 +51,6 @@ const DialogContent = React.forwardRef< )); DialogContent.displayName = DialogPrimitive.Content.displayName; - function DialogHeader({ className, ...props }: React.HTMLAttributes) { return (
, DropdownMenuContentProps diff --git a/lib/platform-bible-react/src/components/shadcn-ui/switch.tsx b/lib/platform-bible-react/src/components/shadcn-ui/switch.tsx index b4777a02b6..2c21a5714d 100644 --- a/lib/platform-bible-react/src/components/shadcn-ui/switch.tsx +++ b/lib/platform-bible-react/src/components/shadcn-ui/switch.tsx @@ -1,12 +1,12 @@ -import React from 'react'; import * as SwitchPrimitives from '@radix-ui/react-switch'; +import React from 'react'; import { cn } from '@/utils/shadcn-ui.util'; const Switch = React.forwardRef< React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( + React.ComponentPropsWithoutRef & { direction?: 'ltr' | 'rtl' } +>(({ className, direction, ...props }, ref) => ( diff --git a/lib/platform-bible-react/src/preview/pages/components/advanced.component.tsx b/lib/platform-bible-react/src/preview/pages/components/advanced.component.tsx index feb47df92f..1d5ba0315b 100644 --- a/lib/platform-bible-react/src/preview/pages/components/advanced.component.tsx +++ b/lib/platform-bible-react/src/preview/pages/components/advanced.component.tsx @@ -89,21 +89,12 @@ function Compositions({ direction }: HasDirection) { - +
{JSON.stringify(scrRef)}
- - - - - -
Scroll Group Id: {`${scrollGroupId}`}
+
@@ -132,15 +123,11 @@ function Compositions({ direction }: HasDirection) { - - - - - + - + @@ -154,10 +141,24 @@ function Compositions({ direction }: HasDirection) { /> + + + + + + +
Scroll Group Id: {`${scrollGroupId}`}
+
+ diff --git a/lib/platform-bible-react/src/preview/pages/components/advanced/book-selector-example.component.tsx b/lib/platform-bible-react/src/preview/pages/components/advanced/book-selector-example.component.tsx index 8a1e0fddc3..a0fc94610b 100644 --- a/lib/platform-bible-react/src/preview/pages/components/advanced/book-selector-example.component.tsx +++ b/lib/platform-bible-react/src/preview/pages/components/advanced/book-selector-example.component.tsx @@ -1,4 +1,5 @@ import BookSelector, { BookSelectionMode } from '@/components/advanced/book-selector.component'; +import { HasDirection } from '@/preview/preview-components/direction-toggle.component'; import { Canon } from '@sillsdev/scripture'; import { useState } from 'react'; @@ -8,7 +9,7 @@ const localizedStrings = { '%webView_bookSelector_chooseBooks%': 'Choose Books', }; -function BookSelectorExample() { +function BookSelectorExample({ direction }: HasDirection) { const [startChapter, setStartChapter] = useState(0); const [endChapter, setEndChapter] = useState(0); const selectedBooksIds = [ @@ -36,6 +37,7 @@ function BookSelectorExample() { onSelectBooks={handleSelectBooks} selectedBookIds={selectedBooksIds} localizedStrings={localizedStrings} + direction={direction} /> ); } diff --git a/lib/platform-bible-react/src/preview/pages/components/advanced/inventory-example.component.tsx b/lib/platform-bible-react/src/preview/pages/components/advanced/inventory-example.component.tsx index 4ed2d3f5c9..e3af2b42cd 100644 --- a/lib/platform-bible-react/src/preview/pages/components/advanced/inventory-example.component.tsx +++ b/lib/platform-bible-react/src/preview/pages/components/advanced/inventory-example.component.tsx @@ -6,6 +6,7 @@ import { } from '@/components/advanced/inventory/inventory-columns'; import { InventoryTableData } from '@/components/advanced/inventory/inventory-utils'; import Inventory, { Scope } from '@/components/advanced/inventory/inventory.component'; +import { HasDirection } from '@/preview/preview-components/direction-toggle.component'; import { defaultScrRef } from 'platform-bible-utils'; import { useState } from 'react'; import scriptureSnippet from './scripture-snippet'; @@ -29,6 +30,7 @@ const createColumns = ( onApprovedItemsChange: (items: string[]) => void, unapprovedItems: string[], onUnapprovedItemsChange: (items: string[]) => void, + direction: 'ltr' | 'rtl', ): ColumnDef[] => [ inventoryItemColumn('Item'), inventoryCountColumn('Count'), @@ -38,10 +40,11 @@ const createColumns = ( onApprovedItemsChange, unapprovedItems, onUnapprovedItemsChange, + direction, ), ]; -function InventoryExample() { +function InventoryExample({ direction }: HasDirection) { const [scrRef, setScrRef] = useState(defaultScrRef); const [approvedItems, setApprovedItems] = useState(['well', 'he']); const [unapprovedItems, setUnapprovedItems] = useState(['for', 'of']); @@ -63,10 +66,16 @@ function InventoryExample() { setApprovedItems, unapprovedItems, setUnapprovedItems, + direction, )} // Matches a sequence of letters surrounded by word boundaries followed by that exact same // sequence of letters surrounded by word boundaries extractItems={/\b(\p{L}+)\b(?=\s\b\1\b)/gu} + direction={direction} + additionalItemsLabels={{ + checkboxText: 'additional header', + tableHeaders: ['additional header'], + }} /> Approved items:
    diff --git a/lib/platform-bible-react/src/preview/pages/components/advanced/marketplace-buttons.example.component.tsx b/lib/platform-bible-react/src/preview/pages/components/advanced/marketplace-buttons.example.component.tsx index 71e7238e55..07f12af35d 100644 --- a/lib/platform-bible-react/src/preview/pages/components/advanced/marketplace-buttons.example.component.tsx +++ b/lib/platform-bible-react/src/preview/pages/components/advanced/marketplace-buttons.example.component.tsx @@ -32,37 +32,37 @@ export default function MarketplaceButtonExamples() { ], }; return ( - <> +

    Note: These buttons are currently styled with fixed colors and are therefore not theme-able


    FilterButton Button: -
    +
    InstallButton Button: -
    +
    {}} buttonText="Get" /> {}} buttonText="Get" /> {}} /> {}} />
    DisableButton Button: -
    +
    {}} /> {}} />
    EnableButton Button: -
    +
    {}} /> {}} />
    UpdateButton Button: -
    +
    {}} /> {}} />
    - +
    ); } diff --git a/lib/platform-bible-react/src/preview/pages/components/advanced/multi-select-combo-box-example.tsx b/lib/platform-bible-react/src/preview/pages/components/advanced/multi-select-combo-box-example.tsx index a640fcfae9..5c5c2f71d8 100644 --- a/lib/platform-bible-react/src/preview/pages/components/advanced/multi-select-combo-box-example.tsx +++ b/lib/platform-bible-react/src/preview/pages/components/advanced/multi-select-combo-box-example.tsx @@ -1,4 +1,5 @@ import MultiSelectComboBox from '@/components/advanced/multi-select-combo-box'; +import { HasDirection } from '@/preview/preview-components/direction-toggle.component'; import { Blocks } from 'lucide-react'; import { useState } from 'react'; @@ -123,7 +124,7 @@ const resources = [ }, ]; -function MultiSelectComboBoxExample() { +function MultiSelectComboBoxExample({ direction }: HasDirection) { const [selectedTypes, setSelectedTypes] = useState(types.map((type) => type.value)); const getOptionsCount = (option: MultiSelectComboBoxEntry): number => { @@ -145,6 +146,7 @@ function MultiSelectComboBoxExample() { : `${selectedTypes.length} type${selectedTypes.length > 1 ? 's' : ''}` } icon={} + direction={direction} />
    diff --git a/lib/platform-bible-react/src/preview/pages/components/basics.component.tsx b/lib/platform-bible-react/src/preview/pages/components/basics.component.tsx index 912b54f60a..c82b1d37ce 100644 --- a/lib/platform-bible-react/src/preview/pages/components/basics.component.tsx +++ b/lib/platform-bible-react/src/preview/pages/components/basics.component.tsx @@ -1,4 +1,3 @@ -import SearchBar from '@/components/basics/search-bar.component'; import { VerticalTabs, VerticalTabsContent, @@ -17,6 +16,7 @@ import ComboBoxExamples from './basics/combo-box.examples.component'; import DropdownExamples from './basics/dropdown.examples.component'; import InputExamples from './basics/input.examples.component'; import RadioGroupExamples from './basics/radio-group.examples'; +import SearchBarExamples from './basics/search.examples.component'; import SelectExamples from './basics/select.examples.component'; import SettingsSidebarExamples from './basics/sidebar.examples.component'; import SliderExamples from './basics/slider.examples.component'; @@ -26,6 +26,7 @@ import SwitchExamples from './basics/switch.examples.component'; import TabExamples from './basics/tab.examples.component'; import TableExamples from './basics/table.examples.component'; import ToggleGroupExamples from './basics/toggle-group.examples.component'; +import DialogExamples from './basics/dialog.examples.component'; function Basics({ direction }: HasDirection) { return ( @@ -43,6 +44,7 @@ function Basics({ direction }: HasDirection) { Checkbox Checklist Combo Box + Dialog Dropdown Menu Input Radio Group @@ -75,7 +77,7 @@ function Basics({ direction }: HasDirection) { - + @@ -90,19 +92,20 @@ function Basics({ direction }: HasDirection) { + + + + - + -
    - alert(`you searched for ${search}`)} />{' '} - {direction === 'rtl' ? <>→ : <>←} type here -
    +
    @@ -116,7 +119,7 @@ function Basics({ direction }: HasDirection) { - + @@ -124,11 +127,11 @@ function Basics({ direction }: HasDirection) { - + - + @@ -144,7 +147,7 @@ function Basics({ direction }: HasDirection) { - +
    diff --git a/lib/platform-bible-react/src/preview/pages/components/basics/chapter-range-example.component.tsx b/lib/platform-bible-react/src/preview/pages/components/basics/chapter-range-example.component.tsx index b45dfdc8d2..b405412a5f 100644 --- a/lib/platform-bible-react/src/preview/pages/components/basics/chapter-range-example.component.tsx +++ b/lib/platform-bible-react/src/preview/pages/components/basics/chapter-range-example.component.tsx @@ -1,8 +1,9 @@ import ChapterRangeSelector from '@/components/basics/chapter-range-selector.component'; +import { HasDirection } from '@/preview/preview-components/direction-toggle.component'; import { getChaptersForBook } from 'platform-bible-utils'; import { useState } from 'react'; -export default function ChapterRangeSelectorExample() { +export default function ChapterRangeSelectorExample({ direction }: HasDirection) { const chapterCount = getChaptersForBook(1); const [startChapter, setStartChapter] = useState(1); const [endChapter, setEndChapter] = useState(chapterCount); @@ -21,6 +22,7 @@ export default function ChapterRangeSelectorExample() { handleSelectStartChapter={handleSelectStart} handleSelectEndChapter={handleSelectEnd} chapterCount={chapterCount} + direction={direction} /> ); } diff --git a/lib/platform-bible-react/src/preview/pages/components/basics/dialog.examples.component.tsx b/lib/platform-bible-react/src/preview/pages/components/basics/dialog.examples.component.tsx new file mode 100644 index 0000000000..36b5236089 --- /dev/null +++ b/lib/platform-bible-react/src/preview/pages/components/basics/dialog.examples.component.tsx @@ -0,0 +1,30 @@ +import { Button } from '@/components/shadcn-ui/button'; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from '@/components/shadcn-ui/dialog'; +import { HasDirection } from '@/preview/preview-components/direction-toggle.component'; + +export default function DialogExamples({ direction }: HasDirection) { + return ( + + + + + + + Clear filters + Clear filters to show all results? + + + + + + + ); +} diff --git a/lib/platform-bible-react/src/preview/pages/components/basics/radio-group.examples.tsx b/lib/platform-bible-react/src/preview/pages/components/basics/radio-group.examples.tsx index 1e227b71c1..567cf27d88 100644 --- a/lib/platform-bible-react/src/preview/pages/components/basics/radio-group.examples.tsx +++ b/lib/platform-bible-react/src/preview/pages/components/basics/radio-group.examples.tsx @@ -1,18 +1,19 @@ import { Label } from '@/components/shadcn-ui/label'; import { RadioGroup, RadioGroupItem } from '@/components/shadcn-ui/radio-group'; +import { HasDirection } from '@/preview/preview-components/direction-toggle.component'; -export default function RadioGroupExamples() { +export default function RadioGroupExamples({ direction }: HasDirection) { return ( - -
    + +
    -
    +
    -
    +
    diff --git a/lib/platform-bible-react/src/preview/pages/components/basics/search.examples.component.tsx b/lib/platform-bible-react/src/preview/pages/components/basics/search.examples.component.tsx new file mode 100644 index 0000000000..eb5c4e7c7a --- /dev/null +++ b/lib/platform-bible-react/src/preview/pages/components/basics/search.examples.component.tsx @@ -0,0 +1,19 @@ +import SearchBar from '@/components/basics/search-bar.component'; +import { HasDirection } from '@/preview/preview-components/direction-toggle.component'; + +// eslint-disable-next-line no-undef +let timer: NodeJS.Timeout; + +function onSearchDebounced(search: string) { + clearTimeout(timer); + timer = setTimeout(() => alert(`you searched for ${search}`), 1000); +} + +export default function SearchBarExamples({ direction }: HasDirection) { + return ( +
    + {' '} + {direction === 'rtl' ? <>→ : <>←} type here +
    + ); +} diff --git a/lib/platform-bible-react/src/preview/pages/components/basics/slider.examples.component.tsx b/lib/platform-bible-react/src/preview/pages/components/basics/slider.examples.component.tsx index 47bf0480f6..ad1075deff 100644 --- a/lib/platform-bible-react/src/preview/pages/components/basics/slider.examples.component.tsx +++ b/lib/platform-bible-react/src/preview/pages/components/basics/slider.examples.component.tsx @@ -1,7 +1,8 @@ import { Slider } from '@/components/shadcn-ui/slider'; +import { HasDirection } from '@/preview/preview-components/direction-toggle.component'; import { useState } from 'react'; -export default function SliderExamples() { +export default function SliderExamples({ direction }: HasDirection) { const [sliderValue, setSlider] = useState([33]); return ( <> @@ -12,6 +13,7 @@ export default function SliderExamples() { step={1} value={sliderValue} onValueChange={setSlider} + dir={direction} /> {sliderValue} diff --git a/lib/platform-bible-react/src/preview/pages/components/basics/spinner.examples.component.tsx b/lib/platform-bible-react/src/preview/pages/components/basics/spinner.examples.component.tsx index 4134930b61..d8a48a9f23 100644 --- a/lib/platform-bible-react/src/preview/pages/components/basics/spinner.examples.component.tsx +++ b/lib/platform-bible-react/src/preview/pages/components/basics/spinner.examples.component.tsx @@ -1,11 +1,12 @@ import Spinner from '@/components/basics/spinner.component'; +import { HasDirection } from '@/preview/preview-components/direction-toggle.component'; -export default function SpinnerExamples() { +export default function SpinnerExamples({ direction }: HasDirection) { return (
    - Default - Red - Size 10 + Default + Red + Size 10
    ); } diff --git a/lib/platform-bible-react/src/preview/pages/components/basics/switch.examples.component.tsx b/lib/platform-bible-react/src/preview/pages/components/basics/switch.examples.component.tsx index 5871f8fae6..d570022f2a 100644 --- a/lib/platform-bible-react/src/preview/pages/components/basics/switch.examples.component.tsx +++ b/lib/platform-bible-react/src/preview/pages/components/basics/switch.examples.component.tsx @@ -1,14 +1,15 @@ import { Switch } from '@/components/shadcn-ui/switch'; +import { HasDirection } from '@/preview/preview-components/direction-toggle.component'; import { useState } from 'react'; -export default function SwitchExamples() { +export default function SwitchExamples({ direction }: HasDirection) { const [value, setValue] = useState(false); return (
    - - - + + +
    ); } diff --git a/lib/platform-bible-react/src/preview/pages/components/basics/toggle-group.examples.component.tsx b/lib/platform-bible-react/src/preview/pages/components/basics/toggle-group.examples.component.tsx index fed9de89b0..5dd83f26ba 100644 --- a/lib/platform-bible-react/src/preview/pages/components/basics/toggle-group.examples.component.tsx +++ b/lib/platform-bible-react/src/preview/pages/components/basics/toggle-group.examples.component.tsx @@ -1,14 +1,15 @@ import { ToggleGroup, ToggleGroupItem } from '@/components/shadcn-ui/toggle-group'; +import { HasDirection } from '@/preview/preview-components/direction-toggle.component'; -export default function ToggleGroupExamples() { +export default function ToggleGroupExamples({ direction }: HasDirection) { return (
    - + A B C - + A B C diff --git a/lib/platform-bible-react/src/preview/pages/layouts.component.tsx b/lib/platform-bible-react/src/preview/pages/layouts.component.tsx index 1715599c3b..7c2b4c068d 100644 --- a/lib/platform-bible-react/src/preview/pages/layouts.component.tsx +++ b/lib/platform-bible-react/src/preview/pages/layouts.component.tsx @@ -34,13 +34,13 @@ function Layouts({ direction }: HasDirection) { - + TODO - + diff --git a/lib/platform-bible-react/src/preview/pages/layouts/resource-manager.layout.component.tsx b/lib/platform-bible-react/src/preview/pages/layouts/resource-manager.layout.component.tsx index 1c76d427ff..ca83e220c2 100644 --- a/lib/platform-bible-react/src/preview/pages/layouts/resource-manager.layout.component.tsx +++ b/lib/platform-bible-react/src/preview/pages/layouts/resource-manager.layout.component.tsx @@ -23,6 +23,7 @@ import { import { cn } from '@/utils/shadcn-ui.util'; import { DialogTitle } from '@radix-ui/react-dialog'; import MultiSelectComboBox from '@/components/advanced/multi-select-combo-box'; +import { HasDirection } from '@/preview/preview-components/direction-toggle.component'; type MultiSelectComboBoxEntry = { value: string; @@ -164,7 +165,7 @@ const tableData = [ }, ]; -export default function GetResourcesExample() { +export default function GetResourcesExample({ direction }: HasDirection) { const [selectedTypes, setSelectedTypes] = React.useState( types.map((type) => type.value), ); @@ -240,7 +241,8 @@ export default function GetResourcesExample() { 1 ? 's' : ''}` } icon={} + direction={direction} /> } + direction={direction} />
    diff --git a/lib/platform-bible-react/src/preview/pages/layouts/toolbar.layout.component.tsx b/lib/platform-bible-react/src/preview/pages/layouts/toolbar.layout.component.tsx index 39b3513134..6c9fcdd961 100644 --- a/lib/platform-bible-react/src/preview/pages/layouts/toolbar.layout.component.tsx +++ b/lib/platform-bible-react/src/preview/pages/layouts/toolbar.layout.component.tsx @@ -1,10 +1,11 @@ import BookChapterControl from '@/components/advanced/book-chapter-control/book-chapter-control.component'; import { MultiColumnMenuProvider } from '@/components/mui/hamburger-menu-button.component'; import Toolbar from '@/components/mui/toolbar.component'; +import { HasDirection } from '@/preview/preview-components/direction-toggle.component'; import { defaultScrRef, Localized, MultiColumnMenu } from 'platform-bible-utils'; import { useState } from 'react'; -export default function ToolbarExamples() { +export default function ToolbarExamples({ direction }: HasDirection) { const [scrRef] = useState(defaultScrRef); const menu: MultiColumnMenu = { columns: {}, groups: {}, items: [] }; const menuProvider: MultiColumnMenuProvider = () => @@ -14,11 +15,11 @@ export default function ToolbarExamples() { return (
    {}}> - {}} /> + {}} direction={direction} /> {}}> - {}} /> + {}} direction={direction} />
    ); diff --git a/lib/platform-bible-react/src/preview/pages/layouts/window.layout.component.tsx b/lib/platform-bible-react/src/preview/pages/layouts/window.layout.component.tsx index 54a102fa28..8489341a73 100644 --- a/lib/platform-bible-react/src/preview/pages/layouts/window.layout.component.tsx +++ b/lib/platform-bible-react/src/preview/pages/layouts/window.layout.component.tsx @@ -28,7 +28,7 @@ export default function WindowOrTabExample({ direction, isFocused }: HasDirectio
    - +