Skip to content

Commit 666f9f8

Browse files
committed
Fixes dark mode issues
1 parent 738a4e5 commit 666f9f8

File tree

3 files changed

+5
-29
lines changed

3 files changed

+5
-29
lines changed

public/index.html

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,7 @@
3838

3939
gtag('config', 'UA-125599395-1');
4040
</script>
41-
<script>
42-
function loadTheme() {
43-
try {
44-
const theme = localStorage.getItem('theme')
45-
if (!theme)
46-
return
47-
document.body.dataset.theme = theme
48-
} catch (e) {
4941

50-
}
51-
}
52-
loadTheme()
53-
</script>
5442

5543
<title>React App</title>
5644
</head>

src/containers/write/MarkdownEditorContainer.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,13 @@ const MarkdownEditorContainer: React.FC<MarkdownEditorContainerProps> = () => {
256256

257257
useSaveHotKey(() => onTempSave(true));
258258

259+
const isReady = useSelector(
260+
(state: RootState) => state.darkMode.systemTheme !== 'not-ready',
261+
);
259262
const theme = useTheme();
260263

264+
if (!isReady) return null;
265+
261266
return (
262267
<>
263268
<Helmet>

src/server/Html.tsx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,6 @@ function Html({
8585
gtag('config', 'UA-125599395-1');`,
8686
}}
8787
></script>
88-
<script
89-
dangerouslySetInnerHTML={{
90-
__html: `
91-
function loadTheme() {
92-
try {
93-
const theme = localStorage.getItem('theme')
94-
if (!theme)
95-
return
96-
document.body.dataset.theme = theme
97-
} catch (e) {
98-
99-
}
100-
}
101-
loadTheme()
102-
`,
103-
}}
104-
></script>
10588
</head>
10689
<body data-theme={theme}>
10790
<div id="root" dangerouslySetInnerHTML={{ __html: content }}></div>

0 commit comments

Comments
 (0)