Skip to content

Commit 5ea2116

Browse files
committed
added basic dark mode support that utilizes toggle and local storage
1 parent 746dab5 commit 5ea2116

File tree

6 files changed

+457
-125
lines changed

6 files changed

+457
-125
lines changed

assets/javascripts/application.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,36 @@
22
//= require_directory ./plugins/
33
//= require_self
44

5+
var isLightTheme = true;
6+
7+
document.addEventListener('DOMContentLoaded', function() {
8+
var button = document.getElementById('dark-mode-toggle');
9+
10+
// Check if there's a saved preference in localStorage
11+
if (localStorage.getItem('darkMode') === 'true') {
12+
isLightTheme = false;
13+
document.body.classList.add('dark-mode');
14+
button.textContent = 'Light Mode';
15+
} else {
16+
button.textContent = 'Dark Mode';
17+
}
18+
19+
button.addEventListener('click', function() {
20+
isLightTheme = !isLightTheme;
21+
22+
// Toggle dark mode class on body
23+
if (isLightTheme) {
24+
document.body.classList.remove('dark-mode');
25+
localStorage.setItem('darkMode', 'false');
26+
button.textContent = 'Dark Mode';
27+
} else {
28+
document.body.classList.add('dark-mode');
29+
localStorage.setItem('darkMode', 'true');
30+
button.textContent = 'Light Mode';
31+
}
32+
});
33+
});
34+
535
$(document).ready(function () {
636
$('.file_list').dataTable({
737
order: [[1, "asc"]],

assets/stylesheets/plugins/highlight.css

Lines changed: 152 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,128 +2,253 @@
22
github.com style (c) Vasily Polovnyov <[email protected]>
33
*/
44

5+
/* Syntax highlighting styles */
56
pre code {
7+
color: var(--text-color-light);
8+
font-family: "Monaco", "Inconsolata", "Consolas", monospace;
69
}
710

11+
/* Comments */
812
pre .comment,
913
pre .template_comment,
1014
pre .diff .header,
1115
pre .javadoc {
12-
color: #998;
13-
font-style: italic
16+
color: var(--text-color);
17+
opacity: 0.7;
18+
font-style: italic;
1419
}
1520

21+
/* Keywords */
1622
pre .keyword,
1723
pre .css .rule .keyword,
1824
pre .winutils,
1925
pre .javascript .title,
2026
pre .lisp .title {
21-
color: #000;
22-
font-weight: bold
27+
color: var(--text-color-light);
28+
font-weight: bold;
2329
}
2430

31+
/* Numbers */
2532
pre .number,
2633
pre .hexcolor {
27-
color: #458
34+
color: var(--blue-color);
2835
}
2936

30-
37+
/* Strings */
3138
pre .string,
3239
pre .tag .value,
3340
pre .phpdoc,
3441
pre .tex .formula {
35-
color: #d14
42+
color: var(--red-color);
3643
}
3744

45+
/* Substitutions */
3846
pre .subst {
39-
color: #712;
47+
color: var(--text-color-light);
4048
}
4149

50+
/* Constants and titles */
4251
pre .constant,
4352
pre .title,
4453
pre .id {
45-
color: #900;
46-
font-weight: bold
54+
color: var(--green-color);
55+
font-weight: bold;
4756
}
4857

58+
/* JavaScript and Lisp titles */
4959
pre .javascript .title,
5060
pre .lisp .title,
5161
pre .subst {
52-
font-weight: normal
62+
font-weight: normal;
5363
}
5464

65+
/* Classes */
5566
pre .class .title,
5667
pre .haskell .label,
5768
pre .tex .command {
58-
color: #458;
59-
font-weight: bold
69+
color: var(--blue-color);
70+
font-weight: bold;
6071
}
6172

73+
/* Tags */
6274
pre .tag,
6375
pre .tag .title,
6476
pre .rules .property,
6577
pre .django .tag .keyword {
66-
color: #000080;
67-
font-weight: normal
78+
color: var(--text-color-light);
79+
font-weight: normal;
6880
}
6981

82+
/* Attributes and variables */
7083
pre .attribute,
7184
pre .variable,
7285
pre .instancevar,
7386
pre .lisp .body {
74-
color: #008080
87+
color: var(--yellow-color);
7588
}
7689

90+
/* Regular expressions */
7791
pre .regexp {
78-
color: #009926
92+
color: var(--green-color);
7993
}
8094

95+
/* Classes */
8196
pre .class {
82-
color: #458;
83-
font-weight: bold
97+
color: var(--blue-color);
98+
font-weight: bold;
8499
}
85100

101+
/* Symbols */
86102
pre .symbol,
87103
pre .ruby .symbol .string,
88104
pre .ruby .symbol .keyword,
89105
pre .ruby .symbol .keymethods,
90106
pre .lisp .keyword,
91107
pre .tex .special,
92108
pre .input_number {
93-
color: #990073
109+
color: var(--yellow-color);
94110
}
95111

112+
/* Built-ins */
96113
pre .builtin,
97114
pre .built_in,
98115
pre .lisp .title {
99-
color: #0086b3
116+
color: var(--blue-color);
100117
}
101118

119+
/* Preprocessor */
102120
pre .preprocessor,
103121
pre .pi,
104122
pre .doctype,
105123
pre .shebang,
106124
pre .cdata {
107-
color: #999;
108-
font-weight: bold
125+
color: var(--text-color);
126+
opacity: 0.7;
127+
font-weight: bold;
109128
}
110129

130+
/* Diff changes */
111131
pre .deletion {
112-
background: #fdd
132+
background: var(--missed-bg-odd);
113133
}
114134

115135
pre .addition {
116-
background: #dfd
136+
background: var(--covered-bg-odd);
117137
}
118138

119139
pre .diff .change {
120-
background: #0086b3
140+
background: var(--blue-color);
141+
opacity: 0.3;
121142
}
122143

123144
pre .chunk {
124-
color: #aaa
145+
color: var(--text-color);
146+
opacity: 0.5;
125147
}
126148

127149
pre .tex .formula {
128150
opacity: 0.5;
129151
}
152+
153+
/* Dark mode specific overrides */
154+
.dark-mode {
155+
pre code {
156+
color: var(--text-color-light);
157+
}
158+
159+
pre .comment,
160+
pre .template_comment,
161+
pre .diff .header,
162+
pre .javadoc {
163+
color: var(--text-color);
164+
opacity: 0.7;
165+
}
166+
167+
pre .keyword,
168+
pre .css .rule .keyword,
169+
pre .winutils,
170+
pre .javascript .title,
171+
pre .lisp .title {
172+
color: var(--text-color-light);
173+
}
174+
175+
pre .number,
176+
pre .hexcolor {
177+
color: var(--blue-color);
178+
}
179+
180+
pre .string,
181+
pre .tag .value,
182+
pre .phpdoc,
183+
pre .tex .formula {
184+
color: var(--red-color);
185+
}
186+
187+
pre .subst {
188+
color: var(--text-color-light);
189+
}
190+
191+
pre .constant,
192+
pre .title,
193+
pre .id {
194+
color: var(--green-color);
195+
}
196+
197+
pre .attribute,
198+
pre .variable,
199+
pre .instancevar,
200+
pre .lisp .body {
201+
color: var(--yellow-color);
202+
}
203+
204+
pre .regexp {
205+
color: var(--green-color);
206+
}
207+
208+
pre .class {
209+
color: var(--blue-color);
210+
}
211+
212+
pre .symbol,
213+
pre .ruby .symbol .string,
214+
pre .ruby .symbol .keyword,
215+
pre .ruby .symbol .keymethods,
216+
pre .lisp .keyword,
217+
pre .tex .special,
218+
pre .input_number {
219+
color: var(--yellow-color);
220+
}
221+
222+
pre .builtin,
223+
pre .built_in,
224+
pre .lisp .title {
225+
color: var(--blue-color);
226+
}
227+
228+
pre .preprocessor,
229+
pre .pi,
230+
pre .doctype,
231+
pre .shebang,
232+
pre .cdata {
233+
color: var(--text-color);
234+
opacity: 0.7;
235+
}
236+
237+
pre .deletion {
238+
background: var(--missed-bg-odd);
239+
}
240+
241+
pre .addition {
242+
background: var(--covered-bg-odd);
243+
}
244+
245+
pre .diff .change {
246+
background: var(--blue-color);
247+
opacity: 0.3;
248+
}
249+
250+
pre .chunk {
251+
color: var(--text-color);
252+
opacity: 0.5;
253+
}
254+
}

0 commit comments

Comments
 (0)