99 Keyboard ,
1010 LayoutTemplate ,
1111 LockKeyhole ,
12+ Monitor ,
1213 MonitorCog ,
1314 Moon ,
1415 Search ,
@@ -33,6 +34,7 @@ import {
3334 useTheme ,
3435} from "@/shared/theme/ThemeProvider" ;
3536import { SYNTAX_THEMES , isLightTheme } from "@/shared/theme/theme-loader" ;
37+ import { Switch } from "@/shared/ui/switch" ;
3638import { ChannelTemplatesSettingsCard } from "./ChannelTemplatesSettingsCard" ;
3739import { DoctorSettingsPanel } from "./DoctorSettingsPanel" ;
3840import { ExperimentalFeaturesCard } from "./ExperimentalFeaturesCard" ;
@@ -188,8 +190,16 @@ function formatThemeLabel(name: string): string {
188190}
189191
190192function ThemeSettingsCard ( ) {
191- const { setTheme, themeName, isDark, accentColor, setAccentColor } =
192- useTheme ( ) ;
193+ const {
194+ setTheme,
195+ themeName,
196+ selectedThemeName,
197+ isDark,
198+ accentColor,
199+ setAccentColor,
200+ followSystem,
201+ setFollowSystem,
202+ } = useTheme ( ) ;
193203 const [ search , setSearch ] = useState ( "" ) ;
194204 const didScrollRef = useRef ( false ) ;
195205 const activeRef = ( node : HTMLButtonElement | null ) => {
@@ -199,20 +209,25 @@ function ThemeSettingsCard() {
199209 }
200210 } ;
201211
212+ const selectedTheme = selectedThemeName ;
213+
202214 const filtered = useMemo ( ( ) => {
203215 const q = search . toLowerCase ( ) . trim ( ) ;
204216 if ( ! q ) return SYNTAX_THEMES ;
205217 return SYNTAX_THEMES . filter ( ( name ) => name . includes ( q ) ) ;
206218 } , [ search ] ) ;
207219
208220 return (
209- < section className = "min-w-0" data-testid = "settings-theme" >
221+ < section
222+ className = "flex min-h-0 flex-1 flex-col"
223+ data-testid = "settings-theme"
224+ >
210225 < SettingsSectionHeader
211226 title = "Appearance"
212- description = "Choose a theme for Buzz. Light and dark mode is auto-detected. "
227+ description = "Choose a theme for Buzz."
213228 />
214229
215- < div className = "relative mb-3" >
230+ < div className = "relative mb-3 shrink-0 " >
216231 < Search className = "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
217232 < input
218233 autoCapitalize = "none"
@@ -226,14 +241,15 @@ function ThemeSettingsCard() {
226241 />
227242 </ div >
228243
229- < div className = "max -h-72 overflow-y-auto rounded-lg border border-border/70 bg-background/70" >
244+ < div className = "min -h-0 flex-1 overflow-y-auto rounded-lg border border-border/70 bg-background/70" >
230245 { filtered . length === 0 ? (
231246 < p className = "px-3 py-4 text-center text-sm text-muted-foreground" >
232247 No themes match your search.
233248 </ p >
234249 ) : (
235250 filtered . map ( ( name ) => {
236- const isActive = themeName === name ;
251+ const isActive = selectedTheme === name ;
252+ const isEffective = themeName === name ;
237253 const light = isLightTheme ( name ) ;
238254
239255 return (
@@ -243,7 +259,9 @@ function ThemeSettingsCard() {
243259 "flex w-full items-center gap-3 px-3 py-2 text-left text-sm transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring" ,
244260 isActive
245261 ? "bg-primary/10 text-foreground"
246- : "text-muted-foreground hover:bg-accent hover:text-accent-foreground" ,
262+ : isEffective && followSystem
263+ ? "bg-primary/5 text-foreground"
264+ : "text-muted-foreground hover:bg-accent hover:text-accent-foreground" ,
247265 ) }
248266 data-testid = { `theme-option-${ name } ` }
249267 key = { name }
@@ -262,44 +280,62 @@ function ThemeSettingsCard() {
262280 { isActive && (
263281 < Check className = "h-4 w-4 shrink-0 text-primary" />
264282 ) }
283+ { ! isActive && isEffective && followSystem && (
284+ < Monitor className = "h-3.5 w-3.5 shrink-0 text-muted-foreground" />
285+ ) }
265286 </ button >
266287 ) ;
267288 } )
268289 ) }
269290 </ div >
270291
271- < div className = "mt-4" >
272- < h3 className = "mb-2 text-sm font-medium" > Accent Color</ h3 >
273- < div className = "flex gap-2" >
274- { ACCENT_COLORS . map ( ( color ) => {
275- const isNeutral = color . value === NEUTRAL_ACCENT ;
276- const swatchColor = isNeutral
277- ? "hsl(var(--foreground))"
278- : color . value ;
279- const checkClassName =
280- isNeutral && isDark ? "text-black" : "text-white" ;
292+ < div className = "mt-4 flex shrink-0 flex-col gap-3 pb-2 sm:flex-row sm:items-start sm:justify-between" >
293+ < div className = "min-w-0" >
294+ < h3 className = "mb-2 text-sm font-medium" > Accent color</ h3 >
295+ < div className = "flex flex-wrap gap-2" >
296+ { ACCENT_COLORS . map ( ( color ) => {
297+ const isNeutral = color . value === NEUTRAL_ACCENT ;
298+ const swatchColor = isNeutral
299+ ? "hsl(var(--foreground))"
300+ : color . value ;
301+ const checkClassName =
302+ isNeutral && isDark ? "text-black" : "text-white" ;
281303
282- return (
283- < button
284- className = { cn (
285- "flex h-7 w-7 items-center justify-center rounded-full border border-border/50 transition-transform hover:scale-110" ,
286- accentColor === color . value &&
287- "ring-2 ring-ring ring-offset-2 ring-offset-background" ,
288- ) }
289- data-testid = { `accent-color-${ color . name . toLowerCase ( ) } ` }
290- key = { color . value }
291- onClick = { ( ) => setAccentColor ( color . value ) }
292- style = { { backgroundColor : swatchColor } }
293- title = { color . name }
294- type = "button"
295- >
296- { accentColor === color . value && (
297- < Check className = { cn ( "h-4 w-4" , checkClassName ) } />
298- ) }
299- </ button >
300- ) ;
301- } ) }
304+ return (
305+ < button
306+ className = { cn (
307+ "flex h-7 w-7 items-center justify-center rounded-full border border-border/50 transition-transform hover:scale-110" ,
308+ accentColor === color . value &&
309+ "ring-2 ring-ring ring-offset-2 ring-offset-background" ,
310+ ) }
311+ data-testid = { `accent-color-${ color . name . toLowerCase ( ) } ` }
312+ key = { color . value }
313+ onClick = { ( ) => setAccentColor ( color . value ) }
314+ style = { { backgroundColor : swatchColor } }
315+ title = { color . name }
316+ type = "button"
317+ >
318+ { accentColor === color . value && (
319+ < Check className = { cn ( "h-4 w-4" , checkClassName ) } />
320+ ) }
321+ </ button >
322+ ) ;
323+ } ) }
324+ </ div >
302325 </ div >
326+
327+ < label
328+ className = "flex cursor-pointer items-center gap-3 text-sm font-medium text-foreground"
329+ htmlFor = "follow-system-switch"
330+ >
331+ < span className = "min-w-0 truncate" > Use system setting</ span >
332+ < Switch
333+ checked = { followSystem }
334+ data-testid = "follow-system-toggle"
335+ id = "follow-system-switch"
336+ onCheckedChange = { setFollowSystem }
337+ />
338+ </ label >
303339 </ div >
304340 </ section >
305341 ) ;
0 commit comments