multiple classes

This commit is contained in:
annieversary 2022-07-02 15:07:01 +01:00
parent 28d7886ee8
commit 47a260b7ee
1 changed files with 16 additions and 0 deletions

View File

@ -42,8 +42,11 @@ impl Zephyr {
} }
pub fn generate_css(&self, classes: &[&str]) -> String { pub fn generate_css(&self, classes: &[&str]) -> String {
// TODO when we have media queries, we can do something to group them together
classes classes
.into_iter() .into_iter()
.flat_map(|s| s.split_ascii_whitespace())
.flat_map(|c| self.generate_class(c)) .flat_map(|c| self.generate_class(c))
.collect::<Vec<_>>() .collect::<Vec<_>>()
.join("") .join("")
@ -119,4 +122,17 @@ mod tests {
r#".flex\|hover,focus\$placeholder:hover:focus::placeholder { display: flex; }"# r#".flex\|hover,focus\$placeholder:hover:focus::placeholder { display: flex; }"#
); );
} }
#[test]
fn generate_multiple_works() {
let z = Zephyr::new();
let classes_joined = z.generate_css(&["flex-row mt[1rem]"]);
let classes_separate = z.generate_css(&["flex-row", "mt[1rem]"]);
assert_eq!(
classes_joined,
r#".flex-row { display: flex; flex-direction: row; }.mt\[1rem\] { margin-top: 1rem; }"#
);
assert_eq!(classes_separate, classes_joined);
}
} }