tailwind_css_fixes/modules/layouts/aspect_ratio/
mod.rs

1use super::*;
2mod aspect;
3
4use self::aspect::Aspect;
5
6#[doc=include_str!("readme.md")]
7#[derive(Clone, Debug)]
8pub struct TailwindAspect {
9    kind: Aspect,
10}
11
12impl<T> From<T> for TailwindAspect
13where
14    T: Into<String>,
15{
16    fn from(kind: T) -> Self {
17        Self { kind: Aspect::Standard(kind.into()) }
18    }
19}
20
21impl Display for TailwindAspect {
22    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
23        write!(f, "aspect-{}", self.kind)
24    }
25}
26
27impl TailwindInstance for TailwindAspect {
28    fn attributes(&self, _: &TailwindBuilder) -> CssAttributes {
29        css_attributes! {
30            "aspect-ratio" => self.kind.get_properties()
31        }
32    }
33}
34
35impl TailwindAspect {
36    /// <https://tailwindcss.com/docs/aspect-ratio>
37    pub fn parse(pattern: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
38        Ok(Self { kind: Aspect::parse(pattern, arbitrary)? })
39    }
40    /// dispatch to [aspect-ratio](https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio)
41    pub fn parse_arbitrary(arbitrary: &TailwindArbitrary) -> Result<Self> {
42        Ok(Self { kind: Aspect::parse_arbitrary(arbitrary)? })
43    }
44    /// <https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio>
45    pub fn check_valid(mode: &str) -> bool {
46        Aspect::check_valid(mode)
47    }
48}