Merge pull request 'Audit follow-ups: skip link, lighter player, lazy pages, small polish' (#131) from feat/audit-followups into main

This commit is contained in:
squidd 2026-11-13 12:57:18 +01:00
commit cded6f063e
28 changed files with 308 additions and 172 deletions

View file

@ -4,8 +4,8 @@ import { ApiError } from '@/api/client'
import { useMySettings, useUpdateSettings } from '@/api/discover'
import { Button } from '@/components/ui/button'
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog'
import { Switch } from '@/components/ui/switch'
import { errorMessageKey } from '@/i18n'
import { cn } from '@/lib/utils'
/**
* Whether Discover may start from the artists you play most. Turning it on sends their names to Last.fm
@ -26,26 +26,12 @@ export default function ListeningSwitch() {
return (
<div className="flex max-w-xl flex-col gap-3">
<div className="flex items-center gap-4">
<button
type="button"
role="switch"
aria-checked={on}
<Switch
checked={on}
aria-labelledby="listening-label"
disabled={settings.data === undefined || update.isPending}
onClick={() => (on ? change(false) : setAsking(true))}
className={cn(
'relative h-7 w-12 shrink-0 rounded-md border border-input transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:opacity-50',
on ? 'bg-primary' : 'bg-secondary',
)}
>
<span
aria-hidden="true"
className={cn(
'absolute top-0.5 left-0.5 size-5 rounded-sm transition-transform motion-reduce:transition-none',
on ? 'translate-x-5 bg-primary-foreground' : 'bg-muted-foreground',
)}
/>
</button>
/>
<span id="listening-label" className="font-semibold">
{t('discover.listening.label')}
</span>

View file

@ -0,0 +1,7 @@
import { useTranslation } from 'react-i18next'
/** What is on screen while the first page of a lazy route is being fetched. */
export default function RouteLoading() {
const { t } = useTranslation()
return <div role="status" aria-label={t('common.loading')} className="min-h-screen bg-background" />
}

View file

@ -33,7 +33,7 @@ export default function Scrubber({ positionMs, durationMs, onSeek, variant }: Sc
onChange={(e) => onSeek(Number(e.target.value))}
className={cn(
'cursor-pointer disabled:cursor-default',
variant === 'line' ? 'h-6 w-full accent-primary' : 'absolute inset-0 h-full w-full opacity-0',
variant === 'line' ? '-my-2 h-11 w-full accent-primary' : 'absolute inset-0 h-full w-full opacity-0',
)}
/>
)

View file

@ -16,19 +16,36 @@ import PlayerControls from './PlayerControls'
const UP_NEXT = 3
/** The big seek bar and the times. The part of this screen that follows the playback every moment. */
function NowPlayingSeek({ durationMs }: { durationMs: number }) {
const positionMs = usePlayer((s) => s.positionMs)
const seek = usePlayer((s) => s.seek)
return (
<div className="flex flex-col gap-1">
<Scrubber positionMs={positionMs} durationMs={durationMs} onSeek={seek} variant="bars" />
<div className="flex justify-between text-sm text-muted-foreground tabular-nums">
<span>{formatTime(positionMs)}</span>
<span>{formatTime(durationMs)}</span>
</div>
</div>
)
}
/** The full-screen player: a big cover, the controls and what comes next. */
export default function NowPlaying() {
const { t } = useTranslation()
const { open, setOpen } = useNowPlayingUi()
const player = usePlayer()
const track = currentTrack(player)
const track = usePlayer(currentTrack)
const queue = usePlayer((s) => s.queue)
const index = usePlayer((s) => s.index)
const jumpTo = usePlayer((s) => s.jumpTo)
// Nothing left to show (the queue was emptied): close.
useEffect(() => {
if (open && !track) setOpen(false)
}, [open, track, setOpen])
const upNext = player.queue.slice(player.index + 1, player.index + 1 + UP_NEXT)
const upNext = queue.slice(index + 1, index + 1 + UP_NEXT)
return (
<Dialog open={open && track !== null} onOpenChange={setOpen}>
@ -79,18 +96,7 @@ export default function NowPlaying() {
)}
</div>
<div className="flex flex-col gap-1">
<Scrubber
positionMs={player.positionMs}
durationMs={track.duration_ms}
onSeek={player.seek}
variant="bars"
/>
<div className="flex justify-between text-sm text-muted-foreground tabular-nums">
<span>{formatTime(player.positionMs)}</span>
<span>{formatTime(track.duration_ms)}</span>
</div>
</div>
<NowPlayingSeek durationMs={track.duration_ms} />
<PlayerControls large />
<VolumeControl className="-mt-3" />
@ -102,8 +108,8 @@ export default function NowPlaying() {
<TrackRow
key={`${next.id}-${k}`}
track={next}
index={player.index + 1 + k}
onPlay={() => player.jumpTo(player.index + 1 + k)}
index={index + 1 + k}
onPlay={() => jumpTo(index + 1 + k)}
/>
))}
</section>

View file

@ -1,3 +1,4 @@
import { Profiler } from 'react'
import { act, fireEvent, render, screen, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { MemoryRouter } from 'react-router-dom'
@ -11,6 +12,7 @@ import { usePlayer } from '@/player/store'
import { useNowPlayingUi } from '@/player/ui'
import { fakeFullscreen } from '@/test/fullscreen'
import PlayerBar from './PlayerBar'
import PlayerControls from './PlayerControls'
function track(n: number, over: Partial<Track> = {}): Track {
return {
@ -303,3 +305,24 @@ test('Tab stays inside the full-screen player', async () => {
for (const el of outside) if (el) expect(el.contains(document.activeElement)).toBe(false)
}
})
test('the controls and the title do not render again when only the position moves', () => {
usePlayer.getState().playTracks([a, b], 0)
let commits = 0
render(
<MemoryRouter>
<Profiler id="controls" onRender={() => commits++}>
<PlayerControls />
</Profiler>
</MemoryRouter>,
)
const before = commits
act(() => usePlayer.getState().tick(5_000))
act(() => usePlayer.getState().tick(6_000))
expect(commits).toBe(before)
})
test('the seek bar of the player bar is 44 pixels high to take a thumb', () => {
render(<Scrubber positionMs={0} durationMs={1000} onSeek={() => {}} variant="line" />)
expect(screen.getByRole('slider')).toHaveClass('h-11')
})

View file

@ -2,6 +2,7 @@ import { ListMusic } from 'lucide-react'
import { useEffect } from 'react'
import { useTranslation } from 'react-i18next'
import { Link } from 'react-router-dom'
import type { Track } from '@/api/catalog'
import Cover from '@/components/Cover'
import FullscreenButton from '@/components/FullscreenButton'
import Scrubber from '@/components/Scrubber'
@ -28,12 +29,26 @@ function usePlayPauseKey() {
}, [])
}
/** The position, the seek bar and the length. The only part of the bar that follows the playback every moment. */
function PlayerSeek({ track }: { track: Track | null }) {
const positionMs = usePlayer((s) => s.positionMs)
const seek = usePlayer((s) => s.seek)
return (
<div className="player-seek flex w-full max-w-xl items-center gap-3 justify-self-center text-[13px] text-muted-foreground tabular-nums">
<span>{formatTime(track ? positionMs : 0)}</span>
<div className="flex-1">
<Scrubber positionMs={positionMs} durationMs={track?.duration_ms ?? 0} onSeek={seek} variant="line" />
</div>
<span>{formatTime(track?.duration_ms ?? 0)}</span>
</div>
)
}
/** The bar at the bottom of every page: what is playing, the controls and the position. */
export default function PlayerBar() {
const { t } = useTranslation()
const player = usePlayer()
const setOpen = useNowPlayingUi((s) => s.setOpen)
const track = currentTrack(player)
const track = usePlayer(currentTrack)
usePlayPauseKey()
return (
@ -74,18 +89,7 @@ export default function PlayerBar() {
<PlayerControls />
</div>
<div className="player-seek flex w-full max-w-xl items-center gap-3 justify-self-center text-[13px] text-muted-foreground tabular-nums">
<span>{formatTime(track ? player.positionMs : 0)}</span>
<div className="flex-1">
<Scrubber
positionMs={player.positionMs}
durationMs={track?.duration_ms ?? 0}
onSeek={player.seek}
variant="line"
/>
</div>
<span>{formatTime(track?.duration_ms ?? 0)}</span>
</div>
<PlayerSeek track={track} />
<div className="player-extras flex items-center justify-end max-sm:hidden">
<VolumeControl />

View file

@ -7,45 +7,52 @@ import { currentTrack, usePlayer } from '@/player/store'
/** Shuffle, previous, play/pause, next and repeat. Used by the player bar and the full-screen player. */
export default function PlayerControls({ large = false }: { large?: boolean }) {
const { t } = useTranslation()
const player = usePlayer()
const none = currentTrack(player) === null
const none = usePlayer((s) => currentTrack(s) === null)
const playing = usePlayer((s) => s.playing)
const shuffle = usePlayer((s) => s.shuffle)
const repeat = usePlayer((s) => s.repeat)
const toggleShuffle = usePlayer((s) => s.toggleShuffle)
const prev = usePlayer((s) => s.prev)
const togglePlay = usePlayer((s) => s.togglePlay)
const next = usePlayer((s) => s.next)
const cycleRepeat = usePlayer((s) => s.cycleRepeat)
const small = large ? 'size-12' : 'size-11'
const repeatLabel = { off: 'player.repeatOff', all: 'player.repeatAll', one: 'player.repeatOne' }[player.repeat]
const repeatLabel = { off: 'player.repeatOff', all: 'player.repeatAll', one: 'player.repeatOne' }[repeat]
return (
<div className="flex items-center gap-1 sm:gap-3">
<Button
variant="ghost"
className={cn(small, player.shuffle ? 'text-primary' : 'text-muted-foreground')}
className={cn(small, shuffle ? 'text-primary' : 'text-muted-foreground')}
aria-label={t('player.shuffle')}
aria-pressed={player.shuffle}
aria-pressed={shuffle}
disabled={none}
onClick={player.toggleShuffle}
onClick={toggleShuffle}
>
<Shuffle />
</Button>
<Button variant="ghost" className={small} aria-label={t('player.previous')} disabled={none} onClick={player.prev}>
<Button variant="ghost" className={small} aria-label={t('player.previous')} disabled={none} onClick={prev}>
<SkipBack />
</Button>
<Button
className={cn(large ? 'size-16' : 'size-11', 'rounded-md')}
aria-label={player.playing ? t('player.pause') : t('player.play')}
aria-label={playing ? t('player.pause') : t('player.play')}
disabled={none}
onClick={player.togglePlay}
onClick={togglePlay}
>
{player.playing ? <Pause /> : <Play />}
{playing ? <Pause /> : <Play />}
</Button>
<Button variant="ghost" className={small} aria-label={t('player.next')} disabled={none} onClick={player.next}>
<Button variant="ghost" className={small} aria-label={t('player.next')} disabled={none} onClick={next}>
<SkipForward />
</Button>
<Button
variant="ghost"
className={cn(small, player.repeat === 'off' ? 'text-muted-foreground' : 'text-primary')}
className={cn(small, repeat === 'off' ? 'text-muted-foreground' : 'text-primary')}
aria-label={t(repeatLabel)}
disabled={none}
onClick={player.cycleRepeat}
onClick={cycleRepeat}
>
{player.repeat === 'one' ? <Repeat1 /> : <Repeat />}
{repeat === 'one' ? <Repeat1 /> : <Repeat />}
</Button>
</div>
)

View file

@ -1,5 +1,6 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { render, screen, within } from '@testing-library/react'
import { render, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { createMemoryRouter, RouterProvider } from 'react-router-dom'
import { beforeEach, expect, test, vi } from 'vitest'
import { sessionStore } from '@/auth/session'
@ -12,21 +13,24 @@ beforeEach(async () => {
await initI18n()
})
function renderAt(path: string) {
async function renderAt(path: string) {
const router = createMemoryRouter(routes, { initialEntries: [path] })
render(
<QueryClientProvider client={new QueryClient()}>
<RouterProvider router={router} />
</QueryClientProvider>,
)
// The pages are fetched when first opened: wait until the one asked for is in.
await waitFor(() => expect(router.state.initialized).toBe(true))
await screen.findByRole('main')
}
function mainNav() {
return screen.getByRole('navigation', { name: 'Main' })
}
test('at /artists the Artists link is the current page and the others are not', () => {
renderAt('/artists')
test('at /artists the Artists link is the current page and the others are not', async () => {
await renderAt('/artists')
const nav = within(mainNav())
expect(nav.getByRole('link', { name: 'Artists' })).toHaveAttribute('aria-current', 'page')
for (const name of ['Home', 'Search', 'Discover', 'Albums', 'Songs', 'Settings']) {
@ -39,16 +43,16 @@ const adminRoutes = {
'GET /api/v1/library/scan': () => ({ running: false }),
}
test('an admin has an Admin link, and a user who is not one has none', () => {
test('an admin has an Admin link, and a user who is not one has none', async () => {
sessionStore.setState({ status: 'authenticated', user: { id: 1, email: 'tom@example.org', is_admin: false } })
renderAt('/artists')
await renderAt('/artists')
expect(within(mainNav()).queryByRole('link', { name: 'Admin' })).not.toBeInTheDocument()
})
test('the Admin link opens the libraries and stays current inside the admin area', async () => {
sessionStore.setState({ status: 'authenticated', user: { id: 1, email: 'tom@example.org', is_admin: true } })
mockFetch(adminRoutes)
renderAt('/admin')
await renderAt('/admin')
expect(await screen.findByRole('region', { name: 'Libraries' })).toBeInTheDocument()
expect(within(mainNav()).getByRole('link', { name: 'Admin' })).toHaveAttribute('aria-current', 'page')
})
@ -56,7 +60,7 @@ test('the Admin link opens the libraries and stays current inside the admin area
test('the admin area has a Users section next to Libraries', async () => {
sessionStore.setState({ status: 'authenticated', user: { id: 1, email: 'tom@example.org', is_admin: true } })
mockFetch({ ...adminRoutes, 'GET /api/v1/users': () => ({ users: [{ id: 1, email: 'tom@example.org', is_admin: true }] }) })
renderAt('/admin/users')
await renderAt('/admin/users')
expect(await screen.findByRole('region', { name: 'Users' })).toBeInTheDocument()
const sections = within(screen.getByRole('navigation', { name: 'Admin sections' }))
expect(sections.getByRole('link', { name: 'Users' })).toHaveAttribute('aria-current', 'page')
@ -66,7 +70,7 @@ test('the admin area has a Users section next to Libraries', async () => {
test('the admin area has a Providers section too', async () => {
sessionStore.setState({ status: 'authenticated', user: { id: 1, email: 'tom@example.org', is_admin: true } })
mockFetch({ ...adminRoutes, 'GET /api/v1/providers': () => ({ providers: [] }) })
renderAt('/admin/providers')
await renderAt('/admin/providers')
expect(await screen.findByRole('region', { name: 'Providers' })).toBeInTheDocument()
expect(within(screen.getByRole('navigation', { name: 'Admin sections' })).getByRole('link', { name: 'Providers' })).toHaveAttribute('aria-current', 'page')
})
@ -80,7 +84,7 @@ test('the admin area has a Jobs section too', async () => {
'GET /api/v1/library/artist-images': () => ({ running: false }),
'GET /api/v1/library/descriptions': () => ({ running: false }),
})
renderAt('/admin/jobs')
await renderAt('/admin/jobs')
expect(await screen.findByRole('region', { name: 'Jobs' })).toBeInTheDocument()
expect(within(screen.getByRole('navigation', { name: 'Admin sections' })).getByRole('link', { name: 'Jobs' })).toHaveAttribute('aria-current', 'page')
})
@ -88,8 +92,8 @@ test('the admin area has a Jobs section too', async () => {
test('someone who is not an admin who opens the jobs address gets a notice and no request', async () => {
sessionStore.setState({ status: 'authenticated', user: { id: 2, email: 'ann@example.org', is_admin: false } })
const { calls } = mockFetch({ 'GET /api/v1/library/covers': () => ({ running: false }) })
renderAt('/admin/jobs')
expect(screen.getByText('Only admins can see this page.')).toBeInTheDocument()
await renderAt('/admin/jobs')
expect(await screen.findByText('Only admins can see this page.')).toBeInTheDocument()
await new Promise((r) => setTimeout(r, 30))
expect(calls).toHaveLength(0)
})
@ -97,8 +101,8 @@ test('someone who is not an admin who opens the jobs address gets a notice and n
test('someone who is not an admin who opens the providers address gets a notice and no request', async () => {
sessionStore.setState({ status: 'authenticated', user: { id: 2, email: 'ann@example.org', is_admin: false } })
const { calls } = mockFetch({ 'GET /api/v1/providers': () => ({ providers: [] }) })
renderAt('/admin/providers')
expect(screen.getByText('Only admins can see this page.')).toBeInTheDocument()
await renderAt('/admin/providers')
expect(await screen.findByText('Only admins can see this page.')).toBeInTheDocument()
await new Promise((r) => setTimeout(r, 30))
expect(calls).toHaveLength(0)
})
@ -106,8 +110,8 @@ test('someone who is not an admin who opens the providers address gets a notice
test('someone who is not an admin who opens the users address gets a notice and no request', async () => {
sessionStore.setState({ status: 'authenticated', user: { id: 2, email: 'ann@example.org', is_admin: false } })
const { calls } = mockFetch({ 'GET /api/v1/users': () => ({ users: [] }) })
renderAt('/admin/users')
expect(screen.getByText('Only admins can see this page.')).toBeInTheDocument()
await renderAt('/admin/users')
expect(await screen.findByText('Only admins can see this page.')).toBeInTheDocument()
await new Promise((r) => setTimeout(r, 30))
expect(calls).toHaveLength(0)
})
@ -115,30 +119,30 @@ test('someone who is not an admin who opens the users address gets a notice and
test('someone who is not an admin who opens the admin address gets a notice and no request', async () => {
sessionStore.setState({ status: 'authenticated', user: { id: 2, email: 'ann@example.org', is_admin: false } })
const { calls } = mockFetch(adminRoutes)
renderAt('/admin/libraries')
expect(screen.getByText('Only admins can see this page.')).toBeInTheDocument()
await renderAt('/admin/libraries')
expect(await screen.findByText('Only admins can see this page.')).toBeInTheDocument()
await new Promise((r) => setTimeout(r, 30))
expect(calls.filter((c) => c.url.pathname.includes('librar'))).toHaveLength(0)
})
test('Home is the current page only on /', () => {
renderAt('/')
test('Home is the current page only on /', async () => {
await renderAt('/')
expect(within(mainNav()).getByRole('link', { name: 'Home' })).toHaveAttribute('aria-current', 'page')
})
test('an artist page keeps the Artists link current', () => {
renderAt('/artists/5')
test('an artist page keeps the Artists link current', async () => {
await renderAt('/artists/5')
expect(within(mainNav()).getByRole('link', { name: 'Artists' })).toHaveAttribute('aria-current', 'page')
})
test('the page has one main landmark and says what the server does with data', () => {
renderAt('/songs')
test('the page has one main landmark and says what the server does with data', async () => {
await renderAt('/songs')
expect(screen.getAllByRole('main')).toHaveLength(1)
expect(screen.getByText('Nothing leaves this server unless an admin turns a provider on.')).toBeInTheDocument()
})
test('the home page opens with a greeting as its heading', () => {
renderAt('/')
test('the home page opens with a greeting as its heading', async () => {
await renderAt('/')
expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent(/^Good (morning|afternoon|evening)$/)
})
@ -149,19 +153,29 @@ test.each([
['/songs', 'Songs'],
['/discover', 'Discover'],
['/settings', 'Settings'],
])('the route %s opens a page headed %s', (path, heading) => {
renderAt(path)
])('the route %s opens a page headed %s', async (path, heading) => {
await renderAt(path)
expect(screen.getByRole('heading', { level: 1, name: heading })).toBeInTheDocument()
})
test.each(['/artists/5', '/albums/5'])('the detail route %s opens inside the shell and starts loading', (path) => {
test.each(['/artists/5', '/albums/5'])('the detail route %s opens inside the shell and starts loading', async (path) => {
mockFetch({})
renderAt(path)
await renderAt(path)
expect(within(screen.getByRole('main')).getByRole('status')).toHaveTextContent('Loading')
})
test('an unknown path shows the not-found page with a way back', () => {
renderAt('/no/such/page')
test('an unknown path shows the not-found page with a way back', async () => {
await renderAt('/no/such/page')
expect(screen.getByRole('heading', { name: 'This page does not exist' })).toBeInTheDocument()
expect(screen.getByRole('link', { name: 'Back to Home' })).toHaveAttribute('href', '/')
})
test('a skip link comes first and moves the focus to the page', async () => {
const user = userEvent.setup()
await renderAt('/artists')
await user.tab()
const skip = screen.getByRole('link', { name: 'Skip to content' })
expect(skip).toHaveFocus()
await user.keyboard('{Enter}')
expect(screen.getByRole('main')).toHaveFocus()
})

View file

@ -1,3 +1,5 @@
import { useRef } from 'react'
import { useTranslation } from 'react-i18next'
import { Outlet } from 'react-router-dom'
import { usePlayerEngine } from '@/player/usePlayer'
import UpdateNotice from '@/pwa/UpdateNotice'
@ -6,12 +8,30 @@ import Sidebar from './Sidebar'
/** The frame of the app: the sidebar, the page, and the player bar. */
export default function Shell() {
const { t } = useTranslation()
const main = useRef<HTMLElement>(null)
usePlayerEngine()
return (
<div className="flex min-h-screen flex-col bg-background text-foreground">
{/* The first stop of the Tab key: it jumps over the sidebar. It moves the focus itself, so the address does not change. */}
<a
href="#main"
onClick={(e) => {
e.preventDefault()
main.current?.focus()
}}
className="sr-only focus-visible:not-sr-only focus-visible:fixed focus-visible:top-2 focus-visible:left-2 focus-visible:z-50 focus-visible:rounded-md focus-visible:bg-primary focus-visible:px-4 focus-visible:py-2 focus-visible:font-bold focus-visible:text-primary-foreground"
>
{t('app.skip')}
</a>
<div className="flex flex-1 flex-wrap gap-2 p-2">
<Sidebar />
<main className="min-w-0 flex-[999_1_560px] rounded-xl bg-card p-6 text-card-foreground">
<main
id="main"
ref={main}
tabIndex={-1}
className="min-w-0 flex-[999_1_560px] rounded-xl bg-card p-6 text-card-foreground outline-none"
>
<Outlet />
</main>
</div>

View file

@ -0,0 +1,23 @@
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { expect, test, vi } from 'vitest'
import { Switch } from './switch'
test('it is a switch that says whether it is on and reports a click', async () => {
const onClick = vi.fn()
render(<Switch checked={false} aria-label="Wi-Fi" onClick={onClick} />)
const sw = screen.getByRole('switch', { name: 'Wi-Fi' })
expect(sw).toHaveAttribute('aria-checked', 'false')
await userEvent.click(sw)
expect(onClick).toHaveBeenCalledTimes(1)
})
test('the area that takes a tap is 44 pixels high, and a disabled switch ignores taps', async () => {
const onClick = vi.fn()
render(<Switch checked disabled aria-label="Wi-Fi" onClick={onClick} />)
const sw = screen.getByRole('switch')
expect(sw).toHaveClass('h-11')
expect(sw).toHaveAttribute('aria-checked', 'true')
await userEvent.click(sw)
expect(onClick).not.toHaveBeenCalled()
})

View file

@ -0,0 +1,37 @@
import type { ComponentProps } from 'react'
import { cn } from '@/lib/utils'
interface SwitchProps extends Omit<ComponentProps<'button'>, 'role' | 'type' | 'children'> {
checked: boolean
}
/** An on/off switch. The button is 44 pixels high so that a thumb finds it; the track drawn inside is smaller. */
export function Switch({ checked, className, ...props }: SwitchProps) {
return (
<button
type="button"
role="switch"
aria-checked={checked}
className={cn(
'group flex h-11 w-12 shrink-0 items-center rounded-md focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:opacity-50',
className,
)}
{...props}
>
<span
aria-hidden="true"
className={cn(
'relative h-7 w-full rounded-md border border-input transition-colors',
checked ? 'bg-primary' : 'bg-secondary',
)}
>
<span
className={cn(
'absolute top-0.5 left-0.5 size-5 rounded-sm transition-transform motion-reduce:transition-none',
checked ? 'translate-x-5 bg-primary-foreground' : 'bg-muted-foreground',
)}
/>
</span>
</button>
)
}

View file

@ -1,6 +1,7 @@
{
"app": {
"name": "Sonda",
"skip": "Skip to content",
"privacy": "Nothing leaves this server unless an admin turns a provider on."
},
"nav": {

View file

@ -1,6 +1,7 @@
{
"app": {
"name": "Sonda",
"skip": "Vai al contenuto",
"privacy": "Niente esce da questo server finché un admin non accende un provider."
},
"nav": {

View file

@ -52,6 +52,16 @@
* {
@apply border-border outline-ring/50;
}
/* A line of reading stays readable on a wide screen, and no line ends on a lone word. */
p {
max-width: 56ch;
text-wrap: pretty;
}
h1,
h2,
h3 {
text-wrap: balance;
}
body {
@apply bg-background text-foreground;
}

View file

@ -44,7 +44,7 @@ function MixView({ id }: { id: string }) {
<MixCover albumIds={mix.album_ids} size={232} fluid />
<div className="flex min-w-0 flex-1 basis-80 flex-col gap-3">
<h1 className="text-4xl font-extrabold tracking-tight md:text-6xl">{title}</h1>
{mix.artists.length > 0 && <p className="max-w-2xl text-muted-foreground">{t('mixes.with', { artists: mix.artists.join(', ') })}</p>}
{mix.artists.length > 0 && <p className="text-muted-foreground">{t('mixes.with', { artists: mix.artists.join(', ') })}</p>}
<p className="text-muted-foreground">{t('playlists.meta', { count: mix.tracks.length, duration: formatTime(duration) })}</p>
<div className="flex flex-wrap gap-2">
<Button className="h-12 gap-2 rounded-md px-6" disabled={empty} onClick={() => playTracks(mix.tracks, 0)}>

View file

@ -88,7 +88,7 @@ function PlaylistView({ id }: { id: number }) {
<MixCover albumIds={p.album_ids} size={232} fluid />
<div className="flex min-w-0 flex-1 basis-80 flex-col gap-3">
<h1 className="text-4xl font-extrabold tracking-tight md:text-6xl">{p.name}</h1>
{p.description && <p className="max-w-2xl text-muted-foreground">{p.description}</p>}
{p.description && <p className="text-muted-foreground">{p.description}</p>}
<p className="text-muted-foreground">{t('playlists.meta', { count: p.track_count, duration: formatTime(p.duration_ms) })}</p>
<div className="flex flex-wrap gap-2">
<Button className="h-12 gap-2 rounded-md px-6" disabled={playableIds.length === 0} onClick={() => play(null)}>

View file

@ -141,7 +141,7 @@ export default function SettingsPage() {
{app.available && (
<Section title={t('settings.app')}>
<p className="max-w-2xl text-muted-foreground">{t('pwa.installIntro')}</p>
<p className="text-muted-foreground">{t('pwa.installIntro')}</p>
<Button className="self-start" onClick={() => void app.install()}>
{t('pwa.install')}
</Button>

View file

@ -56,7 +56,7 @@ function SmartView({ id }: { id: number }) {
<MixCover albumIds={covers.data ?? []} size={232} fluid />
<div className="flex min-w-0 flex-1 basis-80 flex-col gap-3">
<h1 className="text-4xl font-extrabold tracking-tight md:text-6xl">{p.name}</h1>
{p.description && <p className="max-w-2xl text-muted-foreground">{p.description}</p>}
{p.description && <p className="text-muted-foreground">{p.description}</p>}
<ul aria-label={t('smart.rulesTitle')} className="flex flex-wrap gap-2">
{describeRules(t, p.rules).map((line) => (
<li key={line} className="rounded-md bg-secondary px-3 py-1 text-sm font-semibold">

View file

@ -55,7 +55,7 @@ function SuggestedView({ name: key }: { name: string }) {
<MixCover albumIds={covers.data ?? []} size={232} fluid />
<div className="flex min-w-0 flex-1 basis-80 flex-col gap-3">
<h1 className="text-4xl font-extrabold tracking-tight md:text-6xl">{title}</h1>
<p className="max-w-2xl text-muted-foreground">{description}</p>
<p className="text-muted-foreground">{description}</p>
<ul aria-label={t('smart.rulesTitle')} className="flex flex-wrap gap-2">
{describeRules(t, suggested.rules).map((line) => (
<li key={line} className="rounded-md bg-secondary px-3 py-1 text-sm font-semibold">

View file

@ -16,7 +16,7 @@ export default function CostsPage() {
return (
<Section title={t('admin.sectionCosts')}>
<p className="max-w-2xl text-sm text-muted-foreground">{t('admin.costs.intro')}</p>
<p className="text-sm text-muted-foreground">{t('admin.costs.intro')}</p>
<ChoiceGroup
label={t('admin.costs.period')}
value={String(days) as `${Period}`}
@ -47,8 +47,8 @@ export default function CostsPage() {
</div>
))}
</dl>
<p className="max-w-2xl text-sm text-muted-foreground">{t('admin.costs.estimate', { model: query.data.model })}</p>
{query.data.unpriced && <p className="max-w-2xl text-sm text-muted-foreground">{t('admin.costs.unpriced')}</p>}
<p className="text-sm text-muted-foreground">{t('admin.costs.estimate', { model: query.data.model })}</p>
{query.data.unpriced && <p className="text-sm text-muted-foreground">{t('admin.costs.unpriced')}</p>}
</section>
{query.data.daily.length === 0 ? (

Some files were not shown because too many files have changed in this diff Show more