Add a toggle between dark and light theme
This commit is contained in:
parent
d22617538e
commit
559ed139aa
34 changed files with 640 additions and 469 deletions
|
|
@ -26,25 +26,36 @@ where
|
|||
fn main() {
|
||||
println!("cargo:rerun-if-changed=style.scss");
|
||||
|
||||
fn run_sass(command: &mut Command) -> Output {
|
||||
command
|
||||
.arg("--no-source-map")
|
||||
.arg("scss/style.scss")
|
||||
.arg("static/style.css")
|
||||
.output()
|
||||
.expect("Unable to compile SASS file, install SASS, see https://sass-lang.com/")
|
||||
fn run_sass(filename_without_extension: &str) {
|
||||
fn run_sass_command(command: &mut Command, name: &str) -> Output {
|
||||
command
|
||||
.arg("--no-source-map")
|
||||
.arg(format!("scss/{}.scss", name))
|
||||
.arg(format!("static/{}.css", name))
|
||||
.output()
|
||||
.expect("Unable to compile SASS file, install SASS, see https://sass-lang.com/")
|
||||
}
|
||||
|
||||
let output = if exists_in_path("sass.bat") {
|
||||
run_sass_command(
|
||||
Command::new("cmd").args(["/C", "sass.bat"]),
|
||||
filename_without_extension,
|
||||
)
|
||||
} else {
|
||||
run_sass_command(&mut Command::new("sass"), filename_without_extension)
|
||||
};
|
||||
|
||||
if !output.status.success() {
|
||||
// SASS will put the error in the file.
|
||||
let error =
|
||||
std::fs::read_to_string(format!("./static/{}.css", filename_without_extension))
|
||||
.unwrap_or_else(|_| {
|
||||
panic!("unable to read {}.css", filename_without_extension)
|
||||
});
|
||||
panic!("{}", error);
|
||||
}
|
||||
}
|
||||
|
||||
let output = if exists_in_path("sass.bat") {
|
||||
run_sass(Command::new("cmd").args(["/C", "sass.bat"]))
|
||||
} else {
|
||||
run_sass(&mut Command::new("sass"))
|
||||
};
|
||||
|
||||
if !output.status.success() {
|
||||
// SASS will put the error in the file.
|
||||
let error =
|
||||
std::fs::read_to_string("./static/style.css").expect("unable to read style.css");
|
||||
panic!("{}", error);
|
||||
}
|
||||
run_sass("style_light");
|
||||
run_sass("style_dark");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue