@@ -5,80 +5,49 @@ import { browser } from "./Browser";
55import { Tab } from "./Tab" ;
66import { BookmarksStrip } from "./components/BookmarksStrip" ;
77import { Omnibar } from "./components/Omnibar/Omnibar" ;
8+ import { getTheme } from "./themes" ;
89
910export function App ( props : { } , cx : ComponentContext ) {
1011 const applyTheme = ( ) => {
11- let theme = browser . settings . theme ;
12+ const appearance = browser . settings . appearance ;
13+ const themeId = browser . settings . themeId ;
14+ const theme = getTheme ( themeId ) ;
1215
13- if ( theme === "system" ) {
16+ // Determine if we should use light mode
17+ let isLight = false ;
18+ if ( appearance === "system" ) {
1419 const prefersDark = window . matchMedia (
1520 "(prefers-color-scheme: dark)"
1621 ) . matches ;
17- document . body . classList . toggle ( "light-mode" , ! prefersDark ) ;
22+ isLight = ! prefersDark ;
1823 } else {
19- document . body . classList . toggle ( "light-mode" , theme === "light" ) ;
24+ isLight = appearance === "light" ;
25+ }
26+
27+ document . body . classList . toggle ( "light-mode" , isLight ) ;
28+
29+ // Apply theme tokens
30+ for ( const [ key , value ] of Object . entries ( theme . tokens ) ) {
31+ document . body . style . setProperty ( `--${ key } ` , value ) ;
2032 }
2133 } ;
2234
2335 applyTheme ( ) ;
2436
2537 const mediaQuery = window . matchMedia ( "(prefers-color-scheme: dark)" ) ;
2638 const handleThemeChange = ( ) => {
27- if ( browser . settings . theme === "system" ) {
39+ if ( browser . settings . appearance === "system" ) {
2840 applyTheme ( ) ;
2941 }
3042 } ;
3143
3244 mediaQuery . addEventListener ( "change" , handleThemeChange ) ;
3345
34- use ( browser . settings . theme ) . listen ( applyTheme ) ;
35-
36- const theme = {
37- // dark theme
38- // frame: "rgb(240, 240, 244)",
39- // toolbar: "rgb(249, 249, 251)",
40- // tab_selected: "rgb(255, 255, 255)",
41- // tab_background_text: "black",
42- // toolbar_text: "rgb(21, 20, 26)",
43- // icons: "rgb(91, 91, 102)",
44- // toolbar_field: "rgb(230 230, 230)",
45- // ntp_background: "rgb(249, 249, 251)",
46- // ntp_background_text: "rgb(21, 20, 26)",
47-
48- // light theme
49- // frame: "#1c1b22",
50- // tab_selected: "#42414d",
51- // tab_background_text: "white",
52- // toolbar: "#2b2a33",
53- // toolbar_text: "white",
54- // toolbar_field: "#1C1B22",
55- // toolbar_field_text: "white",
56- // icons: "white",
57- // ntp_background: "#121117",
58- // ntp_text: "white",
59-
60- // catppuccin
61- toolbar : "rgb(45, 41, 59)" ,
62- toolbar_text : "rgb(236, 191, 189)" ,
63- frame : "rgb(30, 30, 40)" ,
64- tab_background_text : "rgb(215, 218, 224)" ,
65- toolbar_field : "rgb(30, 30, 40)" ,
66- toolbar_field_text : "rgb(236, 191, 189)" ,
67- tab_line : "rgb(236, 191, 189)" ,
68- popup : "rgb(30, 30, 40)" ,
69- popup_text : "rgb(236, 191, 189)" ,
70- icons : "rgb(198, 170, 232)" ,
71- ntp_background : "rgb(21, 18, 28)" ,
72- ntp_text : "rgb(164, 185, 239)" ,
73- popup_border : "rgb(236, 191, 189)" ,
74- toolbar_top_separator : "rgb(30, 30, 40)" ,
75- tab_loading : "rgb(236, 191, 189)" ,
76- } ;
46+ use ( browser . settings . appearance ) . listen ( applyTheme ) ;
47+ use ( browser . settings . themeId ) . listen ( applyTheme ) ;
7748
7849 cx . mount = ( ) => {
79- for ( const [ key , value ] of Object . entries ( theme ) ) {
80- document . body . style . setProperty ( `--${ key } ` , value ) ;
81- }
50+ applyTheme ( ) ;
8251 } ;
8352
8453 return (
0 commit comments