File tree Expand file tree Collapse file tree
src/web/FloraWeb/Components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,31 +14,35 @@ import FloraWeb.Pages.Templates.Types
1414
1515navbar :: FloraHTML
1616navbar = do
17+ let xData =
18+ [str |
19+ {
20+ updateTheme() {
21+ const customTheme = document.documentElement.getAttribute('data-theme');
22+ const isSystemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
23+ const applyTheme = (theme) => {
24+ document.documentElement.setAttribute('data-theme', theme);
25+ (async () => { await cookieStore.set('theme', theme) })();
26+ };
27+ switch (customTheme) {
28+ case 'light':
29+ applyTheme('dark');
30+ break;
31+ case 'dark':
32+ applyTheme('light');
33+ break;
34+ default:
35+ isSystemDark ? applyTheme('light') : applyTheme('dark');
36+ break;
37+ }
38+ }
39+ }
40+ |]
41+
1742 ActiveElements {aboutNav, packagesNav} <- asks activeElements
1843 nav_
1944 [ class_ " top-navbar"
20- , xData_
21- " { updateTheme() { \
22- \ const customTheme = document.documentElement.getAttribute('data-theme'); \
23- \ const isSystemDark = window.matchMedia('(prefers-color-scheme: dark)').matches; \
24- \ const applyTheme = (theme) => { \
25- \ document.documentElement.setAttribute('data-theme', theme); \
26- \ console.log(\" theme switch\" ); \
27- \ (async () => { await cookieStore.set('theme', theme) })(); \
28- \ }; \
29- \ switch (customTheme) { \
30- \ case 'light': \
31- \ applyTheme('dark'); \
32- \ break; \
33- \ case 'dark': \
34- \ applyTheme('light'); \
35- \ break; \
36- \ default: \
37- \ isSystemDark ? applyTheme('light') : applyTheme('dark'); \
38- \ break; \
39- \ } \
40- \ } \
41- \}"
45+ , xData_ xData
4246 ]
4347 $ do
4448 div_ [class_ " navbar-content" ] $ do
You can’t perform that action at this time.
0 commit comments