multiple classes
This commit is contained in:
parent
28d7886ee8
commit
47a260b7ee
16
src/lib.rs
16
src/lib.rs
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue