tailwind_css_fixes/modules/svg/stroke/
mod.rs1use crate::syntax_error;
2
3use super::*;
4
5pub(crate) mod stroke_color;
6pub(crate) mod stroke_width;
7
8#[derive(Clone, Debug)]
9pub struct TailwindStroke {}
10
11impl TailwindStroke {
12 pub fn parse(str: &[&str], arbitrary: &TailwindArbitrary) -> Result<Box<dyn TailwindInstance>> {
13 let color = |color| TailwindStrokeColor::from(color).boxed();
14 let out = match str {
15 ["black"] => color(TailwindColor::Black),
17 ["white"] => color(TailwindColor::White),
18 ["color"] => color(TailwindColor::parse_arbitrary(arbitrary)?),
19 ["color", rest] => {
20 let a = TailwindArbitrary::from(*rest);
21 color(TailwindColor::parse_arbitrary(&a)?)
22 },
23 [theme, weight] => color(TailwindColor::parse_themed(theme, weight)?),
25 [n] => maybe_width(n)?,
27 _ => return syntax_error!("Unknown decoration instructions: {}", str.join("-")),
28 };
29 Ok(out)
30 }
31}
32
33fn maybe_width(s: &str) -> Result<Box<dyn TailwindInstance>> {
34 Ok(TailwindStrokeWidth::try_new(s)?.boxed())
35}