polished_css/property/appearance/
border.rs

1macro_rules! create_border_color_struct {
2    ($property:ident, $atomic:literal) => {
3        $crate::create_property!(
4            $property,
5            display = "",
6            atomic = $atomic,
7            custom = false,
8            data_type = "<color>",
9            initial_value = CurrentColor,
10            keywords = "currentColor",
11        );
12    };
13}
14create_border_color_struct!(BorderColor, "bor-c");
15create_border_color_struct!(BorderBlockColor, "bor-c-bl");
16create_border_color_struct!(BorderInlineColor, "bor-c-in");
17create_border_color_struct!(BorderTopColor, "bor-c-t");
18create_border_color_struct!(BorderBottomColor, "bor-c-b");
19create_border_color_struct!(BorderLeftColor, "bor-c-l");
20create_border_color_struct!(BorderRightColor, "bor-c-r");
21
22macro_rules! create_border_radius_struct {
23    ($property:ident, $atomic:literal, $custom:literal) => {
24        $crate::create_property!(
25            $property,
26            display = "",
27            atomic = $atomic,
28            custom = $custom,
29            data_type = "<length-percentage>",
30            initial_value = Initial,
31            keywords = "",
32        );
33    };
34}
35create_border_radius_struct!(BorderRadius, "bor-r", false);
36create_border_radius_struct!(BorderTopRadius, "bor-r-t", true);
37create_border_radius_struct!(BorderBottomRadius, "bor-r-b", true);
38create_border_radius_struct!(BorderLeftRadius, "bor-r-l", true);
39create_border_radius_struct!(BorderRightRadius, "bor-r-r", true);
40create_border_radius_struct!(BorderTopLeftRadius, "bor-r-t-l", false);
41create_border_radius_struct!(BorderTopRightRadius, "bor-r-t-r", false);
42create_border_radius_struct!(BorderBottomLeftRadius, "bor-r-b-l", false);
43create_border_radius_struct!(BorderBottomRightRadius, "bor-r-b-r", false);
44
45macro_rules! create_border_style_struct {
46    ($property:ident, $atomic:literal) => {
47        $crate::create_property!(
48            $property,
49            display = "",
50            atomic = $atomic,
51            custom = false,
52            data_type = "",
53            initial_value = None,
54            keywords = "none,hidden,dotted,dashed,solid,double,groove,ridge,inset,outset",
55        );
56    };
57}
58create_border_style_struct!(BorderStyle, "bor-s");
59create_border_style_struct!(BorderBlockStyle, "bor-s-bl");
60create_border_style_struct!(BorderInlineStyle, "bor-s-in");
61create_border_style_struct!(BorderTopStyle, "bor-s-t");
62create_border_style_struct!(BorderBottomStyle, "bor-s-b");
63create_border_style_struct!(BorderLeftStyle, "bor-s-l");
64create_border_style_struct!(BorderRightStyle, "bor-s-r");
65
66macro_rules! create_border_width_struct {
67    ($property:ident, $atomic:literal) => {
68        $crate::create_property!(
69            $property,
70            display = "",
71            atomic = $atomic,
72            custom = false,
73            data_type = "<length-percentage>",
74            initial_value = Initial,
75            keywords = "",
76        );
77    };
78}
79create_border_width_struct!(BorderWidth, "bor-w");
80create_border_width_struct!(BorderBlockWidth, "bor-w-bl");
81create_border_width_struct!(BorderInlineWidth, "bor-w-in");
82create_border_width_struct!(BorderTopWidth, "bor-w-t");
83create_border_width_struct!(BorderBottomWidth, "bor-w-b");
84create_border_width_struct!(BorderLeftWidth, "bor-w-l");
85create_border_width_struct!(BorderRightWidth, "bor-w-r");
86
87#[cfg(test)]
88mod test {
89    #[test]
90    fn colors() {
91        macro_rules! test_property {
92            ($property:ident, $name:expr, $atomic:expr) => {
93                crate::test_property_initial_value!($property, CurrentColor);
94                crate::test_global_keywords!($property, $name);
95                crate::test_function_var!($property, $name);
96                #[cfg(feature = "atomic")]
97                crate::test_atomic_property!($property, $atomic);
98            };
99        }
100        test_property!(BorderColor, "border-color", "bor-c");
101        test_property!(BorderBlockColor, "border-block-color", "bor-c-bl");
102        test_property!(BorderInlineColor, "border-inline-color", "bor-c-in");
103        test_property!(BorderTopColor, "border-top-color", "bor-c-t");
104        test_property!(BorderBottomColor, "border-bottom-color", "bor-c-b");
105        test_property!(BorderLeftColor, "border-left-color", "bor-c-l");
106        test_property!(BorderRightColor, "border-right-color", "bor-c-r");
107    }
108
109    #[test]
110    fn radiuses() {
111        macro_rules! test_property {
112            ($property:ident, $name:expr, $atomic:expr) => {
113                crate::test_property_initial_value!($property, Initial);
114                crate::test_global_keywords!($property, $name);
115                crate::test_function_var!($property, $name);
116                #[cfg(feature = "atomic")]
117                crate::test_atomic_property!($property, $atomic);
118            };
119        }
120        test_property!(BorderRadius, "border-radius", "bor-r");
121        test_property!(BorderTopRadius, "--border-top-radius", "bor-r-t");
122        test_property!(BorderBottomRadius, "--border-bottom-radius", "bor-r-b");
123        test_property!(BorderLeftRadius, "--border-left-radius", "bor-r-l");
124        test_property!(BorderRightRadius, "--border-right-radius", "bor-r-r");
125        test_property!(BorderTopLeftRadius, "border-top-left-radius", "bor-r-t-l");
126        test_property!(BorderTopRightRadius, "border-top-right-radius", "bor-r-t-r");
127        #[rustfmt::skip]
128        test_property!(BorderBottomLeftRadius, "border-bottom-left-radius", "bor-r-b-l");
129        #[rustfmt::skip]
130        test_property!(BorderBottomRightRadius, "border-bottom-right-radius", "bor-r-b-r");
131    }
132
133    #[test]
134    fn style() {
135        macro_rules! test_property {
136            ($property:ident, $name:expr, $atomic:expr) => {
137                crate::test_property_initial_value!($property, None);
138                crate::test_global_keywords!($property, $name);
139                crate::test_global_keywords!($property, $name);
140                crate::test_function_var!($property, $name);
141                #[cfg(feature = "atomic")]
142                $crate::test_atomic_property!($property, $atomic);
143            };
144        }
145        test_property!(BorderStyle, "border-style", "bor-s");
146        test_property!(BorderBlockStyle, "border-block-style", "bor-s-bl");
147        test_property!(BorderInlineStyle, "border-inline-style", "bor-s-in");
148        test_property!(BorderTopStyle, "border-top-style", "bor-s-t");
149        test_property!(BorderBottomStyle, "border-bottom-style", "bor-s-b");
150        test_property!(BorderLeftStyle, "border-left-style", "bor-s-l");
151        test_property!(BorderRightStyle, "border-right-style", "bor-s-r");
152    }
153
154    #[test]
155    fn widths() {
156        macro_rules! test_property {
157            ($property:ident, $name:expr, $atomic:expr) => {
158                crate::test_property_initial_value!($property, Initial);
159                crate::test_global_keywords!($property, $name);
160                crate::test_function_var!($property, $name);
161                #[cfg(feature = "atomic")]
162                crate::test_atomic_property!($property, $atomic);
163            };
164        }
165        test_property!(BorderWidth, "border-width", "bor-w");
166        test_property!(BorderBlockWidth, "border-block-width", "bor-w-bl");
167        test_property!(BorderInlineWidth, "border-inline-width", "bor-w-in");
168        test_property!(BorderTopWidth, "border-top-width", "bor-w-t");
169        test_property!(BorderBottomWidth, "border-bottom-width", "bor-w-b");
170        test_property!(BorderLeftWidth, "border-left-width", "bor-w-l");
171        test_property!(BorderRightWidth, "border-right-width", "bor-w-r");
172    }
173}