diff --git a/src/defaults.rs b/src/defaults.rs index eec366a..abdb91e 100644 --- a/src/defaults.rs +++ b/src/defaults.rs @@ -1,9 +1,9 @@ use std::collections::HashMap; -use crate::{consts::CSS_COLORS, SpecialDeclaration}; +use crate::SpecialDeclaration; pub(crate) fn default_declarations() -> HashMap { - let mut h = vec![ + vec![ ("flex", "display:flex"), ("flex-row", "display:flex;flex-direction:row"), ("flex-col", "display:flex;flex-direction:column"), @@ -19,16 +19,7 @@ pub(crate) fn default_declarations() -> HashMap { ] .into_iter() .map(|(a, b)| (a.to_string(), b.to_string())) - .collect::>(); - - // add all css colors - h.extend( - CSS_COLORS - .iter() - .map(|c| (c.to_string(), format!("color:{c}"))), - ); - - h + .collect::>() } pub(crate) fn default_properties() -> HashMap { diff --git a/src/lib.rs b/src/lib.rs index 202bbff..8f95dc6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -110,4 +110,13 @@ impl Zephyr { specials: default_specials(), } } + + pub fn with_css_colors(mut self) -> Self { + self.declarations.extend( + crate::consts::CSS_COLORS + .iter() + .map(|c| (c.to_string(), format!("color:{c}"))), + ); + self + } } diff --git a/src/tests.rs b/src/tests.rs index ea324cf..c6a035b 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -134,7 +134,7 @@ fn generate_variable() { #[test] fn generate_css_colors() { - let z = Zephyr::new(); + let z = Zephyr::new().with_css_colors(); let classes = z.generate_classes(["white blanchedalmond"]); assert_eq!(