whisker_css/prop/
display.rs1use crate::css::Css;
4use crate::keyword::{Direction, Display};
5
6impl Css {
7 pub fn display(self, v: Display) -> Self {
10 self.push("display", v)
11 }
12
13 pub fn display_none(self) -> Self {
15 self.push("display", Display::None)
16 }
17
18 pub fn display_flex(self) -> Self {
20 self.push("display", Display::Flex)
21 }
22
23 pub fn display_grid(self) -> Self {
25 self.push("display", Display::Grid)
26 }
27
28 pub fn display_linear(self) -> Self {
30 self.push("display", Display::Linear)
31 }
32
33 pub fn display_relative(self) -> Self {
35 self.push("display", Display::Relative)
36 }
37
38 pub fn direction(self, v: Direction) -> Self {
41 self.push("direction", v)
42 }
43}
44
45#[cfg(test)]
46mod tests {
47 use crate::keyword::{Direction, Display};
48 use crate::Css;
49
50 #[test]
51 fn display_keyword() {
52 let s = Css::new().display(Display::Flex);
53 assert_eq!(s.to_string(), "display: flex;");
54 }
55
56 #[test]
57 fn display_shortcuts() {
58 assert_eq!(Css::new().display_none().to_string(), "display: none;");
59 assert_eq!(Css::new().display_flex().to_string(), "display: flex;");
60 assert_eq!(Css::new().display_grid().to_string(), "display: grid;");
61 assert_eq!(Css::new().display_linear().to_string(), "display: linear;");
62 assert_eq!(
63 Css::new().display_relative().to_string(),
64 "display: relative;"
65 );
66 }
67
68 #[test]
69 fn direction_keywords() {
70 assert_eq!(
71 Css::new().direction(Direction::Ltr).to_string(),
72 "direction: ltr;"
73 );
74 assert_eq!(
75 Css::new().direction(Direction::Rtl).to_string(),
76 "direction: rtl;"
77 );
78 }
79}