Compare commits
2
Commits
5497b16ac0
...
302128fdbc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
302128fdbc | ||
|
|
e0c33ca624 |
No files matched your search
Binary file not shown.
@@ -1,4 +1,5 @@
|
|||||||
import { useMemo, useRef, useState } from 'react';
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
|
import type { CSSProperties } from 'react';
|
||||||
import {
|
import {
|
||||||
IonAccordion,
|
IonAccordion,
|
||||||
IonAccordionGroup,
|
IonAccordionGroup,
|
||||||
@@ -25,9 +26,28 @@ interface InstrumentSelectorProps {
|
|||||||
export function InstrumentSelector({ onSelectInstrument }: InstrumentSelectorProps) {
|
export function InstrumentSelector({ onSelectInstrument }: InstrumentSelectorProps) {
|
||||||
const [searchQuery, setSearchQuery] = useState('');
|
const [searchQuery, setSearchQuery] = useState('');
|
||||||
const [expandedCategoryIds, setExpandedCategoryIds] = useState<string[]>([]);
|
const [expandedCategoryIds, setExpandedCategoryIds] = useState<string[]>([]);
|
||||||
|
const [viewportHeight, setViewportHeight] = useState(
|
||||||
|
() => window.visualViewport?.height ?? window.innerHeight,
|
||||||
|
);
|
||||||
const popoverRef = useRef<HTMLIonPopoverElement>(null);
|
const popoverRef = useRef<HTMLIonPopoverElement>(null);
|
||||||
const popover = usePopoverDisclosure();
|
const popover = usePopoverDisclosure();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const visualViewport = window.visualViewport;
|
||||||
|
|
||||||
|
function updateViewportHeight(): void {
|
||||||
|
setViewportHeight(visualViewport?.height ?? window.innerHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('resize', updateViewportHeight);
|
||||||
|
visualViewport?.addEventListener('resize', updateViewportHeight);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('resize', updateViewportHeight);
|
||||||
|
visualViewport?.removeEventListener('resize', updateViewportHeight);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
const filteredCategories = useMemo(() => {
|
const filteredCategories = useMemo(() => {
|
||||||
const query = searchQuery.trim().toLowerCase();
|
const query = searchQuery.trim().toLowerCase();
|
||||||
return INSTRUMENT_CATEGORIES.flatMap((category) => {
|
return INSTRUMENT_CATEGORIES.flatMap((category) => {
|
||||||
@@ -110,6 +130,7 @@ export function InstrumentSelector({ onSelectInstrument }: InstrumentSelectorPro
|
|||||||
<IonPopover
|
<IonPopover
|
||||||
ref={popoverRef}
|
ref={popoverRef}
|
||||||
className="instrument-picker-popover"
|
className="instrument-picker-popover"
|
||||||
|
style={{ '--picker-viewport-height': `${viewportHeight}px` } as CSSProperties}
|
||||||
trigger="instrument-add-trigger"
|
trigger="instrument-add-trigger"
|
||||||
triggerAction="click"
|
triggerAction="click"
|
||||||
side="top"
|
side="top"
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ export const BEATS_PER_BAR_OPTIONS = [2, 3, 4, 5, 6, 7, 8] as const;
|
|||||||
export type BeatsPerBar = (typeof BEATS_PER_BAR_OPTIONS)[number];
|
export type BeatsPerBar = (typeof BEATS_PER_BAR_OPTIONS)[number];
|
||||||
export const TOTAL_STEPS = DEFAULT_BEATS_PER_BAR * STEPS_PER_BEAT;
|
export const TOTAL_STEPS = DEFAULT_BEATS_PER_BAR * STEPS_PER_BEAT;
|
||||||
export const TEMPO_BPM = 112;
|
export const TEMPO_BPM = 112;
|
||||||
export const MIN_TEMPO_BPM = 60;
|
export const MIN_TEMPO_BPM = 30;
|
||||||
export const MAX_TEMPO_BPM = 180;
|
export const MAX_TEMPO_BPM = 260;
|
||||||
|
|
||||||
export function getTotalSteps(beatsPerBar: BeatsPerBar): number {
|
export function getTotalSteps(beatsPerBar: BeatsPerBar): number {
|
||||||
return beatsPerBar * STEPS_PER_BEAT;
|
return beatsPerBar * STEPS_PER_BEAT;
|
||||||
|
|||||||
@@ -249,6 +249,8 @@ describe('sequencer state transitions', () => {
|
|||||||
const tooSlow = sequencerReducer(initial, { type: 'tempo-changed', tempoBpm: 10 });
|
const tooSlow = sequencerReducer(initial, { type: 'tempo-changed', tempoBpm: 10 });
|
||||||
const tooFast = sequencerReducer(initial, { type: 'tempo-changed', tempoBpm: 300 });
|
const tooFast = sequencerReducer(initial, { type: 'tempo-changed', tempoBpm: 300 });
|
||||||
|
|
||||||
|
expect(MIN_TEMPO_BPM).toBe(30);
|
||||||
|
expect(MAX_TEMPO_BPM).toBe(260);
|
||||||
expect(tooSlow.tempoBpm).toBe(MIN_TEMPO_BPM);
|
expect(tooSlow.tempoBpm).toBe(MIN_TEMPO_BPM);
|
||||||
expect(tooFast.tempoBpm).toBe(MAX_TEMPO_BPM);
|
expect(tooFast.tempoBpm).toBe(MAX_TEMPO_BPM);
|
||||||
});
|
});
|
||||||
|
|||||||
+24
-10
@@ -874,6 +874,13 @@ ion-content.app-content-studio {
|
|||||||
|
|
||||||
ion-popover.instrument-picker-popover {
|
ion-popover.instrument-picker-popover {
|
||||||
--width: min(420px, calc(100vw - 24px));
|
--width: min(420px, calc(100vw - 24px));
|
||||||
|
--picker-menu-height: min(60vh, 420px);
|
||||||
|
--picker-menu-height: min(
|
||||||
|
60dvh,
|
||||||
|
420px,
|
||||||
|
max(120px, calc(var(--picker-viewport-height, 100vh) - 160px))
|
||||||
|
);
|
||||||
|
--max-height: var(--picker-menu-height);
|
||||||
--background: var(--surface);
|
--background: var(--surface);
|
||||||
--backdrop-opacity: 0;
|
--backdrop-opacity: 0;
|
||||||
--box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
|
--box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
|
||||||
@@ -882,7 +889,8 @@ ion-popover.instrument-picker-popover {
|
|||||||
.instrument-picker-menu {
|
.instrument-picker-menu {
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-height: min(60vh, 420px);
|
height: var(--picker-menu-height);
|
||||||
|
max-height: var(--picker-menu-height);
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -1121,31 +1129,36 @@ ion-popover.instrument-picker-popover {
|
|||||||
|
|
||||||
.tempo-range-track {
|
.tempo-range-track {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
display: flex;
|
||||||
width: 44px;
|
width: 44px;
|
||||||
height: 164px;
|
height: 164px;
|
||||||
flex: 0 0 164px;
|
flex: 0 0 164px;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tempo-range {
|
.tempo-range {
|
||||||
width: 44px;
|
position: absolute;
|
||||||
height: 164px;
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
width: 164px;
|
||||||
|
height: 44px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border: 0;
|
border: 0;
|
||||||
appearance: none;
|
appearance: none;
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
writing-mode: vertical-lr;
|
transform: translate(-50%, -50%) rotate(-90deg);
|
||||||
direction: rtl;
|
|
||||||
background: transparent;
|
background: transparent;
|
||||||
touch-action: none;
|
touch-action: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tempo-range::-webkit-slider-runnable-track {
|
.tempo-range::-webkit-slider-runnable-track {
|
||||||
width: 3px;
|
width: 100%;
|
||||||
height: 100%;
|
height: 3px;
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
background: linear-gradient(
|
background: linear-gradient(
|
||||||
to top,
|
to right,
|
||||||
var(--accent) 0%,
|
var(--accent) 0%,
|
||||||
var(--accent) var(--tempo-progress),
|
var(--accent) var(--tempo-progress),
|
||||||
#58537d var(--tempo-progress),
|
#58537d var(--tempo-progress),
|
||||||
@@ -1156,7 +1169,7 @@ ion-popover.instrument-picker-popover {
|
|||||||
.tempo-range::-webkit-slider-thumb {
|
.tempo-range::-webkit-slider-thumb {
|
||||||
width: 18px;
|
width: 18px;
|
||||||
height: 18px;
|
height: 18px;
|
||||||
margin-top: 0;
|
margin-top: -7.5px;
|
||||||
border: 0;
|
border: 0;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
@@ -1165,7 +1178,8 @@ ion-popover.instrument-picker-popover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.tempo-range::-moz-range-track {
|
.tempo-range::-moz-range-track {
|
||||||
width: 3px;
|
width: 100%;
|
||||||
|
height: 3px;
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
background: #58537d;
|
background: #58537d;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user