diff --git a/apps/web/src/components/settings/ProviderAccentColorPicker.tsx b/apps/web/src/components/settings/ProviderAccentColorPicker.tsx index 76f6b7bae52cd..6a40f4bd42305 100644 --- a/apps/web/src/components/settings/ProviderAccentColorPicker.tsx +++ b/apps/web/src/components/settings/ProviderAccentColorPicker.tsx @@ -13,11 +13,12 @@ import { cn } from "../../lib/utils"; const FALLBACK_ACCENT_COLOR = "#2563eb"; -function ProviderCustomColorPanel(props: { +export function ProviderCustomColorPanel(props: { readonly value: string; readonly onCommit: (value: string) => void; + readonly label?: string; }) { - const { onCommit } = props; + const { label = "Accent color", onCommit } = props; const [hsv, setHsv] = useState(() => hexToHsv(props.value)); const currentColor = hsvToHex(hsv.h, hsv.s, hsv.v); const [hexDraft, setHexDraft] = useState(null); @@ -32,15 +33,10 @@ function ProviderCustomColorPanel(props: { return (
- +
commitHsv({ ...hsv, h })} /> @@ -57,7 +53,7 @@ function ProviderCustomColorPanel(props: { }} onBlur={() => setHexDraft(null)} font="mono" - aria-label="Custom hex accent color" + aria-label={`Custom hex ${label.toLowerCase()}`} spellCheck={false} />
diff --git a/apps/web/src/components/settings/ProviderProfilesSettings.tsx b/apps/web/src/components/settings/ProviderProfilesSettings.tsx index 97e7580cbd846..ad07ee0db3ea0 100644 --- a/apps/web/src/components/settings/ProviderProfilesSettings.tsx +++ b/apps/web/src/components/settings/ProviderProfilesSettings.tsx @@ -8,7 +8,7 @@ import { type UnifiedSettings, } from "@t3tools/contracts"; import { createModelSelection } from "@t3tools/shared/model"; -import { PencilIcon, PlusIcon } from "lucide-react"; +import { PencilIcon, PipetteIcon, PlusIcon } from "lucide-react"; import { useMemo, useState } from "react"; import { useUpdateEnvironmentSettings } from "../../hooks/useSettings"; @@ -44,6 +44,8 @@ import { providerProfileIdFromName, resolveProjectProviderProfileId, } from "./ProviderProfilesSettings.logic"; +import { Popover, PopoverPopup, PopoverTrigger } from "../ui/popover"; +import { ProviderCustomColorPanel } from "./ProviderAccentColorPicker"; import { searchableSetting } from "./settingsSearch"; import { SETTINGS_PICKER_TRIGGER_CLASSNAME, SettingsRow, SettingsSection } from "./settingsLayout"; @@ -233,6 +235,48 @@ export function ProviderProfilesSettings({ ); } +/** The last swatch in the profile color row: shows a custom color once picked, and edits it. */ +function ProviderProfileCustomColor({ + value, + onChange, +}: { + value: string | undefined; + onChange: (color: string) => void; +}) { + const custom = + value && !(PROVIDER_PROFILE_COLORS as readonly string[]).includes(value) ? value : undefined; + return ( + + + {custom ? null : } + + } + /> + + + + + ); +} + function ProviderProfileEditorDialog({ initial, entries, @@ -337,6 +381,10 @@ function ProviderProfileEditorDialog({ style={{ background: color }} /> ))} + setDraft({ ...draft, color })} + />