mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Added support for coloring Rekordbox hotcues
This commit is contained in:
1 parent
9be2c029b2
commit
08c53e1150
19 files changed
+337
-45
No files matched your search
@@ -10,6 +10,14 @@ export type MenuItem =
|
||||
// Toggles in place and leaves the menu open, so several can be flipped in one go.
|
||||
| { label: string; checked: boolean; onToggle: () => void }
|
||||
| { heading: string; empty?: string }
|
||||
// A grid of colour swatches plus an uncoloured choice (`selected` null).
|
||||
// Picking one closes the menu, like a plain item.
|
||||
| {
|
||||
swatches: string[]
|
||||
selected: string | null
|
||||
onPick: (color: string | null) => void
|
||||
disabled?: boolean
|
||||
}
|
||||
| { separator: true }
|
||||
|
||||
interface Props {
|
||||
@@ -143,6 +151,16 @@ function MenuPanel({
|
||||
</button>
|
||||
)
|
||||
}
|
||||
if ('swatches' in item) {
|
||||
return (
|
||||
<SwatchGrid
|
||||
key={i}
|
||||
item={item}
|
||||
onEnter={() => setOpen(null)}
|
||||
onPicked={onClose}
|
||||
/>
|
||||
)
|
||||
}
|
||||
if ('heading' in item) {
|
||||
return (
|
||||
<div key={i}>
|
||||
@@ -201,3 +219,59 @@ function MenuPanel({
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
function SwatchGrid({
|
||||
item,
|
||||
onEnter,
|
||||
onPicked,
|
||||
}: {
|
||||
item: Extract<MenuItem, { swatches: string[] }>
|
||||
onEnter: () => void
|
||||
onPicked: () => void
|
||||
}) {
|
||||
const selected = item.selected?.toUpperCase() ?? null
|
||||
const pick = (color: string | null) => {
|
||||
item.onPick(color)
|
||||
onPicked()
|
||||
}
|
||||
// An outline, not a ring: a ring is a box-shadow, which the swatch's glow overrides.
|
||||
const ring = (on: boolean) =>
|
||||
on ? 'outline outline-2 outline-offset-2 outline-white' : 'enabled:hover:scale-110'
|
||||
return (
|
||||
<div className="px-3 pb-2 pt-1" onMouseEnter={onEnter}>
|
||||
<div className="grid w-max grid-cols-8 gap-1.5">
|
||||
{item.swatches.map((color) => (
|
||||
<button
|
||||
key={color}
|
||||
role="menuitemradio"
|
||||
aria-checked={selected === color.toUpperCase()}
|
||||
aria-label={color}
|
||||
title={color}
|
||||
disabled={item.disabled}
|
||||
onClick={() => pick(color)}
|
||||
className={`h-4 w-4 rounded-full transition-transform disabled:cursor-default disabled:opacity-40 ${ring(
|
||||
selected === color.toUpperCase(),
|
||||
)}`}
|
||||
style={{ background: color, boxShadow: `0 0 6px ${color}` }}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<button
|
||||
role="menuitemradio"
|
||||
aria-checked={selected === null}
|
||||
disabled={item.disabled}
|
||||
onClick={() => pick(null)}
|
||||
className={`mt-2 flex items-center gap-2 rounded-[8px] text-xs disabled:cursor-default disabled:text-faint ${
|
||||
selected === null ? 'text-text' : 'text-muted hover:text-text'
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className={`block h-3 w-3 rounded-full border border-ink-600 ${
|
||||
selected === null ? 'outline outline-2 outline-offset-1 outline-white' : ''
|
||||
}`}
|
||||
/>
|
||||
Default
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user