Merge pull request 'Make the seek bar fit the width of a phone' (#46) from fix/seek-bar-fits-phone into main
This commit is contained in:
commit
23845391d4
2 changed files with 11 additions and 2 deletions
|
|
@ -49,3 +49,12 @@ test('it is still a slider that is moved with the keyboard and says where it is
|
||||||
fireEvent.change(slider, { target: { value: '1000' } })
|
fireEvent.change(slider, { target: { value: '1000' } })
|
||||||
expect(onSeek).toHaveBeenCalledWith(1000)
|
expect(onSeek).toHaveBeenCalledWith(1000)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('the bars give way to the width of the screen: no minimum width, and a thin gap on a phone', () => {
|
||||||
|
const peaks = Array.from({ length: 120 }, () => 128)
|
||||||
|
const { container } = render(<Scrubber positionMs={0} durationMs={1000} onSeek={() => {}} size="big" peaks={peaks} />)
|
||||||
|
// 120 bars with a gap of 2px and 1px each would need 358px, more than a phone has.
|
||||||
|
const row = bars(container)[0].parentElement!
|
||||||
|
expect(row).toHaveClass('gap-px', 'sm:gap-[2px]')
|
||||||
|
for (const b of bars(container)) expect(b).toHaveClass('min-w-0')
|
||||||
|
})
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ export default function Scrubber({ positionMs, durationMs, onSeek, size, peaks,
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
'relative flex items-center gap-[2px] rounded-sm focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-ring',
|
'relative flex items-center gap-px rounded-sm sm:gap-[2px] focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-ring',
|
||||||
size === 'bar' ? 'h-11' : 'h-16',
|
size === 'bar' ? 'h-11' : 'h-16',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|
@ -48,7 +48,7 @@ export default function Scrubber({ positionMs, durationMs, onSeek, size, peaks,
|
||||||
data-bar
|
data-bar
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
style={{ height: `${height}%` }}
|
style={{ height: `${height}%` }}
|
||||||
className={cn('min-w-px flex-1 rounded-[2px]', heard ? (friend ? 'bg-friend' : 'bg-primary') : 'bg-input')}
|
className={cn('min-w-0 flex-1 rounded-[2px]', heard ? (friend ? 'bg-friend' : 'bg-primary') : 'bg-input')}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue