aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--build.rs8
-rw-r--r--src/renderer.rs5
2 files changed, 8 insertions, 5 deletions
diff --git a/build.rs b/build.rs
index a386b41..8c354d0 100644
--- a/build.rs
+++ b/build.rs
@@ -3,15 +3,17 @@ use std::fs;
use std::path::Path;
fn main() {
- let out_dir = env::var_os("OUT_DIR").expect("out dir env var missing");
+ let out_dir = env::var_os("OUT_DIR").expect("OUT_DIR env var missing");
let dest_path = Path::new(&out_dir).join("style.css");
fs::write(
&dest_path,
grass::from_string(
include_str!("data/style.scss").to_string(),
&grass::Options::default(),
- ).expect("scss failed to compile"),
- ).expect("failed to write css file");
+ )
+ .expect("scss failed to compile"),
+ )
+ .expect("failed to write css file");
println!("cargo:rerun-if-changed=data/style.scss");
}
diff --git a/src/renderer.rs b/src/renderer.rs
index 8b3f922..5a727d0 100644
--- a/src/renderer.rs
+++ b/src/renderer.rs
@@ -41,12 +41,12 @@ pub fn page(
(page_header(&title_path, file_upload, favicon_route, css_route))
body#drop-container
- // Add classes to body selecting default light and dark theme
.(format!("default_theme_{}", default_color_scheme))
.(format!("default_theme_dark_{}", default_color_scheme_dark)) {
(PreEscaped(r#"
<script>
+ // read theme from local storage and apply it to body
const body = document.body;
var theme = localStorage.getItem('theme');
@@ -54,6 +54,8 @@ pub fn page(
body.classList.add('theme_' + theme);
}
+ // updates the color scheme by replacing the appropriate class
+ // on body and saving the new theme to local storage
function updateColorScheme(name) {
body.classList.remove.apply(body.classList, Array.from(body.classList).filter(v=>v.startsWith("theme_")));
@@ -475,7 +477,6 @@ pub fn render_error(
html {
(page_header(&error_code.to_string(), false, favicon_route, css_route))
- // Add classes to body selecting default light and dark theme
body.(format!("default_theme_{}", default_color_scheme))
.(format!("default_theme_dark_{}", default_color_scheme_dark)) {