Skip to content

Commit 4799c89

Browse files
authored
Merge pull request #3857 from ndd7xv/dark-mode
Draft: Add a Dark Mode
2 parents 917ac74 + f9f75a2 commit 4799c89

File tree

5 files changed

+57
-14
lines changed

5 files changed

+57
-14
lines changed

themes/rusted/static/css/_base.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ a {
9292
text-decoration: none;
9393

9494
&:visited {
95-
color: darken($brand-color, 15%);
95+
color: $brand-color-visited;
9696
}
9797

9898
&:hover {
@@ -126,9 +126,9 @@ blockquote {
126126
pre,
127127
code {
128128
font-size: 15px;
129-
border: 1px solid $grey-colour-light;
129+
border: 1px solid $code-border-color;
130130
border-radius: 3px;
131-
background-color: #eef;
131+
background-color: $code-bg-color;
132132
}
133133

134134
code {
@@ -138,6 +138,7 @@ code {
138138
pre {
139139
padding: 8px 12px;
140140
overflow-x: scroll;
141+
color: $pre-color;
141142

142143
> code {
143144
border: 0;

themes/rusted/static/css/_homepage.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
}
99

1010
.subtext {
11-
11+
margin-left: 50px;
12+
margin-right: 50px;
1213
}

themes/rusted/static/css/_layout.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
letter-spacing: -1px;
1818
margin-bottom: 0;
1919

20-
&,
20+
color: $text-color;
2121
&:visited {
22-
color: $grey-colour-dark;
22+
color: $text-color;
2323
}
2424
}
2525

themes/rusted/static/css/main.scss

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,62 @@
33
// Bootstrap variables
44
$screen-xs-max: 768px !default;
55

6-
// Our variables
76
$base-font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
87
$base-font-size: 16px;
98
$small-font-size: $base-font-size * 0.875;
109
$base-line-height: 1.5;
1110

1211
$spacing-unit: 30px;
1312

14-
$text-color: #444;
15-
$background-color: #fdfdfd;
16-
$brand-color: #2a7ae2;
13+
// Our variables
14+
$text-color: var(--text-color);
15+
$background-color: var(--background-color);
16+
$brand-color: var(--brand-color);
17+
$brand-color-visited: var(--brand-color-visited);
18+
$pre-color: var(--pre-color);
19+
$code-bg-color: var(--code-bg-color);
20+
$code-border-color: var(--code-border-color);
21+
$grey-colour: #828282;
22+
$grey-colour-light: lighten($grey-colour, 40%);
23+
$grey-colour-dark: darken($grey-colour, 25%);
24+
25+
// Light theme colors
26+
$text-color-lt: #444;
27+
$background-color-lt: #fdfdfd;
28+
$brand-color-lt: #2a7ae2;
29+
$brand-color-visited-lt: #1756a9;
30+
$pre-color-lt: #333;
31+
$code-bg-color-lt: #eef;
32+
33+
// Dark theme colors
34+
$text-color-dt: #f0f0f0;
35+
$background-color-dt: #353535;
36+
$brand-color-dt: #d2991d;
37+
$brand-color-visited-dt: #9a7015;
38+
$pre-color-dt: #aeaeae;
39+
$code-bg-color-dt: #2a2a2a;
1740

18-
$grey-colour: #828282;
19-
$grey-colour-light: lighten($grey-colour, 40%);
20-
$grey-colour-dark: darken($grey-colour, 25%);
41+
:root {
42+
--text-color: #{$text-color-lt};
43+
--background-color: #{$background-color-lt};
44+
--brand-color: #{$brand-color-lt};
45+
--brand-color-visited: #{$brand-color-visited-lt};
46+
--pre-color: #{$pre-color-lt};
47+
--code-bg-color: #{$code-bg-color-lt};
48+
--code-border-color: #{$grey-colour-light};
49+
}
50+
51+
@media(prefers-color-scheme: dark) {
52+
:root {
53+
--text-color: #{$text-color-dt};
54+
--background-color: #{$background-color-dt};
55+
--brand-color: #{$brand-color-dt};
56+
--brand-color-visited: #{$brand-color-visited-dt};
57+
--pre-color: #{$pre-color-dt};
58+
--code-bg-color: #{$code-bg-color-dt};
59+
--code-border-color: #{$code-bg-color-dt};
60+
}
61+
}
2162

2263
$on-palm: 600px;
2364
$on-laptop: 800px;

themes/rusted/templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="row">
55
<div class="col-md-12 text-center">
66
<h1 class="pitch">Handpicked Rust updates, <br /> delivered to your inbox.</h1>
7-
<p class="subtext">Stay up to date with events, learning resources, and recent developments in Rust community.</p>
7+
<p class="subtext">Stay up to date with events, learning resources, and recent developments in the Rust community.</p>
88
</div>
99
</div>
1010
{% include "_subscribe-form.html" %}

0 commit comments

Comments
 (0)