From 5374e77070423a8a873af009214914b677728884 Mon Sep 17 00:00:00 2001 From: Brenden Manquen Date: Fri, 19 Dec 2025 10:55:57 -0600 Subject: [PATCH 1/5] feat(ui): add bible reader settings to the bibler reader - refactor popover component to have consistent styling across multiple components and reduce duplication in code. - add bible reader settings and save the users settings to localStorage. --- .../src/components/bible-chapter-picker.tsx | 23 +-- packages/ui/src/components/bible-reader.tsx | 164 ++++++++++++++++-- .../src/components/bible-version-picker.tsx | 75 ++++---- packages/ui/src/components/ui/popover.tsx | 30 +++- 4 files changed, 207 insertions(+), 85 deletions(-) diff --git a/packages/ui/src/components/bible-chapter-picker.tsx b/packages/ui/src/components/bible-chapter-picker.tsx index c86f43f..bd3562d 100644 --- a/packages/ui/src/components/bible-chapter-picker.tsx +++ b/packages/ui/src/components/bible-chapter-picker.tsx @@ -10,7 +10,7 @@ import { import { useControllableState } from '@radix-ui/react-use-controllable-state'; import { useBooks, useTheme } from '@youversion/platform-react-hooks'; import { type BibleBook } from '@youversion/platform-core'; -import { Info, Search, XIcon } from 'lucide-react'; +import { Info, Search } from 'lucide-react'; import { Button } from './ui/button'; import { Popover, PopoverTrigger, PopoverContent, PopoverClose } from './ui/popover'; import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from './ui/accordion'; @@ -137,26 +137,7 @@ function Root({ {children} {/* data-yv-sdk for styles is needed because the popover gets rendered outside of the providers scope **/} - -
-

Books

- - - -
- + >; setChapter: React.Dispatch>; setVersionId: React.Dispatch>; - fontFamily?: string; - fontSize?: number; + currentFontFamily: string; + setCurrentFontFamily: React.Dispatch>; + currentFontSize: number; + setCurrentFontSize: React.Dispatch>; lineHeight?: number; showVerseNumbers: boolean; background: 'light' | 'dark'; @@ -62,7 +65,7 @@ function Root({ versionId: controlledVersionId, defaultVersionId = 111, onVersionChange, - fontFamily, + fontFamily = 'Inter', fontSize = 16, lineHeight, showVerseNumbers = true, @@ -87,6 +90,23 @@ function Root({ onChange: onVersionChange, }); + const [currentFontSize, setCurrentFontSize] = useState(() => { + if (typeof window === 'undefined') return fontSize; + const size = localStorage.getItem('font-size'); + return size ? parseInt(size) : fontSize; + }); + + const [currentFontFamily, setCurrentFontFamily] = useState(() => { + if (typeof window === 'undefined') return fontFamily; + return localStorage.getItem('font-family') || fontFamily; + }); + + useEffect(() => { + if (typeof window === 'undefined') return; + localStorage.setItem('font-size', currentFontSize.toString()); + localStorage.setItem('font-family', currentFontFamily); + }, [currentFontSize, currentFontFamily]); + const providerTheme = useTheme(); const theme = background || providerTheme; @@ -97,8 +117,10 @@ function Root({ setBook, setChapter, setVersionId, - fontFamily, - fontSize, + currentFontFamily, + setCurrentFontFamily, + currentFontSize, + setCurrentFontSize, lineHeight, showVerseNumbers, background: theme, @@ -118,8 +140,15 @@ function Root({ } function Content() { - const { book, chapter, versionId, fontFamily, fontSize, lineHeight, showVerseNumbers } = - useBibleReaderContext(); + const { + book, + chapter, + versionId, + currentFontSize, + currentFontFamily, + lineHeight, + showVerseNumbers, + } = useBibleReaderContext(); const { books } = useBooks(versionId); const { version } = useVersion(versionId); @@ -148,14 +177,17 @@ function Content() { {version?.copyright && ( -