Skip to content

Commit

Permalink
feat: make outline OptionalArbitrary
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed Jan 19, 2023
1 parent 9c00ec9 commit 0321871
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions crates/tailwind-parse/src/eval/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,22 +440,24 @@ pub fn truncate() -> ObjectLit {
])
}

lookup_plugin_arbitrary!(outline_offset, outline_offset, "outlineOffset");
lookup_plugin_arbitrary!(outline_width, outline_width, "outlineWidth");

lookup_plugin_arbitrary!(aspect, aspect_ratio, "aspectRatio");

pub fn outline<'a>(rest: Option<&Value>, theme: &'a TailwindTheme) -> PluginResult<'a> {
pub fn outline<'a>(rest: &Option<SubjectValue>, theme: &'a TailwindTheme) -> PluginResult<'a> {
match rest {
None => Ok(to_lit(&[("outlineStyle", "solid")])),
Some(Value("none")) => Ok(to_lit(&[
Some(SubjectValue::Value(Value("none"))) => Ok(to_lit(&[
("outline", "2px solid transparent"),
("outlineOffset", "2px"),
])),
Some(Value("dashed")) => Ok(to_lit(&[("outlineStyle", "dashed")])),
Some(Value("dotted")) => Ok(to_lit(&[("outlineStyle", "dotted")])),
Some(Value("double")) => Ok(to_lit(&[("outlineStyle", "double")])),
Some(Value("hidden")) => Ok(to_lit(&[("outlineStyle", "hidden")])),
Some(rest) => simple_lookup(&theme.colors, rest.0, "outlineColor")
.or_else(|_e| simple_lookup(&theme.outline_offset, rest.0, "outlineOffset"))
.or_else(|_e| simple_lookup(&theme.outline_width, rest.0, "outlineWidth")),
Some(SubjectValue::Value(Value("dashed"))) => Ok(to_lit(&[("outlineStyle", "dashed")])),
Some(SubjectValue::Value(Value("dotted"))) => Ok(to_lit(&[("outlineStyle", "dotted")])),
Some(SubjectValue::Value(Value("double"))) => Ok(to_lit(&[("outlineStyle", "double")])),
Some(SubjectValue::Value(Value("hidden"))) => Ok(to_lit(&[("outlineStyle", "hidden")])),
Some(SubjectValue::Value(rest)) => simple_lookup(&theme.colors, rest.0, "outlineColor"),
Some(rest) => outline_offset(rest, theme).or_else(|_e| outline_width(rest, theme)),
}
}

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 @@ -133,8 +133,8 @@ impl<'a> Literal<'a> {
Order => Required(plugin::order),
From => Required(plugin::from),
To => Required(plugin::to),
Outline => Optional(plugin::outline),
Aspect => RequiredArbitrary(plugin::aspect),
Outline => OptionalArbitrary(plugin::outline),
Mix => Required(plugin::mix),
Content => RequiredArbitrary(plugin::content),
Grow => Optional(plugin::grow),
Expand Down

0 comments on commit 0321871

Please sign in to comment.