Fix sample picker and tempo slider alignment
This commit is contained in:
1 parent
302128fdbc
commit
3caf21794d
5 files changed
+134
-143
No files matched your search
@@ -10,9 +10,14 @@ interface TempoControlProps {
|
||||
onTempoChange: (tempoBpm: number) => void;
|
||||
}
|
||||
|
||||
const TEMPO_TRACK_HEIGHT = 164;
|
||||
const TEMPO_THUMB_SIZE = 18;
|
||||
|
||||
export const TempoControl = memo(function TempoControl({ tempoBpm, onTempoChange }: TempoControlProps) {
|
||||
const popover = usePopoverDisclosure();
|
||||
const tempoProgress = ((tempoBpm - MIN_TEMPO_BPM) / (MAX_TEMPO_BPM - MIN_TEMPO_BPM)) * 100;
|
||||
const tempoThumbCenter = (TEMPO_TRACK_HEIGHT - TEMPO_THUMB_SIZE) / 2
|
||||
+ ((100 - tempoProgress) / 100) * (TEMPO_TRACK_HEIGHT - TEMPO_THUMB_SIZE);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -41,7 +46,13 @@ export const TempoControl = memo(function TempoControl({ tempoBpm, onTempoChange
|
||||
>
|
||||
<div className="tempo-popover-content">
|
||||
<output className="tempo-value" aria-live="polite">{tempoBpm} BPM</output>
|
||||
<div className="tempo-range-track">
|
||||
<div
|
||||
className="tempo-range-track"
|
||||
style={{
|
||||
'--tempo-progress': `${tempoProgress}%`,
|
||||
'--tempo-thumb-center': `${tempoThumbCenter}px`,
|
||||
} as CSSProperties}
|
||||
>
|
||||
<input
|
||||
className="tempo-range"
|
||||
type="range"
|
||||
@@ -50,9 +61,9 @@ export const TempoControl = memo(function TempoControl({ tempoBpm, onTempoChange
|
||||
max={MAX_TEMPO_BPM}
|
||||
step={1}
|
||||
value={tempoBpm}
|
||||
style={{ '--tempo-progress': `${tempoProgress}%` } as CSSProperties}
|
||||
onChange={(event) => onTempoChange(event.currentTarget.valueAsNumber)}
|
||||
/>
|
||||
<span className="tempo-range-thumb" aria-hidden="true" />
|
||||
</div>
|
||||
</div>
|
||||
</IonPopover>
|
||||
|
||||
Reference in new issue
Block a user