fix(web): keep the player bar on screen, label the settings choices, compact menu on phones

- the player bar stays at the bottom on long pages (sticky sits on its wrapper, not on the bar)
- theme and language groups in Settings have a visible label
- on a phone the menu is a row of links instead of a tall card, and the privacy note is left out there
- the full-screen player is centred vertically
Found by running the app in a real browser against a real server.
This commit is contained in:
tgiachi 2026-11-12 11:58:48 +01:00
commit 80a26aeb4a
6 changed files with 44 additions and 24 deletions

View file

@ -17,25 +17,31 @@ interface ChoiceGroupProps<T extends string> {
/** One choice out of a few, as native radio buttons: the arrow keys and screen readers work as they should. */
export default function ChoiceGroup<T extends string>({ label, choices, value, onChange }: ChoiceGroupProps<T>) {
const name = useId()
const labelId = `${name}-label`
return (
<div role="radiogroup" aria-label={label} className="flex flex-wrap gap-3">
{choices.map((choice) => (
<label
key={choice.value}
className="flex min-h-11 cursor-pointer items-center gap-3 rounded-lg bg-secondary px-4 py-2 font-semibold has-checked:ring-2 has-checked:ring-primary has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ring"
>
<input
type="radio"
name={name}
value={choice.value}
checked={choice.value === value}
onChange={() => onChange(choice.value)}
className="sr-only"
/>
{choice.preview}
<span>{choice.label}</span>
</label>
))}
<div className="flex flex-col gap-2">
<p id={labelId} className="text-sm font-semibold text-muted-foreground">
{label}
</p>
<div role="radiogroup" aria-labelledby={labelId} className="flex flex-wrap gap-3">
{choices.map((choice) => (
<label
key={choice.value}
className="flex min-h-11 cursor-pointer items-center gap-3 rounded-lg bg-secondary px-4 py-2 font-semibold has-checked:ring-2 has-checked:ring-primary has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ring"
>
<input
type="radio"
name={name}
value={choice.value}
checked={choice.value === value}
onChange={() => onChange(choice.value)}
className="sr-only"
/>
{choice.preview}
<span>{choice.label}</span>
</label>
))}
</div>
</div>
)
}

View file

@ -32,7 +32,7 @@ export default function NowPlaying() {
<Dialog open={open && track !== null} onOpenChange={setOpen}>
<DialogContent
showCloseButton={false}
className="inset-0 h-dvh w-screen max-w-none translate-x-0 translate-y-0 content-start overflow-y-auto rounded-none bg-background p-6 sm:max-w-none md:p-12 motion-reduce:data-closed:animate-none motion-reduce:data-open:animate-none"
className="inset-0 h-dvh w-screen max-w-none translate-x-0 translate-y-0 content-center overflow-y-auto rounded-none bg-background p-6 sm:max-w-none md:p-12 motion-reduce:data-closed:animate-none motion-reduce:data-open:animate-none"
>
{track && (
<>

View file

@ -37,7 +37,7 @@ export default function PlayerBar() {
return (
<footer
aria-label={t('player.label')}
className="sticky bottom-0 z-10 flex flex-wrap items-center gap-x-6 gap-y-3 bg-card px-5 py-3 text-card-foreground"
className="flex flex-wrap items-center gap-x-6 gap-y-3 rounded-xl bg-card px-5 py-3 text-card-foreground"
>
<div className="flex min-w-0 flex-[1_1_240px] items-center gap-3">
{track ? (

View file

@ -14,7 +14,8 @@ export default function Shell() {
<Outlet />
</main>
</div>
<div className="px-2 pb-2">
{/* Sticky here, not on the bar: a sticky element only sticks inside its parent. */}
<div className="sticky bottom-0 z-10 bg-background px-2 pb-2">
<PlayerBar />
</div>
</div>

View file

@ -14,7 +14,10 @@ const LINKS = [
export default function Sidebar() {
const { t } = useTranslation()
return (
<nav aria-label={t('nav.main')} className="flex flex-[0_0_248px] flex-col gap-6 rounded-xl bg-card p-5 text-card-foreground">
<nav
aria-label={t('nav.main')}
className="flex flex-[0_0_248px] flex-col gap-6 rounded-xl bg-card p-5 text-card-foreground max-sm:flex-[1_1_100%] max-sm:gap-3 max-sm:p-3"
>
<div className="flex items-center gap-3">
<svg width="28" height="28" viewBox="0 0 28 28" fill="none" aria-hidden="true">
<circle cx="14" cy="14" r="3" fill="var(--primary)" />
@ -23,7 +26,7 @@ export default function Sidebar() {
</svg>
<span className="text-[22px] font-extrabold tracking-tight">{t('app.name')}</span>
</div>
<ul className="flex flex-col gap-1">
<ul className="flex flex-col gap-1 max-sm:flex-row max-sm:flex-wrap">
{LINKS.map((link) => (
<li key={link.to}>
<NavLink
@ -41,7 +44,9 @@ export default function Sidebar() {
</li>
))}
</ul>
<p className="mt-auto rounded-lg bg-secondary px-3 py-2.5 text-[13px] text-muted-foreground">{t('app.privacy')}</p>
<p className="mt-auto rounded-lg bg-secondary px-3 py-2.5 text-[13px] text-muted-foreground max-sm:hidden">
{t('app.privacy')}
</p>
</nav>
)
}

View file

@ -51,6 +51,14 @@ test('a user who is not an admin is not called one', () => {
expect(screen.queryByText('Admin')).not.toBeInTheDocument()
})
test('each group of choices has a label you can see, not only one for screen readers', () => {
renderSettings()
expect(screen.getByText('Theme')).toBeVisible()
expect(screen.getByText('Language')).toBeVisible()
expect(screen.getByRole('radiogroup', { name: 'Theme' })).toBeInTheDocument()
expect(screen.getByRole('radiogroup', { name: 'Language' })).toBeInTheDocument()
})
test('all four themes can be chosen and the current one is selected', async () => {
renderSettings()
const group = screen.getByRole('radiogroup', { name: 'Theme' })