refactor: derive accent color presets from avatar gradient palette

Replace the hardcoded 16-color ACCENT_PRESETS array in AccountPanel with
a shared export from gradients.ts that extracts both hex stops from each
avatar gradient, producing 14 harmonized colors in a 7×2 grid.
This commit is contained in:
Jannis Braun
2026-03-10 20:32:16 +01:00
parent d2697d87fa
commit d3f58f3787
2 changed files with 8 additions and 8 deletions
+6
View File
@@ -72,6 +72,12 @@ export function getSpaceGradient(id?: string | null, name?: string): GradientEnt
return SPACE_GRADIENTS[hashString(key) % SPACE_GRADIENTS.length]!;
}
/** Flat accent-color presets derived from the avatar gradient palette. Both stops per gradient. */
export const ACCENT_PRESETS: string[] = AVATAR_GRADIENTS.flatMap(g => {
const matches = g.gradient.match(/#[0-9a-fA-F]{6}/g);
return matches ?? [];
});
/** Shift each RGB component of a hex color by `amount` (positive = lighter, negative = darker). */
export function adjustColor(hex: string, amount: number): string {
const r = Math.max(0, Math.min(255, parseInt(hex.slice(1, 3), 16) + amount));