Skip to content

Commit c102fff

Browse files
authored
fix tutorial dark mode (#158)
* fix tutorial dark mode * missed a spot
1 parent df8e454 commit c102fff

File tree

2 files changed

+34
-28
lines changed
  • apps/svelte.dev
    • content/tutorial/+assets/src
    • scripts/create-tutorial-zip/common/src

2 files changed

+34
-28
lines changed

apps/svelte.dev/content/tutorial/+assets/src/app.html

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
%sveltekit.head%
99

1010
<style>
11-
body {
11+
html {
1212
--bg-1: hsl(0, 0%, 100%);
1313
--bg-2: hsl(206, 20%, 90%);
1414
--bg-3: hsl(206, 20%, 80%);
@@ -18,6 +18,21 @@
1818
--link: hsl(208, 77%, 47%);
1919
--link-hover: hsl(208, 77%, 55%);
2020
--link-active: hsl(208, 77%, 40%);
21+
22+
&.dark {
23+
--bg-1: hsl(0, 0%, 18%);
24+
--bg-2: hsl(0, 0%, 30%);
25+
--bg-3: hsl(0, 0%, 40%);
26+
--fg-1: hsl(0, 0%, 90%);
27+
--fg-2: hsl(0, 0%, 70%);
28+
--fg-3: hsl(0, 0%, 60%);
29+
--link: hsl(206, 96%, 72%);
30+
--link-hover: hsl(206, 96%, 78%);
31+
--link-active: hsl(206, 96%, 64%);
32+
}
33+
}
34+
35+
body {
2136
--border-radius: 4px;
2237
--font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
2338
'Open Sans', 'Helvetica Neue', sans-serif;
@@ -243,18 +258,6 @@
243258
ul.todos button:hover {
244259
opacity: 1;
245260
}
246-
247-
html.dark {
248-
--bg-1: hsl(0, 0%, 18%);
249-
--bg-2: hsl(0, 0%, 30%);
250-
--bg-3: hsl(0, 0%, 40%);
251-
--fg-1: hsl(0, 0%, 90%);
252-
--fg-2: hsl(0, 0%, 70%);
253-
--fg-3: hsl(0, 0%, 60%);
254-
--link: hsl(206, 96%, 72%);
255-
--link-hover: hsl(206, 96%, 78%);
256-
--link-active: hsl(206, 96%, 64%);
257-
}
258261
</style>
259262
</head>
260263
<body>
@@ -263,8 +266,8 @@
263266
<script>
264267
const theme = new URL(window.location).searchParams.get('theme');
265268

266-
document.body.classList.remove('light', 'dark');
267-
document.body.classList.add(theme || 'light');
269+
document.documentElement.classList.remove('light', 'dark');
270+
document.documentElement.classList.add(theme || 'light');
268271
</script>
269272
</body>
270273
</html>

apps/svelte.dev/scripts/create-tutorial-zip/common/src/app.html

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
%sveltekit.head%
99

1010
<style>
11-
body {
11+
html {
1212
--bg-1: hsl(0, 0%, 100%);
1313
--bg-2: hsl(206, 20%, 90%);
1414
--bg-3: hsl(206, 20%, 80%);
@@ -18,6 +18,21 @@
1818
--link: hsl(208, 77%, 47%);
1919
--link-hover: hsl(208, 77%, 55%);
2020
--link-active: hsl(208, 77%, 40%);
21+
22+
&.dark {
23+
--bg-1: hsl(0, 0%, 18%);
24+
--bg-2: hsl(0, 0%, 30%);
25+
--bg-3: hsl(0, 0%, 40%);
26+
--fg-1: hsl(0, 0%, 90%);
27+
--fg-2: hsl(0, 0%, 70%);
28+
--fg-3: hsl(0, 0%, 60%);
29+
--link: hsl(206, 96%, 72%);
30+
--link-hover: hsl(206, 96%, 78%);
31+
--link-active: hsl(206, 96%, 64%);
32+
}
33+
}
34+
35+
body {
2136
--border-radius: 4px;
2237
--font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
2338
'Open Sans', 'Helvetica Neue', sans-serif;
@@ -243,18 +258,6 @@
243258
ul.todos button:hover {
244259
opacity: 1;
245260
}
246-
247-
html.dark {
248-
--bg-1: hsl(0, 0%, 18%);
249-
--bg-2: hsl(0, 0%, 30%);
250-
--bg-3: hsl(0, 0%, 40%);
251-
--fg-1: hsl(0, 0%, 90%);
252-
--fg-2: hsl(0, 0%, 70%);
253-
--fg-3: hsl(0, 0%, 60%);
254-
--link: hsl(206, 96%, 72%);
255-
--link-hover: hsl(206, 96%, 78%);
256-
--link-active: hsl(206, 96%, 64%);
257-
}
258261
</style>
259262
</head>
260263
<body>

0 commit comments

Comments
 (0)