11import { create } from "zustand" ;
22import { persist } from "zustand/middleware" ;
33
4+ type FunctionPropertyNames < T > = {
5+ // eslint-disable-next-line @typescript-eslint/ban-types
6+ [ K in keyof T ] : T [ K ] extends Function ? K : never ;
7+ } [ keyof T ] ;
8+
9+ type Theme = Omit <
10+ SystemSettingState ,
11+ FunctionPropertyNames < SystemSettingState >
12+ > ;
13+
14+ const defaultTheme : Theme = {
15+ mainColor : "#2e3440" ,
16+ accentColor : "#454e60" ,
17+ fontColor : "#ffffff" ,
18+ iconColor : "#9298b9" ,
19+ background : "https://regolith-linux.org/images/releases/nord-dark.png" ,
20+ } ;
21+
422export interface SystemSettingState {
523 mainColor : string ;
624 accentColor : string ;
@@ -12,16 +30,13 @@ export interface SystemSettingState {
1230 setFontColor : ( color : string ) => void ;
1331 setIconColor : ( color : string ) => void ;
1432 setBackground : ( url : string ) => void ;
33+ restoreDefaultTheme : ( ) => void ;
1534}
1635
1736export const useSystemSettings = create < SystemSettingState > ( ) (
1837 persist (
1938 ( set ) => ( {
20- mainColor : "#2e3440" ,
21- accentColor : "#454e60" ,
22- fontColor : "#ffffff" ,
23- iconColor : "#9298b9" ,
24- background : "https://regolith-linux.org/images/releases/nord-dark.png" ,
39+ ...defaultTheme ,
2540 setAccentColor ( accentColor ) {
2641 set ( { accentColor } ) ;
2742 } ,
@@ -37,6 +52,9 @@ export const useSystemSettings = create<SystemSettingState>()(
3752 setBackground ( background ) {
3853 set ( { background } ) ;
3954 } ,
55+ restoreDefaultTheme ( ) {
56+ set ( { ...defaultTheme } ) ;
57+ } ,
4058 } ) ,
4159 {
4260 name : "system-settings" ,
0 commit comments