:zap: [Enhance] Switch dark mode with darkreader.js
Browse files- components/buttons_binder.js +3 -7
- css/dark.css +0 -53
- index.html +1 -0
components/buttons_binder.js
CHANGED
@@ -365,18 +365,14 @@ class DarkThemeToggleButtonBinder {
|
|
365 |
}
|
366 |
this.set_theme();
|
367 |
});
|
|
|
368 |
}
|
369 |
set_theme() {
|
370 |
let theme = localStorage.getItem(this.storage_key);
|
371 |
if (theme === "dark") {
|
372 |
-
|
373 |
-
$("#dark-theme").remove();
|
374 |
-
$("head").append(
|
375 |
-
'<link id="dark-theme" rel="stylesheet" href="css/dark.css">'
|
376 |
-
);
|
377 |
} else {
|
378 |
-
|
379 |
-
$("#dark-theme").remove();
|
380 |
}
|
381 |
console.log("set theme:", theme);
|
382 |
}
|
|
|
365 |
}
|
366 |
this.set_theme();
|
367 |
});
|
368 |
+
DarkReader.setFetchMethod(window.fetch);
|
369 |
}
|
370 |
set_theme() {
|
371 |
let theme = localStorage.getItem(this.storage_key);
|
372 |
if (theme === "dark") {
|
373 |
+
DarkReader.enable();
|
|
|
|
|
|
|
|
|
374 |
} else {
|
375 |
+
DarkReader.disable();
|
|
|
376 |
}
|
377 |
console.log("set theme:", theme);
|
378 |
}
|
css/dark.css
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
body {
|
2 |
-
background-color: #161616;
|
3 |
-
color: #cccccc;
|
4 |
-
}
|
5 |
-
|
6 |
-
#top-toolbar {
|
7 |
-
background-color: #161616;
|
8 |
-
}
|
9 |
-
|
10 |
-
#chat-agents-sidebar,
|
11 |
-
#chat-history-sidebar {
|
12 |
-
box-shadow: 0px 0px 8px 0px rgba(122, 122, 122, 0.4);
|
13 |
-
background-color: rgba(42, 42, 42, 0.6);
|
14 |
-
color: #cccccc;
|
15 |
-
}
|
16 |
-
|
17 |
-
#user-interactions {
|
18 |
-
box-shadow: 0px 2px 8px 0px rgba(122, 122, 122, 0.4);
|
19 |
-
background-color: #242424;
|
20 |
-
}
|
21 |
-
|
22 |
-
.message-user {
|
23 |
-
/* background-image: linear-gradient(-45deg, #f6f8fe, #e9efff); */
|
24 |
-
background-color: #3a4946;
|
25 |
-
}
|
26 |
-
.message-user .role-displayer {
|
27 |
-
color: #5facfa;
|
28 |
-
}
|
29 |
-
|
30 |
-
.message-assistant {
|
31 |
-
/* background-image: linear-gradient(-45deg, #f4f6fe, #ecedff); */
|
32 |
-
background-color: #3d3d50;
|
33 |
-
}
|
34 |
-
.message-assistant .role-displayer {
|
35 |
-
color: #dc68ff;
|
36 |
-
}
|
37 |
-
|
38 |
-
.content-displayer {
|
39 |
-
color: #cccccc;
|
40 |
-
}
|
41 |
-
|
42 |
-
input,
|
43 |
-
textarea,
|
44 |
-
.form-select,
|
45 |
-
.form-control {
|
46 |
-
background-color: #2e2e2e;
|
47 |
-
color: #cccccc;
|
48 |
-
border-color: #686868;
|
49 |
-
}
|
50 |
-
|
51 |
-
.fa {
|
52 |
-
color: #d2d2d2;
|
53 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
index.html
CHANGED
@@ -20,6 +20,7 @@
|
|
20 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.30.1/moment.min.js"></script>
|
21 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.30.1/moment-with-locales.min.js"></script>
|
22 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/dexie/3.2.4/dexie.min.js"></script>
|
|
|
23 |
<script src="./networks/live.js"></script>
|
24 |
<link rel="stylesheet" href="./css/default.css" />
|
25 |
</head>
|
|
|
20 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.30.1/moment.min.js"></script>
|
21 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.30.1/moment-with-locales.min.js"></script>
|
22 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/dexie/3.2.4/dexie.min.js"></script>
|
23 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/darkreader/4.9.75/darkreader.min.js"></script>
|
24 |
<script src="./networks/live.js"></script>
|
25 |
<link rel="stylesheet" href="./css/default.css" />
|
26 |
</head>
|