-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathVisualizerColorButton.tsx
More file actions
56 lines (53 loc) Β· 1.79 KB
/
Copy pathVisualizerColorButton.tsx
File metadata and controls
56 lines (53 loc) Β· 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { useTranslation } from "react-i18next";
import type { VisualizerColorId } from "../../hooks/useVisualizerColor";
/** A representative rainbow swatch for the button when `rainbow` is active. */
const RAINBOW_SWATCH =
"conic-gradient(from 0deg, #ef4444, #f97316, #eab308, #22c55e, #22d3ee, #6366f1, #d946ef, #ef4444)";
interface VisualizerColorButtonProps {
/** Current selection β drives the localized label. */
colorId: VisualizerColorId;
/** Solid CSS fill for the swatch, or `undefined` when `rainbow`. */
color: string | undefined;
/** Whether the current selection is the per-bar rainbow. */
rainbow: boolean;
/** Advance to the next colour (loops). */
onCycle: () => void;
size?: number;
}
/**
* Immersive-view control that cycles the spectrum-visualizer colour
* (issue #468). The swatch shows the current colour (a conic gradient for
* rainbow); clicking advances to the next and loops back to the default β
* same "advance-through-a-fixed-list" shape as the repeat-mode button, so the
* user can find a tint that reads well over the album-derived backdrop.
*/
export function VisualizerColorButton({
colorId,
color,
rainbow,
onCycle,
size = 20,
}: VisualizerColorButtonProps) {
const { t } = useTranslation();
const label = t("settings.visualizer.cycleColor", {
color: t(`settings.visualizer.colors.${colorId}`),
});
return (
<button
type="button"
onClick={onCycle}
aria-label={label}
title={label}
className="p-2 rounded-full text-white/60 transition-colors hover:text-white"
>
<span
className="block rounded-full border border-white/40 shadow-sm"
style={{
width: size,
height: size,
background: rainbow ? RAINBOW_SWATCH : color,
}}
/>
</button>
);
}