From 76a981444e2423da7fe934ac545559665f31b649 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Fri, 26 Jul 2019 14:21:53 +0200 Subject: [PATCH] Generate CSS assets during build The main CSS file will import everything from Bootstrap and Font Awesome and provide a way to override things. --- ui/build.rs | 20 ++++++++++++++++++++ ui/scss/stoptime.scss | 28 ++++++++++++++++++++++++++++ ui/static/css/.gitkeep | 0 3 files changed, 48 insertions(+) create mode 100644 ui/build.rs create mode 100644 ui/scss/stoptime.scss create mode 100644 ui/static/css/.gitkeep diff --git a/ui/build.rs b/ui/build.rs new file mode 100644 index 0000000..20d81b9 --- /dev/null +++ b/ui/build.rs @@ -0,0 +1,20 @@ +// Generates static assets. + +use std::env; +use std::fs::File; +use std::io::Write; +use std::path::Path; + +use sass_rs::{self, Options}; + +fn main() { + let dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + let scss_dir = Path::new(&dir).join("scss"); + let source_css_file = scss_dir.join("stoptime.scss"); + let css_dir = Path::new(&dir).join("static").join("css"); + let target_css_file = css_dir.join("stoptime.css"); + + let sass = sass_rs::compile_file(&source_css_file, Options::default()).unwrap(); + let mut f = File::create(&target_css_file).unwrap(); + f.write_all(sass.as_bytes()).unwrap(); +} diff --git a/ui/scss/stoptime.scss b/ui/scss/stoptime.scss new file mode 100644 index 0000000..c4c4a4e --- /dev/null +++ b/ui/scss/stoptime.scss @@ -0,0 +1,28 @@ +// Include all of Bootstrap. +@import "bootstrap/bootstrap"; + +// Include all of Font Awesome. +@import "fontawesome/fontawesome"; + +/* StopTime's main CSS (overrides) + */ + +// Prepare for the fixed-top navbar. +html { + position: relative; + min-height: 100%; +} + +// Add some padding for the fixed-top navbar. +body { + padding-top: 80px; + margin-bottom: 24px; +} + +footer { + position: absolute; + bottom: 0; + width: 100%; + height: 24px; + line-height: 24px; +} diff --git a/ui/static/css/.gitkeep b/ui/static/css/.gitkeep new file mode 100644 index 0000000..e69de29