logo
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use super::*;
use tailwind_error::TailwindError;

impl TailwindOpacity {
    /// https://tailwindcss.com/docs/opacity
    pub fn parse(input: &[&str], arbitrary: &str) -> Result<Self> {
        debug_assert!(arbitrary.is_empty(), "forbidden arbitrary in duration");
        match input {
            [n] => Ok(Self { opacity: parse_usize(n)? }),
            _ => syntax_error!("Unknown opacity instructions: {}", input.join("-")),
        }
    }
}

impl TailwindBlendMode {}

impl FromStr for TailwindBlendMode {
    type Err = TailwindError;

    fn from_str(s: &str) -> Result<Self> {
        let out = match s {
            "normal" => Self::Normal,
            _ => return syntax_error!("mode error"),
        };
        Ok(out)
    }
}

impl TailwindBlend {
    #[inline]
    pub fn new(mode: &str, is_background: bool) -> Self {
        let mode = mode.parse().expect("???");
        Self { kind: TailwindBlendKind::new(is_background), mode }
    }
}

impl TailwindBlendKind {
    #[inline]
    pub fn new(is_background: bool) -> Self {
        match is_background {
            true => Self::Background,
            false => Self::Normal,
        }
    }
}

impl TailwindBlendMode {
    pub fn parse(input: &[&str], arbitrary: &str) -> Result<Self> {
        todo!()
    }
}

impl TailwindShadow {
    pub fn parse_box(input: &[&str], arbitrary: &str) -> Result<Self> {
        todo!()
    }
    pub fn parse_drop(input: &[&str], arbitrary: &str) -> Result<Self> {
        todo!()
    }
    pub fn parse_arbitrary(arbitrary: &str) -> Result<Self> {
        todo!()
    }
}

#[inline(always)]
fn parse_usize(deg: &str) -> Result<usize> {
    Ok(parse_integer(deg)?.1)
}