Skip to content

Commit

Permalink
feat: add italic plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed Nov 30, 2022
1 parent 0d92ef5 commit 7bb1acc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/tailwind-parse/src/eval/plugin.rs
Expand Up @@ -714,6 +714,10 @@ pub fn justify(Value(rest): &Value, _theme: &TailwindTheme) -> Option<ObjectLit>
.map(|v| to_lit(&[("justifyContent", v)]))
}

pub fn italic() -> Option<ObjectLit> {
Some(to_lit(&[("fontStyle", "italic")]))
}

pub fn items(Value(rest): &Value, _theme: &TailwindTheme) -> Option<ObjectLit> {
match *rest {
"start" => Some("flex-start"),
Expand Down
3 changes: 3 additions & 0 deletions crates/tailwind-parse/src/literal.rs
Expand Up @@ -47,6 +47,7 @@ impl<'a> LiteralConversionError<'a> {
}

enum PluginType {
Singular(fn() -> Option<ObjectLit>),
Required(fn(&Value, &TailwindTheme) -> Option<ObjectLit>),
Optional(fn(Option<&Value>, &TailwindTheme) -> Option<ObjectLit>),
RequiredArbitrary(fn(&SubjectValue, &TailwindTheme) -> Option<ObjectLit>),
Expand Down Expand Up @@ -147,6 +148,7 @@ impl<'a> Literal<'a> {
Grow => Optional(plugin::grow),
Shrink => Optional(plugin::shrink),
Basis => Required(plugin::basis),
Italic => Singular(plugin::italic),
Justify => Required(plugin::justify),
Items => Required(plugin::items),
Gap(None) => Required(plugin::gap),
Expand Down Expand Up @@ -209,6 +211,7 @@ impl<'a> Literal<'a> {
(Optional(p), None) => p(None, theme),
(RequiredArbitrary(p), Some(value)) => p(value, theme),
(OptionalArbitrary(p), value) => p(value.as_ref(), theme),
(Singular(p), None) => p(),
_ => None,
}
.ok_or_else(|| LiteralConversionError::new(self.cmd, self.value))
Expand Down
2 changes: 2 additions & 0 deletions crates/tailwind-parse/src/plugin.rs
Expand Up @@ -107,6 +107,7 @@ mod plugin {
Space,
Transform,
Opacity,
Italic,
Blur,
Ring,
Sr,
Expand All @@ -123,6 +124,7 @@ mod plugin {
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum Not {
Prose,
Italic,
}

#[derive(Copy, Clone, Eq, PartialEq, Debug)]
Expand Down

0 comments on commit 7bb1acc

Please sign in to comment.