Hansimov commited on
Commit
63b7747
1 Parent(s): bc3895d

:gem: [Feature] New dark theme toggle button

Browse files
Files changed (3) hide show
  1. components/buttons_binder.js +35 -0
  2. css/dark.css +33 -0
  3. index.html +5 -0
components/buttons_binder.js CHANGED
@@ -40,6 +40,8 @@ export class ButtonsBinder {
40
  clear_chat_history_button_binder.bind();
41
  let available_models_select_binder = new AvailableModelsSelectBinder();
42
  available_models_select_binder.bind();
 
 
43
  }
44
  }
45
 
@@ -318,3 +320,36 @@ class AvailableModelsSelectBinder {
318
  });
319
  }
320
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  clear_chat_history_button_binder.bind();
41
  let available_models_select_binder = new AvailableModelsSelectBinder();
42
  available_models_select_binder.bind();
43
+ let dark_theme_toggle_button_binder = new DarkThemeToggleButtonBinder();
44
+ dark_theme_toggle_button_binder.bind();
45
  }
46
  }
47
 
 
320
  });
321
  }
322
  }
323
+
324
+ class DarkThemeToggleButtonBinder {
325
+ constructor() {
326
+ this.storage_key = "theme";
327
+ this.set_theme();
328
+ }
329
+ bind() {
330
+ const toggle_button = $("#dark-theme-toggle-button");
331
+ toggle_button.click(() => {
332
+ let theme = localStorage.getItem(this.storage_key);
333
+ if (theme === "dark") {
334
+ localStorage.setItem(this.storage_key, "light");
335
+ } else {
336
+ localStorage.setItem(this.storage_key, "dark");
337
+ }
338
+ this.set_theme();
339
+ });
340
+ }
341
+ set_theme() {
342
+ let theme = localStorage.getItem(this.storage_key);
343
+ if (theme === "dark") {
344
+ // load dark.css
345
+ $("#dark-theme").remove();
346
+ $("head").append(
347
+ '<link id="dark-theme" rel="stylesheet" href="css/dark.css">'
348
+ );
349
+ } else {
350
+ // remove dark.css
351
+ $("#dark-theme").remove();
352
+ }
353
+ console.log("set theme:", theme);
354
+ }
355
+ }
css/dark.css ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+ background-color: #0f0f0f;
3
+ color: #cccccc;
4
+ }
5
+
6
+ #top-toolbar {
7
+ background-color: #373737;
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: #373737;
20
+ }
21
+
22
+ input,
23
+ textarea,
24
+ .form-select,
25
+ .form-control {
26
+ background-color: #373737;
27
+ color: #cccccc;
28
+ border-color: #686868;
29
+ }
30
+
31
+ .fa {
32
+ color: #d2d2d2;
33
+ }
index.html CHANGED
@@ -48,6 +48,11 @@
48
  <i class="fa fa-camera"></i>
49
  </button>
50
  </div>
 
 
 
 
 
51
  </div>
52
  </div>
53
  <div class="offcanvas offcanvas-end" data-bs-scroll="true" data-bs-backdrop="false" id="chat-agents-sidebar"
 
48
  <i class="fa fa-camera"></i>
49
  </button>
50
  </div>
51
+ <div class="col">
52
+ <button id="dark-theme-toggle-button" class="btn">
53
+ <i class="fa fa-lightbulb"></i>
54
+ </button>
55
+ </div>
56
  </div>
57
  </div>
58
  <div class="offcanvas offcanvas-end" data-bs-scroll="true" data-bs-backdrop="false" id="chat-agents-sidebar"