Skip to content

Commit

Permalink
feat: add transparency to text plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed May 21, 2023
1 parent 09d7853 commit b71861a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 14 additions & 9 deletions crates/tailwind-parse/src/eval/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,8 @@ array_plugin!(
["left", "center", "right", "justify", "start", "end"],
"textAlign"
);
lookup_plugin_arbitrary!(text_color, colors, "color");
lookup_color_plugin_arbitrary!(text_color, colors, "color", "--tw-text-opacity");
lookup_plugin_arbitrary!(text_size, font_size, "fontSize", |t| t.0.to_string());
merge_plugins!(text_base, arb text_color, arb text_size);

array_plugin!(appearance, ["none"], "appearance");

Expand Down Expand Up @@ -411,13 +410,19 @@ pub fn transform_origin<'a>(Value(rest): &Value, _theme: &'a TailwindTheme) -> P
}
}

pub fn text<'a>(value: &SubjectValue, theme: &'a TailwindTheme) -> PluginResult<'a> {
text_base(value, theme).or_else(|e| match value {
SubjectValue::Value(v) => {
text_align(v, theme).map_err(|e2| e.into_iter().chain(e2).collect())
}
SubjectValue::Css(_) => Err(e),
})
pub fn text<'a>(
value: &SubjectValue,
theme: &'a TailwindTheme,
alpha: Option<&Value>,
) -> PluginResult<'a> {
text_color(value, theme, alpha)
.or_else(|_| text_size(value, theme))
.or_else(|e| match value {
SubjectValue::Value(v) => {
text_align(v, theme).map_err(|e2| e.into_iter().chain(e2).collect())
}
SubjectValue::Css(_) => Err(e),
})
}

pub fn space<'a>(Value(rest): &Value, theme: &'a TailwindTheme) -> PluginResult<'a> {
Expand Down
2 changes: 1 addition & 1 deletion crates/tailwind-parse/src/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl<'a> Literal<'a> {
Auto(Auto::Rows) => RequiredArbitrary(plugin::auto_rows),

// all other plugins
Text => RequiredArbitrary(plugin::text),
Text => RequiredArbitraryTransparency(plugin::text),
Font => Required(plugin::font),
Shadow => Optional(plugin::shadow),
Transition => Optional(plugin::transition),
Expand Down

0 comments on commit b71861a

Please sign in to comment.