fix(web): keep the controls of the full-screen player on screen on a phone
On a short phone screen the play, previous and next buttons were pushed under the bottom edge and needed a scroll to reach. - The seek bar and the controls sit in one block that sticks to the bottom on a phone, above the safe area; what comes next scrolls beneath it. - The cover is capped by the height of the screen as well as its width. - The sound picture is lower on a phone. Wide screens keep the same layout as before. Fixes #43
This commit is contained in:
parent
5eff98a639
commit
a757743161
2 changed files with 33 additions and 5 deletions
|
|
@ -118,7 +118,7 @@ export default function NowPlaying() {
|
||||||
<DialogDescription className="sr-only">{t('player.nowPlaying')}</DialogDescription>
|
<DialogDescription className="sr-only">{t('player.nowPlaying')}</DialogDescription>
|
||||||
|
|
||||||
<div className="mx-auto flex w-full max-w-5xl flex-wrap items-center justify-center gap-x-16 gap-y-6 sm:gap-y-8 sm:pt-10">
|
<div className="mx-auto flex w-full max-w-5xl flex-wrap items-center justify-center gap-x-16 gap-y-6 sm:gap-y-8 sm:pt-10">
|
||||||
<div className="flex min-w-0 flex-[1_1_320px] justify-center max-sm:max-w-72">
|
<div data-phone-cover className="flex min-w-0 flex-[1_1_320px] justify-center max-sm:max-w-[min(18rem,34dvh)]">
|
||||||
<Cover albumId={track.album?.id ?? null} friend={track.friend} size={520} fluid />
|
<Cover albumId={track.album?.id ?? null} friend={track.friend} size={520} fluid />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -155,11 +155,16 @@ export default function NowPlaying() {
|
||||||
{radio && <p className="text-sm font-semibold text-primary">{t('radio.now', { name: radio.title })}</p>}
|
{radio && <p className="text-sm font-semibold text-primary">{t('radio.now', { name: radio.title })}</p>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Visualizer size="full" friend={track.friend !== undefined} className="h-20 w-full sm:h-36" />
|
<Visualizer size="full" friend={track.friend !== undefined} className="h-14 w-full sm:h-36" />
|
||||||
|
|
||||||
<NowPlayingSeek track={track} />
|
{/* On a phone the seek bar and the controls stay at the bottom of the screen while the page scrolls; wide, they are in the flow as before. */}
|
||||||
|
<div
|
||||||
<PlayerControls large className="w-full justify-between sm:w-auto sm:justify-start" />
|
data-phone-dock
|
||||||
|
className="flex flex-col gap-5 max-sm:sticky max-sm:bottom-0 max-sm:z-10 max-sm:-mx-6 max-sm:bg-background max-sm:px-6 max-sm:pt-3 max-sm:pb-[max(0.75rem,env(safe-area-inset-bottom))] sm:contents"
|
||||||
|
>
|
||||||
|
<NowPlayingSeek track={track} />
|
||||||
|
<PlayerControls large className="w-full justify-between sm:w-auto sm:justify-start" />
|
||||||
|
</div>
|
||||||
<VolumeControl className="-mt-3 max-sm:hidden" />
|
<VolumeControl className="-mt-3 max-sm:hidden" />
|
||||||
|
|
||||||
{upNext.length > 0 && (
|
{upNext.length > 0 && (
|
||||||
|
|
|
||||||
|
|
@ -584,6 +584,29 @@ test('the full-screen player controls come in full: shuffle, previous and repeat
|
||||||
for (const name of ['Shuffle', 'Previous', 'Repeat: off']) expect(dialog.getByRole('button', { name })).not.toHaveClass('max-sm:hidden')
|
for (const name of ['Shuffle', 'Previous', 'Repeat: off']) expect(dialog.getByRole('button', { name })).not.toHaveClass('max-sm:hidden')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('on a phone the seek bar and the controls of the full-screen player stay at the bottom while the page scrolls', async () => {
|
||||||
|
act(() => usePlayer.getState().playTracks([a, b, c]))
|
||||||
|
renderBar()
|
||||||
|
await userEvent.click(screen.getByRole('button', { name: 'Open the full-screen player' }))
|
||||||
|
const full = within(screen.getByRole('dialog'))
|
||||||
|
const dock = full.getByRole('button', { name: 'Previous' }).closest('[data-phone-dock]')
|
||||||
|
expect(dock).not.toBeNull()
|
||||||
|
expect(dock).toHaveClass('max-sm:sticky', 'max-sm:bottom-0')
|
||||||
|
// The seek bar and the play button are in the same block, so that both stay on screen.
|
||||||
|
expect(within(dock as HTMLElement).getByRole('slider')).toBeInTheDocument()
|
||||||
|
expect(within(dock as HTMLElement).getByRole('button', { name: 'Pause' })).toBeInTheDocument()
|
||||||
|
// What comes next is not in it: it is what scrolls beneath.
|
||||||
|
expect(within(dock as HTMLElement).queryByRole('region', { name: 'Up next' })).toBeNull()
|
||||||
|
})
|
||||||
|
|
||||||
|
test('on a short phone the cover of the full-screen player shrinks to leave room for the controls', async () => {
|
||||||
|
act(() => usePlayer.getState().playTracks([a, b]))
|
||||||
|
renderBar()
|
||||||
|
await userEvent.click(screen.getByRole('button', { name: 'Open the full-screen player' }))
|
||||||
|
const full = screen.getByRole('dialog')
|
||||||
|
expect(full.querySelector('[data-phone-cover]')?.className).toContain('max-sm:max-w-[min(18rem,34dvh)]')
|
||||||
|
})
|
||||||
|
|
||||||
// --- Gestures on a phone -----------------------------------------------------------------------
|
// --- Gestures on a phone -----------------------------------------------------------------------
|
||||||
|
|
||||||
const touch = (x: number, y: number) => ({ clientX: x, clientY: y })
|
const touch = (x: number, y: number) => ({ clientX: x, clientY: y })
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue