Skip to content

Commit d6f23a3

Browse files
authored
fix: interface blinks on reload with dark theme (#2480)
1 parent 141c7e0 commit d6f23a3

File tree

1 file changed

+36
-26
lines changed

1 file changed

+36
-26
lines changed

public/index.html

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
3-
<head>
4-
<meta charset="utf-8" />
5-
<link rel="icon" href="%PUBLIC_URL%/static/favicon.png" />
6-
<meta name="viewport" content="width=device-width, initial-scale=1" />
7-
<meta name="theme-color" content="#000000" />
8-
<meta
9-
name="YDB Monitoring"
10-
/>
11-
<meta name="referrer" content="no-referrer-when-downgrade" />
12-
<!--
3+
<head>
4+
<script>
5+
(function () {
6+
const savedTheme = localStorage.getItem('theme') || 'light';
7+
if (
8+
savedTheme.includes('dark') ||
9+
(savedTheme === 'system' &&
10+
window.matchMedia &&
11+
window.matchMedia('(prefers-color-scheme: dark)').matches)
12+
) {
13+
document.documentElement.style.backgroundColor = '#2d2c33';
14+
}
15+
})();
16+
</script>
17+
<meta charset="utf-8" />
18+
<link rel="icon" href="%PUBLIC_URL%/static/favicon.png" />
19+
<meta name="viewport" content="width=device-width, initial-scale=1" />
20+
<meta name="theme-color" content="#000000" />
21+
<meta name="YDB Monitoring" />
22+
<meta name="referrer" content="no-referrer-when-downgrade" />
23+
<!--
1324
Notice the use of %PUBLIC_URL% in the tags above.
1425
It will be replaced with the URL of the `public` folder during the build.
1526
Only files inside the `public` folder can be referenced from the HTML.
@@ -18,19 +29,19 @@
1829
work correctly both with client-side routing and a non-root public URL.
1930
Learn how to configure a non-root public URL by running `npm run build`.
2031
-->
21-
<title>YDB Monitoring</title>
22-
<script>
23-
window.systemSettings = {};
24-
window.web_version = !'%REACT_APP_BACKEND%';
25-
window.custom_backend = '%NODE_ENV%' === 'development' && '%REACT_APP_BACKEND%';
26-
window.meta_backend = '%REACT_APP_META_BACKEND%'
27-
window.react_app_disable_checks = '%REACT_APP_DISABLE_CHECKS%'
28-
</script>
29-
</head>
30-
<body>
31-
<noscript>You need to enable JavaScript to run this app.</noscript>
32-
<div id="root"></div>
33-
<!--
32+
<title>YDB Monitoring</title>
33+
<script>
34+
window.systemSettings = {};
35+
window.web_version = !'%REACT_APP_BACKEND%';
36+
window.custom_backend = '%NODE_ENV%' === 'development' && '%REACT_APP_BACKEND%';
37+
window.meta_backend = '%REACT_APP_META_BACKEND%';
38+
window.react_app_disable_checks = '%REACT_APP_DISABLE_CHECKS%';
39+
</script>
40+
</head>
41+
<body>
42+
<noscript>You need to enable JavaScript to run this app.</noscript>
43+
<div id="root"></div>
44+
<!--
3445
This HTML file is a template.
3546
If you open it directly in the browser, you will see an empty page.
3647
@@ -39,6 +50,5 @@
3950
4051
To begin the development, run `npm start` or `yarn start`.
4152
To create a production bundle, use `npm run build` or `yarn build`.
42-
-->
43-
</body>
53+
--></body>
4454
</html>

0 commit comments

Comments
 (0)