diff --git a/src/web/screens/detail/ThemePicker.tsx b/src/web/screens/detail/ThemePicker.tsx
index 7883258..4683b19 100644
--- a/src/web/screens/detail/ThemePicker.tsx
+++ b/src/web/screens/detail/ThemePicker.tsx
@@ -5,7 +5,7 @@ import type { Theme } from "../../../shared/validation.js";
import { api, errorMessage, useApi } from "../../api.js";
import { Button } from "../../components/ui/button.js";
import { useConfirm } from "../../components/ui/dialog.js";
-import { ColorInput, Input, Segmented } from "../../components/ui/form.js";
+import { ColorInput, Input } from "../../components/ui/form.js";
import { useToast } from "../../components/ui/toast.js";
import { cx } from "../../lib/cx.js";
import { parseCoolorsInput, themeFromPalette, TRENDING_PALETTES, type Variant } from "../../lib/palette.js";
@@ -59,7 +59,29 @@ function PresetCard({ name, theme, selected, onClick }: { name: string; theme: T
);
}
-// A palette: each color opens the role menu, the name row applies the whole palette.
+// Miniature of a link page (background, a text line and a button) that applies one version of a palette.
+function VariantThumb({ theme, label, selected, onClick }: { theme: Theme; label: string; selected: boolean; onClick: () => void }) {
+ return (
+
+ );
+}
+
+// A palette: each color opens the role menu, the two thumbnails apply a dark or light version of it.
function PaletteCard({
colors,
label,
@@ -70,14 +92,14 @@ function PaletteCard({
}: {
colors: string[];
label: string;
- selected: boolean;
- onApply: () => void;
+ selected: Variant | null;
+ onApply: (variant: Variant) => void;
onPickColor: (color: string, anchor: HTMLElement) => void;
onRemove?: () => void;
}) {
return (
-
-
+
+
{colors.map((c, i) => (
))}
-
-
+
+ {label}
+ {(["dark", "light"] as const).map((v) => (
+ onApply(v)}
+ />
+ ))}
{onRemove && (
@@ -222,9 +245,8 @@ export function ThemePicker({ theme, onChange }: { theme: Theme; onChange: (them
const saved = useApi("/palettes");
const toast = useToast();
const confirm = useConfirm();
- const [variant, setVariant] = useState("dark");
- // The palette the current theme was generated from, so switching dark/light can re-map it.
- const [source, setSource] = useState(null);
+ // The palette version the current theme was generated from, to mark it as selected.
+ const [source, setSource] = useState<{ colors: string[]; variant: Variant } | null>(null);
const [link, setLink] = useState("");
const [linkError, setLinkError] = useState();
const [importing, setImporting] = useState(false);
@@ -232,21 +254,20 @@ export function ThemePicker({ theme, onChange }: { theme: Theme; onChange: (them
const toggleMenu = (color: string, anchor: HTMLElement) => setMenu((m) => (m?.anchor === anchor ? null : { color, anchor }));
- const applyPalette = (colors: string[], v = variant) => {
- setSource(colors);
- onChange(themeFromPalette(colors, v));
- };
- const changeVariant = (v: Variant) => {
- setVariant(v);
- if (source) onChange(themeFromPalette(source, v));
+ const applyPalette = (colors: string[], variant: Variant) => {
+ setSource({ colors, variant });
+ onChange(themeFromPalette(colors, variant));
};
const setColor = (role: keyof Theme, color: string) => {
setSource(null);
onChange({ ...theme, [role]: color });
};
- const isSelected = (colors: string[]) =>
- !!source && paletteKey(source) === paletteKey(colors) && sameTheme(themeFromPalette(colors, variant), theme);
+ // Which version of this palette is in use, if any (editing a single color deselects it).
+ const selectedVariant = (colors: string[]): Variant | null =>
+ source && paletteKey(source.colors) === paletteKey(colors) && sameTheme(themeFromPalette(colors, source.variant), theme)
+ ? source.variant
+ : null;
const importLink = async () => {
const colors = parseCoolorsInput(link);
@@ -258,7 +279,7 @@ export function ThemePicker({ theme, onChange }: { theme: Theme; onChange: (them
try {
await api("POST", "/palettes", { colors });
await saved.reload();
- applyPalette(colors);
+ applyPalette(colors, "dark");
setLink("");
setLinkError(undefined);
} catch (err) {
@@ -280,7 +301,7 @@ export function ThemePicker({ theme, onChange }: { theme: Theme; onChange: (them
}
};
- const pickHint = "Click a name to use the whole palette, or a single color to assign it.";
+ const pickHint = "Pick the dark or light version of a palette, or click a single color to use it for one part.";
return (