tailwind_css_fixes/modules/borders/divide/divide_style/
mod.rs

1use super::*;
2
3#[derive(Clone, Debug)]
4pub struct TailwindDivideStyle {
5    kind: String,
6}
7
8impl From<&str> for TailwindDivideStyle {
9    /// Creates a new TailwindDivideStyle from a style keyword like "solid".
10    fn from(style: &str) -> Self {
11        Self { kind: style.to_string() }
12    }
13}
14
15impl Display for TailwindDivideStyle {
16    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
17        write!(f, "divide-{}", self.kind)
18    }
19}
20
21impl TailwindInstance for TailwindDivideStyle {
22    fn inlineable(&self) -> bool {
23        // TailwindDivideStyle cannot be inlined bc it generates a class with a nested rule.
24        false
25    }
26
27    fn attributes(&self, _: &TailwindBuilder) -> CssAttributes {
28        // Create the inner attributes for the nested rule.
29        let inner_attrs = css_attributes! {
30            // this CSS variable can be used by other utilities.
31            "--tw-border-style" => self.kind.clone(),
32            "border-style" => self.kind.clone()
33        };
34
35        // Create the top-level object to hold the nested rule.
36        let mut top_level_attrs = CssAttributes::default();
37
38        // Insert the nested rule with the correct child selector.
39        let selector = ":where(& > :not(:last-child))".to_string();
40        top_level_attrs.insert_nested(selector, inner_attrs);
41
42        top_level_attrs
43    }
44}