diff options
author | Bao Trinh <qubidt@gmail.com> | 2023-07-12 17:46:51 +0000 |
---|---|---|
committer | Bao Trinh <qubidt@gmail.com> | 2023-07-12 18:39:51 +0000 |
commit | b369a1a9ff3c60b67a7598d4486253c428e3a4da (patch) | |
tree | 2cdf9586cc50f999fc69f436aea89c5ff3332cba /src/renderer.rs | |
parent | simplify theme selection using data attributes (diff) | |
download | miniserve-b369a1a9ff3c60b67a7598d4486253c428e3a4da.tar.gz miniserve-b369a1a9ff3c60b67a7598d4486253c428e3a4da.zip |
Separate color schemes into separate files
Diffstat (limited to '')
-rw-r--r-- | src/renderer.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/renderer.rs b/src/renderer.rs index 2e1ff2e..2de95c8 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -346,6 +346,21 @@ pub enum ThemeSlug { Monokai, } +impl ThemeSlug { + pub fn css(&self) -> &str { + match self { + ThemeSlug::Squirrel => include_str!(concat!(env!("OUT_DIR"), "/theme-squirrel.css")), + ThemeSlug::Archlinux => include_str!(concat!(env!("OUT_DIR"), "/theme-archlinux.css")), + ThemeSlug::Zenburn => include_str!(concat!(env!("OUT_DIR"), "/theme-zenburn.css")), + ThemeSlug::Monokai => include_str!(concat!(env!("OUT_DIR"), "/theme-monokai.css")), + } + } + + pub fn css_dark(&self) -> String { + format!("@media (prefers-color-scheme: dark) {{\n{}}}", self.css()) + } +} + /// Partial: qr code spoiler fn qr_spoiler(show_qrcode: bool, content: &Uri) -> Markup { html! { |