@@ -4,30 +4,33 @@ import { Menu } from "@/components/menu";
44import { Button } from "@/components/button" ;
55import { cn } from "@/lib/utils" ;
66import {
7- useColorMode ,
8- type ResolvedColorMode ,
9- type ColorMode ,
10- COLOR_MODE_OPTIONS ,
7+ useTheme ,
8+ type ResolvedColorTheme ,
9+ type ColorTheme ,
10+ COLOR_THEME_OPTIONS ,
1111} from "@/contexts/theme-context" ;
1212
13- const RESOLVED_MODE_SHORT : Record < ResolvedColorMode , string > = {
13+ const RESOLVED_COLOR_THEME_SHORT : Record < ResolvedColorTheme , string > = {
1414 light : "Light" ,
1515 dark : "Dark" ,
1616} ;
1717
1818/**
19- * Decorative dual swatches for the mode picker. Light/dark show their surface
19+ * Decorative dual swatches for the color theme picker. Light/dark show their surface
2020 * tones; system splits the two to signal "follows the OS".
2121 * Kept as static hex previews so they render before any stylesheet loads.
2222 */
23- const MODE_PREVIEW : Record < ColorMode , { readonly a : `#${string } `; readonly b : `#${string } ` } > = {
23+ const COLOR_THEME_PREVIEW : Record <
24+ ColorTheme ,
25+ { readonly a : `#${string } `; readonly b : `#${string } ` }
26+ > = {
2427 light : { a : "#ffffff" , b : "#d4d4d8" } ,
2528 dark : { a : "#3f3f46" , b : "#71717a" } ,
2629 system : { a : "#ffffff" , b : "#3f3f46" } ,
2730} ;
2831
29- function isMode ( value : string ) : value is ColorMode {
30- return COLOR_MODE_OPTIONS . some ( ( o ) => o . value === value ) ;
32+ function isColorTheme ( value : string ) : value is ColorTheme {
33+ return COLOR_THEME_OPTIONS . some ( ( o ) => o . value === value ) ;
3134}
3235
3336/** Shared radio-item chrome — used by both the mode and font grids. */
@@ -42,8 +45,8 @@ function radioItemClasses(active: boolean) {
4245 ) ;
4346}
4447
45- function ModePreviewSwatches ( { modeId } : { modeId : ColorMode } ) {
46- const { a, b } = MODE_PREVIEW [ modeId ] ;
48+ function ColorThemePreviewSwatches ( { colorTheme } : { colorTheme : ColorTheme } ) {
49+ const { a, b } = COLOR_THEME_PREVIEW [ colorTheme ] ;
4750 return (
4851 < div
4952 className = "astw:flex astw:h-10 astw:w-full astw:max-w-[5.5rem] astw:items-center astw:justify-center astw:gap-1.5 astw:rounded-md astw:border astw:border-border/80 astw:bg-card astw:px-2"
@@ -62,15 +65,15 @@ function ModePreviewSwatches({ modeId }: { modeId: ColorMode }) {
6265}
6366
6467/**
65- * Appearance menu. The end-user controls **mode ** (light / dark / system);
68+ * Appearance menu. The end-user controls **color theme ** (light / dark / system);
6669 * the color palette/brand is a developer configuration, so it is not shown here.
6770 */
6871function AppearanceSwitcher ( ) {
69- const { mode , resolvedMode , setMode } = useColorMode ( ) ;
72+ const { theme , resolvedTheme , setTheme } = useTheme ( ) ;
7073
7174 const triggerTitle =
72- mode === "system"
73- ? `Following system — currently ${ RESOLVED_MODE_SHORT [ resolvedMode ] } `
75+ theme === "system"
76+ ? `Following system — currently ${ RESOLVED_COLOR_THEME_SHORT [ resolvedTheme ] } `
7477 : "Choose appearance" ;
7578
7679 return (
@@ -97,21 +100,21 @@ function AppearanceSwitcher() {
97100 < Menu . GroupLabel className = "astw:px-0 astw:pb-2 astw:pt-0" > Appearance</ Menu . GroupLabel >
98101 < Menu . RadioGroup
99102 className = "astw:grid astw:grid-cols-3 astw:gap-2"
100- value = { mode }
103+ value = { theme }
101104 onValueChange = { ( value ) => {
102- if ( typeof value === "string" && isMode ( value ) ) setMode ( value ) ;
105+ if ( typeof value === "string" && isColorTheme ( value ) ) setTheme ( value ) ;
103106 } }
104107 >
105- { COLOR_MODE_OPTIONS . map ( ( opt ) => (
108+ { COLOR_THEME_OPTIONS . map ( ( opt ) => (
106109 < Menu . RadioItem
107110 key = { opt . value }
108111 value = { opt . value }
109- className = { radioItemClasses ( mode === opt . value ) }
112+ className = { radioItemClasses ( theme === opt . value ) }
110113 >
111114 < Menu . RadioItemIndicator className = "astw:sr-only" >
112115 { opt . label }
113116 </ Menu . RadioItemIndicator >
114- < ModePreviewSwatches modeId = { opt . value } />
117+ < ColorThemePreviewSwatches colorTheme = { opt . value } />
115118 < span className = "astw:block astw:w-full astw:truncate astw:px-0.5" >
116119 { opt . label }
117120 </ span >
0 commit comments