Skip to content

Commit d30f10a

Browse files
committed
Update Theme Milestone
1 parent ef4f72f commit d30f10a

File tree

5 files changed

+30
-9
lines changed

5 files changed

+30
-9
lines changed

web/src/gui/navigation/ThemeSwitcher.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@ import { FiMonitor, FiMoon, FiSun } from 'react-icons/fi';
33

44
import { cn } from '@/util/style';
55

6+
export const updateTheme = () => {
7+
const theme = localStorage.getItem('theme') || 'system';
8+
9+
document.documentElement.classList.remove('light', 'dark');
10+
document.documentElement.classList.add(theme);
11+
};
12+
613
export const ThemeSwitcher = () => {
714
const theme = localStorage.getItem('theme') || 'system';
815
const [currentTheme, setCurrentTheme] = useState(theme);
916
const setTheme = (theme: string) => {
1017
localStorage.setItem('theme', theme);
1118
setCurrentTheme(theme);
12-
document.documentElement.classList.remove('light', 'dark');
13-
document.documentElement.classList.add(theme);
19+
20+
updateTheme();
1421
};
1522

1623
return (

web/src/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { preflightAuth } from '@/api';
1010
// Import the generated route tree
1111
import { routeTree } from '@/routeTree.gen';
1212

13+
import { updateTheme } from './gui/navigation/ThemeSwitcher';
1314
import { PageErrorBoundary } from './gui/PageErrorBoundary';
1415
import { defaultPendingComponent } from './gui/Router';
1516
import { QueryProvider } from './util/query';
@@ -27,11 +28,12 @@ const router = createRouter({
2728
// Register the router instance for type safety
2829
declare module '@tanstack/react-router' {
2930
// eslint-disable-next-line prettier/prettier, unused-imports/no-unused-vars
30-
interface Register {
31+
interface Register {
3132
router: typeof router;
3233
}
3334
}
3435

36+
updateTheme();
3537
preflightAuth();
3638

3739
ReactDOM.createRoot(document.querySelector('#root')!).render(

web/src/styles/colors.scss

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
}
1313

1414
html.dark {
15-
--background: #0b0b0b;
16-
--background2: #0d0d0d;
1715
--border: #313131;
18-
--text: #fff;
1916
--link: #60a5fa;
2017
--muted: #1f1f1f;
2118

@@ -26,3 +23,18 @@ html.dark {
2623
--text-primary: #fff;
2724
--text-secondary: #fff;
2825
}
26+
27+
@media (prefers-color-scheme: dark) {
28+
html:not(.light) {
29+
--border: #313131;
30+
--link: #60a5fa;
31+
--muted: #1f1f1f;
32+
33+
--bg-primary: #0d0d0d;
34+
--bg-secondary: #0b0b0b;
35+
--bg-hover: #ffffff1a;
36+
--bg-muted: #1f1f1f;
37+
--text-primary: #fff;
38+
--text-secondary: #fff;
39+
}
40+
}

web/src/styles/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ body {
2626
overflow: hidden;
2727
font-family: "Inter", monospace, sans-serif;
2828
background-color: var(--bg-secondary);
29-
color: var(--text);
29+
color: var(--text-primary);
3030
}
3131

3232
body.dark {

web/tailwind.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ module.exports = {
1212
hover: 'var(--bg-hover)',
1313
},
1414
borderColor: {
15-
default: 'var(--border)',
15+
DEFAULT: 'var(--border)',
1616
},
1717
outlineColor: {
18-
default: 'var(--border)',
18+
DEFAULT: 'var(--border)',
1919
},
2020
textColor: {
2121
link: 'var(--link)',

0 commit comments

Comments
 (0)