tailwind_css_fixes/modules/borders/ring/ring_width/
mod.rs

1use crate::NumericValue;
2
3use super::*;
4
5#[doc=include_str!("readme.md")]
6#[derive(Clone, Debug)]
7pub struct TailwindRingWidth {
8    kind: NumericValue,
9}
10
11impl Display for TailwindRingWidth {
12    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
13        write!(f, "ring-offset-{}", self.kind)
14    }
15}
16
17impl TailwindInstance for TailwindRingWidth {
18    fn attributes(&self, _: &TailwindBuilder) -> CssAttributes {
19        css_attributes! {
20            "--tw-ring-offset-width" => self.kind,
21            "box-shadow" => "0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color), var(--tw-ring-shadow)"
22        }
23    }
24}
25impl TailwindRingWidth {
26    /// <https://tailwindcss.com/docs/ring-width>
27    pub fn parse(pattern: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
28        let kind = match pattern {
29            [] => NumericValue::from(3u32),
30            _ => NumericValue::positive_parser("blur", Self::check_valid)(pattern, arbitrary)?,
31        };
32        Ok(Self { kind })
33    }
34    /// https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit#syntax
35    pub fn check_valid(mode: &str) -> bool {
36        ["inherit", "initial", "revert", "unset"].contains(&mode)
37    }
38}