Skip to content

Commit 7eaf380

Browse files
cameronapakclaude
andauthored
YPE-1919: Fix overflow issues on mobile for Bible Reader toolbar and Popovers (#209)
* fix(ui): prevent popovers from overflowing viewport on small screens Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Update bible reader font selection styles Adjusted styling for font selection buttons in the bible reader component to improve visual consistency and responsiveness. Also updated popover component to use a smaller default width on small screens. * Refactor bible reader toolbar layout and styling Adjusted the layout of the Bible reader toolbar to improve responsiveness and visual presentation. This includes changes to grid structures, max-width calculations, and element sizing for better adaptability across different screen sizes. * Update bible reader toolbar styling and variants Refactor the Bible reader toolbar to improve its visual appearance and responsiveness. This includes adjusting grid column definitions, button variants, and min-width properties for better text handling and overall layout. * Fixed a test for the Bible font settings popover * Update changeset message --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3f1b3f4 commit 7eaf380

4 files changed

Lines changed: 49 additions & 21 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@youversion/platform-core': patch
3+
'@youversion/platform-react-hooks': patch
4+
'@youversion/platform-react-ui': patch
5+
---
6+
7+
Fixed some UI bugs that caused the Bible Reader toolbar and its popovers to overflow past the width of the screen on mobile.

packages/ui/src/components/bible-reader.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,10 @@ export const LoadsSavedPreferencesFromLocalStorage: Story = {
541541
});
542542

543543
const sourceSerifButton = screen.getByRole('button', { name: /source serif/i });
544-
await expect(sourceSerifButton).toHaveClass('yv:bg-black');
544+
await expect(sourceSerifButton).toHaveClass('yv:bg-primary');
545545

546546
const interButton = screen.getByRole('button', { name: /inter/i });
547-
await expect(interButton).not.toHaveClass('yv:bg-black');
547+
await expect(interButton).not.toHaveClass('yv:bg-primary');
548548
},
549549
};
550550

packages/ui/src/components/bible-reader.tsx

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,20 @@ function Toolbar({ border = 'top' }: { border?: 'top' | 'bottom' }) {
351351
return (
352352
<section
353353
className={cn(
354-
'yv:flex yv:justify-center yv:gap-2 yv:p-4 yv:bg-background yv:border-border',
354+
'yv:flex yv:justify-center yv:gap-2 yv:p-4 yv:bg-background yv:border-border yv:max-w-screen yv:overflow-x-hidden',
355355
border === 'top' && 'yv:border-t',
356356
border === 'bottom' && 'yv:border-b',
357357
)}
358358
>
359-
<div className={cn('yv:flex yv:grow yv:w-full yv:items-center yv:max-w-lg yv:gap-3')}>
360-
{!!yvContext?.authEnabled && <UserMenu />}
359+
<div
360+
className={cn(
361+
'yv:grid yv:w-full yv:items-center yv:sm:max-w-lg yv:max-w-[calc(100vw-2rem)] yv:gap-3',
362+
yvContext?.authEnabled
363+
? 'yv:grid-cols-[auto_1fr_auto_auto]'
364+
: 'yv:grid-cols-[1fr_auto_auto]',
365+
)}
366+
>
367+
{yvContext?.authEnabled && <UserMenu />}
361368

362369
<BibleChapterPicker.Root
363370
book={book}
@@ -369,11 +376,14 @@ function Toolbar({ border = 'top' }: { border?: 'top' | 'bottom' }) {
369376
>
370377
<BibleChapterPicker.Trigger>
371378
{({ chapterLabel, currentBook, loading }) => (
372-
<div className="yv:relative yv:grow">
379+
<div
380+
className="yv:grid yv:grid-cols-[auto_1fr_auto]
381+
yv:justify-start yv:grid-rows-1 yv:overflow-hidden yv:rounded-full yv:min-w-30 yv:bg-muted yv:text-muted-foreground yv:hover:bg-muted/80"
382+
>
373383
<Button
374-
className="yv:group yv:absolute yv:place-self-center yv:top-0 yv:bottom-0 yv:left-4 yv:z-10 yv:size-6! yv:-translate-x-2 yv:touch-hitbox"
384+
className="yv:min-w-0 yv:group yv:place-self-center yv:max-size-9 yv:touch-hitbox"
375385
size="icon"
376-
variant="secondary"
386+
variant="ghost"
377387
disabled={!canNavigatePrevious}
378388
aria-label="Previous chapter"
379389
onClick={(e) => {
@@ -390,14 +400,21 @@ function Toolbar({ border = 'top' }: { border?: 'top' | 'bottom' }) {
390400
<Button
391401
size="lg"
392402
variant="secondary"
393-
className="yv:w-full yv:font-bold yv:text-foreground yv:tabular-nums"
403+
className="yv:px-0 yv:font-bold yv:text-foreground yv:min-w-[5ch]"
394404
disabled={loading}
395405
aria-label="Change Bible book and chapter"
396406
>
397407
{loading ? (
398408
<LoaderIcon className="yv:size-4 yv:animate-spin yv:text-muted-foreground" />
399409
) : (
400-
`${currentBook?.title || 'Select'} ${chapterLabel || ''}`
410+
<>
411+
<span className="yv:min-w-[3ch] yv:truncate">
412+
{currentBook?.title || 'Select'}
413+
</span>
414+
<span className="yv:tabular-nums yv:min-w-[1ch] yv:truncate">
415+
{chapterLabel || ''}
416+
</span>
417+
</>
401418
)}
402419
</Button>
403420

@@ -409,9 +426,9 @@ function Toolbar({ border = 'top' }: { border?: 'top' | 'bottom' }) {
409426
setChapter(nextResult.chapterId);
410427
}
411428
}}
412-
className="yv:group yv:absolute yv:place-self-center yv:top-0 yv:bottom-0 yv:right-4 yv:z-10 yv:size-6! yv:translate-x-2 yv:touch-hitbox"
429+
className="yv:min-w-0 yv:group yv:place-self-center yv:size-9 yv:touch-hitbox"
413430
size="icon"
414-
variant="secondary"
431+
variant="ghost"
415432
disabled={!canNavigateNext}
416433
aria-label="Next chapter"
417434
>
@@ -432,7 +449,7 @@ function Toolbar({ border = 'top' }: { border?: 'top' | 'bottom' }) {
432449
<Button
433450
size="lg"
434451
variant="secondary"
435-
className="yv:font-bold yv:text-foreground"
452+
className="yv:min-w-[calc(0.25rem*4*2+3ch)] yv:px-4 yv:font-bold yv:text-foreground"
436453
disabled={loading}
437454
aria-label={loading ? 'Loading Bible version' : 'Change Bible version'}
438455
>
@@ -441,7 +458,9 @@ function Toolbar({ border = 'top' }: { border?: 'top' | 'bottom' }) {
441458
{loading ? (
442459
<LoaderIcon className="yv:size-4 yv:animate-spin yv:text-muted-foreground" />
443460
) : (
444-
version?.localized_abbreviation || 'Select version'
461+
<span className="yv:truncate">
462+
{version?.localized_abbreviation || 'Select version'}
463+
</span>
445464
)}
446465
</div>
447466
</Button>
@@ -489,12 +508,13 @@ function Toolbar({ border = 'top' }: { border?: 'top' | 'bottom' }) {
489508
A
490509
</Button>
491510
</div>
511+
492512
<div className="yv:grid yv:grid-cols-2">
493513
<Button
494514
className={cn(
495-
'yv:group yv:dark:bg-muted yv:rounded-r-none yv:dark:border-border yv:rounded-l-[8px] yv:h-auto',
515+
'yv:group yv:dark:bg-muted yv:rounded-r-none yv:border-r-0.5 yv:dark:border-border yv:rounded-l-[8px] yv:h-auto',
496516
currentFontFamily === INTER_FONT
497-
? 'yv:bg-black yv:dark:bg-inherit yv:text-white yv:hover:text-white yv:hover:bg-black/80'
517+
? 'yv:bg-primary yv:border-primary yv:dark:bg-inherit yv:text-primary-foreground yv:hover:text-primary-foreground yv:hover:bg-primary/80'
498518
: '',
499519
)}
500520
onClick={() => setCurrentFontFamily(INTER_FONT)}
@@ -511,14 +531,14 @@ function Toolbar({ border = 'top' }: { border?: 'top' | 'bottom' }) {
511531
>
512532
Font
513533
</span>
514-
<span className="yv:text-xl">Inter</span>
534+
<span className="yv:sm:text-xl yv:text-base">Inter</span>
515535
</div>
516536
</Button>
517537
<Button
518538
className={cn(
519-
'yv:group yv:dark:bg-muted yv:rounded-l-none yv:rounded-r-[8px] yv:h-auto',
539+
'yv:group yv:dark:bg-muted yv:border-l-0.5 yv:rounded-l-none yv:rounded-r-[8px] yv:h-auto',
520540
currentFontFamily === SOURCE_SERIF_FONT
521-
? 'yv:bg-black yv:dark:bg-inherit yv:text-white yv:hover:text-white yv:hover:bg-black/80'
541+
? 'yv:bg-primary yv:border-primary yv:dark:bg-inherit yv:text-primary-foreground yv:hover:text-primary-foreground yv:hover:bg-primary/80'
522542
: '',
523543
)}
524544
onClick={() => setCurrentFontFamily(SOURCE_SERIF_FONT)}
@@ -535,7 +555,7 @@ function Toolbar({ border = 'top' }: { border?: 'top' | 'bottom' }) {
535555
>
536556
Font
537557
</span>
538-
<span className="yv:text-xl yv:font-serif">Source Serif</span>
558+
<span className="yv:sm:text-xl yv:text-base yv:font-serif">Source Serif</span>
539559
</div>
540560
</Button>
541561
</div>

packages/ui/src/components/ui/popover.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ function PopoverContent({
4141
data-yv-theme={theme}
4242
align={align}
4343
sideOffset={sideOffset}
44+
collisionPadding={16}
4445
className={cn(
45-
'yv:bg-popover yv:text-popover-foreground yv:data-[state=open]:animate-in yv:data-[state=closed]:animate-out yv:data-[state=closed]:fade-out-0 yv:data-[state=open]:fade-in-0 yv:data-[state=closed]:zoom-out-95 yv:data-[state=open]:zoom-in-95 yv:data-[side=bottom]:slide-in-from-top-2 yv:data-[side=left]:slide-in-from-right-2 yv:data-[side=right]:slide-in-from-left-2 yv:data-[side=top]:slide-in-from-bottom-2 yv:z-50 yv:origin-(--radix-popover-content-transform-origin) yv:outline-hidden yv:grid yv:grid-rows-[auto_1fr_auto] yv:p-0 yv:h-full yv:max-h-[66svh] yv:w-96 yv:sm:w-sm yv:overflow-hidden yv:rounded-2xl yv:border-0 yv:shadow-lg',
46+
'yv:bg-popover yv:text-popover-foreground yv:data-[state=open]:animate-in yv:data-[state=closed]:animate-out yv:data-[state=closed]:fade-out-0 yv:data-[state=open]:fade-in-0 yv:data-[state=closed]:zoom-out-95 yv:data-[state=open]:zoom-in-95 yv:data-[side=bottom]:slide-in-from-top-2 yv:data-[side=left]:slide-in-from-right-2 yv:data-[side=right]:slide-in-from-left-2 yv:data-[side=top]:slide-in-from-bottom-2 yv:z-50 yv:origin-(--radix-popover-content-transform-origin) yv:outline-hidden yv:grid yv:grid-rows-[auto_1fr_auto] yv:p-0 yv:h-full yv:max-h-[66svh] yv:max-sm:max-w-[calc(100vw-2rem)] yv:w-sm yv:sm:max-w-sm yv:overflow-hidden yv:rounded-2xl yv:border-0 yv:shadow-lg',
4647
className,
4748
)}
4849
{...props}

0 commit comments

Comments
 (0)