Skip to content

Commit 743b6f3

Browse files
authored
Merge pull request #1728 from typicode/feat/system-theme-index-dark-mode
feat: support system dark mode on index page
2 parents d2b3dec + 04b4b7c commit 743b6f3

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

views/index.html

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,29 @@
66
<title>JSON Server</title>
77
<style>
88
:root {
9-
--fg: #111;
10-
--muted: #999;
11-
--line: #e5e5e5;
9+
color-scheme: light dark;
10+
--fg: light-dark(#111, #e8e8e8);
11+
--bg: light-dark(#fff, #111214);
12+
--muted: light-dark(#999, #9aa0a6);
13+
--line: light-dark(#e5e5e5, #2c2f34);
14+
--accent: light-dark(#6366f1, #8b90ff);
15+
--chip-bg: light-dark(#111, #f5f5f5);
16+
--chip-fg: light-dark(#fff, #111214);
1217
}
1318
body {
1419
margin: 40px auto;
1520
max-width: 400px;
1621
padding: 0 24px;
1722
font-family:
1823
ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
19-
background-color: #fff;
24+
background-color: var(--bg);
2025
color: var(--fg);
2126
line-height: 1.5;
2227
font-size: 14px;
28+
transition:
29+
background-color 0.2s ease,
30+
color 0.2s ease,
31+
border-color 0.2s ease;
2332
}
2433
a {
2534
color: inherit;
@@ -44,7 +53,7 @@
4453
color: var(--fg);
4554
}
4655
.topbar a:hover {
47-
color: #6366f1;
56+
color: var(--accent);
4857
}
4958
.section-title {
5059
margin-bottom: 8px;
@@ -64,7 +73,7 @@
6473
transition: color 0.1s ease;
6574
}
6675
.list a:hover {
67-
color: #6366f1;
76+
color: var(--accent);
6877
}
6978
.meta {
7079
color: var(--muted);
@@ -90,8 +99,8 @@
9099
width: 32px;
91100
height: 32px;
92101
border-radius: 50%;
93-
color: #fff;
94-
background-color: #111;
102+
color: var(--chip-fg);
103+
background-color: var(--chip-bg);
95104
text-decoration: none;
96105
transition: transform 0.15s ease;
97106
}
@@ -133,5 +142,6 @@
133142
</footer>
134143

135144
<a href="https://github.com/sponsors/typicode" target="_blank" class="heart"></a>
145+
136146
</body>
137147
</html>

0 commit comments

Comments
 (0)