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
use crate::syntax_error;
use super::*;
pub(crate) mod stroke_color;
pub(crate) mod stroke_width;
#[derive(Clone, Debug)]
pub struct TailwindStroke {}
impl TailwindStroke {
pub fn parse(str: &[&str], arbitrary: &TailwindArbitrary) -> Result<Box<dyn TailwindInstance>> {
let color = |color| TailwindStrokeColor::from(color).boxed();
let out = match str {
["current"] => color(TailwindColor::Current),
["transparent"] => color(TailwindColor::Transparent),
["inherit"] => color(TailwindColor::Inherit),
["black"] => color(TailwindColor::Black),
["white"] => color(TailwindColor::White),
["color"] => {
debug_assert!(arbitrary.is_some());
color(TailwindColor::parse_arbitrary(arbitrary)?)
},
["color", rest] => {
let a = TailwindArbitrary::from(*rest);
color(TailwindColor::parse_arbitrary(&a)?)
},
[theme, weight] => color(TailwindColor::parse_themed(theme, weight)?),
[n] => maybe_width(n)?,
_ => return syntax_error!("Unknown decoration instructions: {}", str.join("-")),
};
Ok(out)
}
}
fn maybe_width(s: &str) -> Result<Box<dyn TailwindInstance>> {
Ok(TailwindStrokeWidth::try_new(s)?.boxed())
}