Skip to content

Commit bb35063

Browse files
committed
Styles: Made non-active dark/light css variables exist by default
This means that it would be possible to jump between light/dark mode with just the class, and no reload needed. Not something we'll directly use right now, but may be useful in customizations.
1 parent 0f40aeb commit bb35063

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed
Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
@php
2-
$settingSuffix = setting()->getForCurrentUser('dark-mode-enabled') ? '-dark' : '';
3-
@endphp
41
<style>
52
:root {
6-
--color-primary: {{ setting('app-color' . $settingSuffix) }};
7-
--color-primary-light: {{ setting('app-color-light' . $settingSuffix) }};
8-
--color-link: {{ setting('link-color' . $settingSuffix) }};
9-
--color-bookshelf: {{ setting('bookshelf-color' . $settingSuffix)}};
10-
--color-book: {{ setting('book-color' . $settingSuffix)}};
11-
--color-chapter: {{ setting('chapter-color' . $settingSuffix)}};
12-
--color-page: {{ setting('page-color' . $settingSuffix)}};
13-
--color-page-draft: {{ setting('page-draft-color' . $settingSuffix)}};
3+
--color-primary: {{ setting('app-color') }};
4+
--color-primary-light: {{ setting('app-color-light') }};
5+
--color-link: {{ setting('link-color') }};
6+
--color-bookshelf: {{ setting('bookshelf-color') }};
7+
--color-book: {{ setting('book-color') }};
8+
--color-chapter: {{ setting('chapter-color') }};
9+
--color-page: {{ setting('page-color') }};
10+
--color-page-draft: {{ setting('page-draft-color') }};
11+
}
12+
:root.dark-mode {
13+
--color-primary: {{ setting('app-color-dark') }};
14+
--color-primary-light: {{ setting('app-color-light-dark') }};
15+
--color-link: {{ setting('link-color-dark') }};
16+
--color-bookshelf: {{ setting('bookshelf-color-dark') }};
17+
--color-book: {{ setting('book-color-dark') }};
18+
--color-chapter: {{ setting('chapter-color-dark') }};
19+
--color-page: {{ setting('page-color-dark') }};
20+
--color-page-draft: {{ setting('page-draft-color-dark') }};
1421
}
1522
</style>

tests/Settings/SettingsTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,17 @@ public function test_updating_and_removing_app_icon()
101101
file_get_contents(public_path('favicon.ico')),
102102
);
103103
}
104+
105+
public function test_both_light_and_dark_colors_are_used_in_the_base_view()
106+
{
107+
// To allow for dynamic color changes on the front-end where desired.
108+
$this->setSettings(['page-color' => 'superlightblue', 'page-color-dark' => 'superdarkblue']);
109+
110+
$resp = $this->get('/login');
111+
112+
$resp->assertSee(':root {');
113+
$resp->assertSee('superlightblue');
114+
$resp->assertSee(':root.dark-mode {');
115+
$resp->assertSee('superdarkblue');
116+
}
104117
}

0 commit comments

Comments
 (0)