From 9d0499d9fff24c09f041d22ab11971c8a8fb8201 Mon Sep 17 00:00:00 2001 From: hfcRed Date: Wed, 4 Mar 2026 18:15:05 +0100 Subject: [PATCH] Make chat color optional --- app/components/CustomThemeSelector.module.css | 4 ++ app/components/CustomThemeSelector.tsx | 51 ++++++++++++++----- app/db/tables.ts | 4 +- app/features/chat/components/Chat.module.css | 2 +- app/utils/zod.ts | 3 +- locales/en/common.json | 1 + 6 files changed, 50 insertions(+), 15 deletions(-) diff --git a/app/components/CustomThemeSelector.module.css b/app/components/CustomThemeSelector.module.css index 3ef95e780..2a0003825 100644 --- a/app/components/CustomThemeSelector.module.css +++ b/app/components/CustomThemeSelector.module.css @@ -80,3 +80,7 @@ oklch(65% 0.15 360) ) !important; } + +.chatColorPreview { + color: oklch(from var(--color-text-accent) l c var(--_chat-h)); +} diff --git a/app/components/CustomThemeSelector.tsx b/app/components/CustomThemeSelector.tsx index b34924d0b..c64effa5c 100644 --- a/app/components/CustomThemeSelector.tsx +++ b/app/components/CustomThemeSelector.tsx @@ -15,6 +15,7 @@ import { THEME_INPUT_LIMITS } from "~/utils/zod"; import styles from "./CustomThemeSelector.module.css"; import { Divider } from "./Divider"; import { LinkButton, SendouButton } from "./elements/Button"; +import { SendouSwitch } from "./elements/Switch"; import { Label } from "./Label"; const COLOR_SLIDERS = [ @@ -54,15 +55,6 @@ const COLOR_SLIDERS = [ labelKey: "accentChroma", isHue: false, }, - { - id: "chat-hue", - inputKey: "chatHue", - min: THEME_INPUT_LIMITS.BASE_HUE_MIN, - max: THEME_INPUT_LIMITS.BASE_HUE_MAX, - step: 1, - labelKey: "chatHue", - isHue: true, - }, ] as const; const RADIUS_SLIDERS = [ @@ -134,14 +126,15 @@ type ThemeInputKey = | (typeof COLOR_SLIDERS)[number]["inputKey"] | (typeof RADIUS_SLIDERS)[number]["inputKey"] | (typeof BORDER_SLIDERS)[number]["inputKey"] - | (typeof SIZE_SLIDERS)[number]["inputKey"]; + | (typeof SIZE_SLIDERS)[number]["inputKey"] + | "chatHue"; export const DEFAULT_THEME_INPUT: ThemeInput = { baseHue: 260, baseChroma: 0.012, accentHue: 270, accentChroma: 0.24, - chatHue: 0, + chatHue: null, radiusBox: 3, radiusField: 2, radiusSelector: 2, @@ -163,7 +156,7 @@ export function themeInputFromCustomTheme( accentChroma: (customTheme["--_acc-c-1"] ?? 0) / ACCENT_CHROMA_MULTIPLIERS[1] || DEFAULT_THEME_INPUT.accentChroma, - chatHue: customTheme["--_chat-h"] ?? DEFAULT_THEME_INPUT.chatHue, + chatHue: customTheme["--_chat-h"], radiusBox: customTheme["--_radius-box"] ?? DEFAULT_THEME_INPUT.radiusBox, radiusField: customTheme["--_radius-field"] ?? DEFAULT_THEME_INPUT.radiusField, @@ -253,6 +246,17 @@ export function CustomThemeSelector({ applyThemeInput(updatedInput); }; + const chatHueEnabled = themeInput.chatHue !== null; + + const handleChatHueToggle = (isSelected: boolean) => { + const updatedInput = { + ...themeInput, + chatHue: isSelected ? 0 : null, + }; + setThemeInput(updatedInput); + applyThemeInput(updatedInput); + }; + const handleSave = () => { onSave(themeInput); }; @@ -303,6 +307,29 @@ export function CustomThemeSelector({ onChange={handleSliderChange} /> ))} +
+ + {t("common:settings.customTheme.chatHueToggle")} + +
+ {chatHueEnabled ? ( +
+ +
+ ) : null} {t("common:settings.customTheme.radius")}
diff --git a/app/db/tables.ts b/app/db/tables.ts index 427290c88..31329d0c2 100644 --- a/app/db/tables.ts +++ b/app/db/tables.ts @@ -70,7 +70,9 @@ export const CUSTOM_THEME_VARS = [ "--_size-spacing", ] as const; export type CustomThemeVar = (typeof CUSTOM_THEME_VARS)[number]; -export type CustomTheme = Record; +export type CustomTheme = Omit, "--_chat-h"> & { + "--_chat-h": number | null; +}; export interface Team { avatarImgId: number | null; diff --git a/app/features/chat/components/Chat.module.css b/app/features/chat/components/Chat.module.css index e475d56ea..b44681604 100644 --- a/app/features/chat/components/Chat.module.css +++ b/app/features/chat/components/Chat.module.css @@ -63,7 +63,7 @@ .messageUser { font-weight: var(--weight-semi); font-size: var(--font-sm); - color: oklch(from var(--color-accent) l c var(--chat-hue)); + color: oklch(from var(--color-text-accent) l c var(--chat-hue)); max-width: 110px; overflow: hidden; text-overflow: ellipsis; diff --git a/app/utils/zod.ts b/app/utils/zod.ts index 32817fded..5497527b3 100644 --- a/app/utils/zod.ts +++ b/app/utils/zod.ts @@ -81,7 +81,8 @@ export const themeInputSchema = z.object({ chatHue: z .number() .min(THEME_INPUT_LIMITS.BASE_HUE_MIN) - .max(THEME_INPUT_LIMITS.BASE_HUE_MAX), + .max(THEME_INPUT_LIMITS.BASE_HUE_MAX) + .nullable(), radiusBox: z .number() .int() diff --git a/locales/en/common.json b/locales/en/common.json index 059cec3eb..b00f53984 100644 --- a/locales/en/common.json +++ b/locales/en/common.json @@ -332,6 +332,7 @@ "settings.customTheme.baseChroma": "Base chroma", "settings.customTheme.accentHue": "Accent hue", "settings.customTheme.accentChroma": "Accent chroma", + "settings.customTheme.chatHueToggle": "Use custom chat name color", "settings.customTheme.chatHue": "Chat name color", "settings.customTheme.boxes": "Boxes", "settings.customTheme.fields": "Fields",