diff --git a/src/theme.rs b/src/theme.rs index 1f9e77d..847c143 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -38,6 +38,22 @@ pub fn theme_from_str(x: &str) -> Theme { THEMES[choice] } +pub struct CssClass(Theme); + +impl Theme { + pub fn css_class(self) -> CssClass { + CssClass(self) + } +} + +use std::fmt::{self, Display, Formatter}; + +impl Display for CssClass { + fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { + write!(fmt, "theme-{}", self.0) + } +} + #[cfg(test)] mod test { use super::*; @@ -74,4 +90,9 @@ mod test { fn from_str() { assert_eq!(theme_from_str("Bartefjes"), Theme::Orange); } + + #[test] + fn css_class_display() { + assert_eq!(&Theme::Red.css_class().to_string(), "theme-red"); + } } diff --git a/templates/layout.html b/templates/layout.html index 2123814..e1c8ee3 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -9,7 +9,7 @@ - + {{>search_input.html}} {{{body}}}