Skip to content

Commit

Permalink
feat: add decoration plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed May 21, 2023
1 parent 2714ce5 commit 86d4ada
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/tailwind-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ pub struct TailwindTheme<'a> {

#[serde(borrow, alias = "aspectRatio")]
pub aspect_ratio: HashMap<&'a str, &'a str>,

#[serde(borrow, alias = "textDecorationThickness")]
pub decoration_thickness: HashMap<&'a str, &'a str>,
}

#[derive(Deserialize, Debug)]
Expand Down
18 changes: 18 additions & 0 deletions crates/tailwind-parse/src/eval/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,24 @@ lookup_plugin_arbitrary!(max_h, max_height, "maxHeight");

lookup_plugin!(leading, line_height, "lineHeight");

lookup_plugin_arbitrary!(decoration_color, colors, "textDecorationColor");
lookup_plugin_arbitrary!(
decoration_thickness,
decoration_thickness,
"textDecorationThickness"
);
array_plugin!(
decoration_style,
["solid", "double", "dotted", "dashed", "wavy"],
"textDecorationStyle"
);

pub fn decoration<'a>(value: &SubjectValue, theme: &'a TailwindTheme) -> PluginResult<'a> {
decoration_color(value, theme)
.or_else(|_| decoration_thickness(value, theme))
.or_else(|_| decoration_style(value.value().expect("css consumed above"), theme))
}

array_plugin!(
align,
[
Expand Down
1 change: 1 addition & 0 deletions crates/tailwind-parse/src/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ impl<'a> Literal<'a> {
Placeholder => Required(plugin::placeholder),
Delay => RequiredArbitrary(plugin::delay),
Duration => Optional(plugin::duration),
Decoration => RequiredArbitrary(plugin::decoration),
Rotate => Required(plugin::rotate),
Appearance => Required(plugin::appearance),
Pointer => Required(plugin::pointer_events),
Expand Down
1 change: 1 addition & 0 deletions crates/tailwind-parse/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ mod plugin {
List(List),
H,
W,
Decoration,
P,
Px,
Pl,
Expand Down

0 comments on commit 86d4ada

Please sign in to comment.