tailwind_css/modules/borders/divide/divide_width/
mod.rs1use crate::NumericValue;
2
3use super::*;
4
5#[doc=include_str!("readme.md")]
6#[derive(Clone, Debug)]
7pub struct TailwindDivideWidth {
8 axis: AxisXY,
9 kind: NumericValue,
10}
11
12impl Display for TailwindDivideWidth {
13 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
14 self.axis.write_xy(f, "divide-", &self.kind)
15 }
16}
17
18impl TailwindInstance for TailwindDivideWidth {
19 fn attributes(&self, _: &TailwindBuilder) -> CssAttributes {
20 match self.axis {
21 AxisXY::X => css_attributes! {
22 "border-right-width" => format!("{}px", self.kind),
23 "border-left-width" => "0"
24 },
25 AxisXY::Y => css_attributes! {
26 "border-top-width" => "0",
27 "border-bottom-width" => format!("{}px", self.kind)
28 },
29 AxisXY::N => unreachable!(),
30 }
31 }
32}
33
34impl TailwindDivideWidth {
35 pub fn parse(input: &[&str], arbitrary: &TailwindArbitrary, axis: bool) -> Result<Self> {
37 let kind = NumericValue::positive_parser("divide-width", Self::check_valid)(input, arbitrary)?;
38 Ok(Self { axis: AxisXY::from(axis), kind })
39 }
40 pub fn check_valid(mode: &str) -> bool {
42 [
43 "none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "ridge", "inset", "outset", "inherit",
44 "initial", "revert", "unset",
45 ]
46 .contains(&mode)
47 }
48}