Merge pull request 'Square the corners of the web app' (#22) from feat/sharp-corners into main
This commit is contained in:
commit
ea2478b786
11 changed files with 51 additions and 16 deletions
|
|
@ -13,7 +13,7 @@ export default function FriendChip({ friend, className }: { friend: number; clas
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
aria-label={t('player.fromFriend', { name })}
|
aria-label={t('player.fromFriend', { name })}
|
||||||
className={cn('shrink-0 rounded-full border border-friend px-2.5 text-[13px] leading-5 font-semibold text-friend', className)}
|
className={cn('shrink-0 rounded-md border border-friend px-2.5 text-[13px] leading-5 font-semibold text-friend', className)}
|
||||||
>
|
>
|
||||||
{name}
|
{name}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ export function ShareBars({ label, bars, wide = false }: { label: string; bars:
|
||||||
{bars.map((b) => (
|
{bars.map((b) => (
|
||||||
<li key={b.key} className={cn('grid items-center gap-3', wide ? 'grid-cols-[minmax(9rem,20rem)_1fr_3.5rem]' : 'grid-cols-[minmax(6rem,10rem)_1fr_3.5rem]')}>
|
<li key={b.key} className={cn('grid items-center gap-3', wide ? 'grid-cols-[minmax(9rem,20rem)_1fr_3.5rem]' : 'grid-cols-[minmax(6rem,10rem)_1fr_3.5rem]')}>
|
||||||
<span className="min-w-0 truncate font-medium first-letter:uppercase">{b.label}</span>
|
<span className="min-w-0 truncate font-medium first-letter:uppercase">{b.label}</span>
|
||||||
<span aria-hidden="true" className="h-2 overflow-hidden rounded-full bg-card">
|
<span aria-hidden="true" className="h-2 overflow-hidden rounded-sm bg-card">
|
||||||
<span className="block h-full rounded-full bg-primary" style={{ width: `${Math.min(1, Math.max(0, b.value)) * 100}%` }} />
|
<span className="block h-full rounded-sm bg-primary" style={{ width: `${Math.min(1, Math.max(0, b.value)) * 100}%` }} />
|
||||||
</span>
|
</span>
|
||||||
<span className="text-right text-sm tabular-nums text-muted-foreground">{b.text}</span>
|
<span className="text-right text-sm tabular-nums text-muted-foreground">{b.text}</span>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import type { CSSProperties } from 'react'
|
||||||
import { Volume1, Volume2, VolumeX } from 'lucide-react'
|
import { Volume1, Volume2, VolumeX } from 'lucide-react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
|
|
@ -31,7 +32,8 @@ export default function VolumeControl({ className }: { className?: string }) {
|
||||||
aria-label={t('player.volume')}
|
aria-label={t('player.volume')}
|
||||||
aria-valuetext={`${percent}%`}
|
aria-valuetext={`${percent}%`}
|
||||||
onChange={(e) => setVolume(Number(e.target.value) / 100)}
|
onChange={(e) => setVolume(Number(e.target.value) / 100)}
|
||||||
className="h-11 w-24 cursor-pointer accent-primary max-sm:hidden"
|
style={{ "--fill": `${percent}%` } as CSSProperties}
|
||||||
|
className="slider h-11 w-24 cursor-pointer max-sm:hidden"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ export default function PhoneTabs() {
|
||||||
<span
|
<span
|
||||||
data-bar
|
data-bar
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
className={cn('h-[3px] w-6 rounded-full', tab.current ? ('friend' in tab ? 'bg-friend' : 'bg-primary') : 'bg-transparent')}
|
className={cn('h-[3px] w-6', tab.current ? ('friend' in tab ? 'bg-friend' : 'bg-primary') : 'bg-transparent')}
|
||||||
/>
|
/>
|
||||||
<span>{tab.label}</span>
|
<span>{tab.label}</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
|
||||||
|
|
@ -424,11 +424,11 @@ test('the bar has a heart for a song of this server, and none for a friend’s',
|
||||||
expect(screen.queryByRole('button', { name: /favourites/ })).not.toBeInTheDocument()
|
expect(screen.queryByRole('button', { name: /favourites/ })).not.toBeInTheDocument()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('the play button is round, and teal for this server’s music', () => {
|
test('the play button is square-cornered, and teal for this server’s music', () => {
|
||||||
act(() => usePlayer.getState().playTracks([a]))
|
act(() => usePlayer.getState().playTracks([a]))
|
||||||
renderBar()
|
renderBar()
|
||||||
const play = screen.getByRole('button', { name: 'Pause' })
|
const play = screen.getByRole('button', { name: 'Pause' })
|
||||||
expect(play).toHaveClass('rounded-full', 'bg-primary')
|
expect(play).toHaveClass('rounded-md', 'bg-primary')
|
||||||
expect(play).not.toHaveClass('bg-friend')
|
expect(play).not.toHaveClass('bg-friend')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ export default function PlayerControls({ large = false, className }: { large?: b
|
||||||
<Button
|
<Button
|
||||||
className={cn(
|
className={cn(
|
||||||
large ? 'size-[72px]' : 'size-12',
|
large ? 'size-[72px]' : 'size-12',
|
||||||
'rounded-full',
|
'rounded-md',
|
||||||
friend && 'bg-friend text-friend-foreground hover:bg-friend/80',
|
friend && 'bg-friend text-friend-foreground hover:bg-friend/80',
|
||||||
)}
|
)}
|
||||||
aria-label={playing ? t('player.pause') : t('player.play')}
|
aria-label={playing ? t('player.pause') : t('player.play')}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ interface SwitchProps extends Omit<ComponentProps<'button'>, 'role' | 'type' | '
|
||||||
checked: boolean
|
checked: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
/** An on/off switch: a pill with a round knob. The button is 44 pixels high so that a thumb finds it; the track drawn inside is 32. */
|
/** An on/off switch: a rectangle with a square knob. The button is 44 pixels high so that a thumb finds it; the track drawn inside is 32. */
|
||||||
export function Switch({ checked, className, ...props }: SwitchProps) {
|
export function Switch({ checked, className, ...props }: SwitchProps) {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
|
|
@ -13,7 +13,7 @@ export function Switch({ checked, className, ...props }: SwitchProps) {
|
||||||
role="switch"
|
role="switch"
|
||||||
aria-checked={checked}
|
aria-checked={checked}
|
||||||
className={cn(
|
className={cn(
|
||||||
'group flex h-11 w-14 shrink-0 items-center rounded-full focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:opacity-50',
|
'group flex h-11 w-14 shrink-0 items-center rounded-md focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:opacity-50',
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|
@ -21,13 +21,13 @@ export function Switch({ checked, className, ...props }: SwitchProps) {
|
||||||
<span
|
<span
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
className={cn(
|
className={cn(
|
||||||
'relative h-8 w-full rounded-full border border-input transition-colors',
|
'relative h-8 w-full rounded-md border border-input transition-colors',
|
||||||
checked ? 'border-primary bg-primary' : 'bg-secondary',
|
checked ? 'border-primary bg-primary' : 'bg-secondary',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
'absolute top-0.5 left-0.5 size-6 rounded-full transition-transform motion-reduce:transition-none',
|
'absolute top-0.5 left-0.5 size-6 rounded-sm transition-transform motion-reduce:transition-none',
|
||||||
checked ? 'translate-x-6 bg-primary-foreground' : 'bg-muted-foreground',
|
checked ? 'translate-x-6 bg-primary-foreground' : 'bg-muted-foreground',
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--radius: 0.5rem;
|
--radius: 0.125rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@layer base {
|
@layer base {
|
||||||
|
|
@ -99,3 +99,36 @@
|
||||||
.lift img { transition: transform 200ms ease-out; }
|
.lift img { transition: transform 200ms ease-out; }
|
||||||
.lift:hover img { transform: scale(1.03); }
|
.lift:hover img { transform: scale(1.03); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The volume slider has square corners like the rest: a thin track filled up to the knob, and a bar for a knob. The
|
||||||
|
browser's own slider is round, and no setting makes it square. */
|
||||||
|
.slider {
|
||||||
|
appearance: none;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
.slider::-webkit-slider-runnable-track {
|
||||||
|
height: 4px;
|
||||||
|
background: linear-gradient(to right, var(--primary) var(--fill), var(--input) var(--fill));
|
||||||
|
}
|
||||||
|
.slider::-webkit-slider-thumb {
|
||||||
|
appearance: none;
|
||||||
|
width: 8px;
|
||||||
|
height: 18px;
|
||||||
|
margin-top: -7px;
|
||||||
|
background: var(--primary);
|
||||||
|
}
|
||||||
|
.slider::-moz-range-track {
|
||||||
|
height: 4px;
|
||||||
|
background: var(--input);
|
||||||
|
}
|
||||||
|
.slider::-moz-range-progress {
|
||||||
|
height: 4px;
|
||||||
|
background: var(--primary);
|
||||||
|
}
|
||||||
|
.slider::-moz-range-thumb {
|
||||||
|
width: 8px;
|
||||||
|
height: 18px;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 0;
|
||||||
|
background: var(--primary);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ function Row({ request }: { request: LidarrRequest }) {
|
||||||
<span className="text-sm text-muted-foreground">{t('requests.sent', { when: day.format(new Date(request.requested_at)) })}</span>
|
<span className="text-sm text-muted-foreground">{t('requests.sent', { when: day.format(new Date(request.requested_at)) })}</span>
|
||||||
</div>
|
</div>
|
||||||
<span className={cn('flex items-center gap-2 text-sm font-semibold', arrived ? 'text-foreground' : 'text-muted-foreground')}>
|
<span className={cn('flex items-center gap-2 text-sm font-semibold', arrived ? 'text-foreground' : 'text-muted-foreground')}>
|
||||||
<span aria-hidden="true" className={cn('size-2 rounded-full', arrived ? 'bg-primary' : 'border border-muted-foreground')} />
|
<span aria-hidden="true" className={cn('size-2 rounded-sm', arrived ? 'bg-primary' : 'border border-muted-foreground')} />
|
||||||
{arrived ? t('requests.arrived', { when: day.format(new Date(request.arrived_at ?? request.requested_at)) }) : t('requests.waiting')}
|
{arrived ? t('requests.arrived', { when: day.format(new Date(request.arrived_at ?? request.requested_at)) }) : t('requests.waiting')}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ export default function FederationFriends({ friends }: { friends: FederationFrie
|
||||||
<div className="flex min-w-0 flex-col gap-1">
|
<div className="flex min-w-0 flex-col gap-1">
|
||||||
<span className="flex flex-wrap items-center gap-3">
|
<span className="flex flex-wrap items-center gap-3">
|
||||||
<span className="text-xl font-bold">{friend.name}</span>
|
<span className="text-xl font-bold">{friend.name}</span>
|
||||||
<span className="rounded-full border border-friend px-3 text-[13px] font-semibold text-friend">
|
<span className="rounded-md border border-friend px-3 text-[13px] font-semibold text-friend">
|
||||||
{t(`admin.federation.state.${friend.state}`)}
|
{t(`admin.federation.state.${friend.state}`)}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,7 @@ test('the key of this server is big and in groups of four, in the colour of this
|
||||||
test('the state of a friend is a pill in the friend colour', async () => {
|
test('the state of a friend is a pill in the friend colour', async () => {
|
||||||
server({ enabled: true, key_id: 'abcdef0123456789', friends: [friend({ name: 'Bruno', state: 'incoming', approved_at: null })] })
|
server({ enabled: true, key_id: 'abcdef0123456789', friends: [friend({ name: 'Bruno', state: 'incoming', approved_at: null })] })
|
||||||
renderPage()
|
renderPage()
|
||||||
expect(await screen.findByText('Wants to be your friend')).toHaveClass('border-friend', 'text-friend', 'rounded-full')
|
expect(await screen.findByText('Wants to be your friend')).toHaveClass('border-friend', 'text-friend', 'rounded-md')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('the parts are divided by lines, not put in boxes', async () => {
|
test('the parts are divided by lines, not put in boxes', async () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue