Skip to content

Commit

Permalink
feat: support content subcommands
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed Feb 20, 2023
1 parent 1b96169 commit 41b4d60
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
26 changes: 24 additions & 2 deletions crates/tailwind-parse/src/eval/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,30 @@ pub fn row<'a>(row: Option<Row>, value: &Value, theme: &'a TailwindTheme) -> Plu
}
}

pub fn content<'a>(rest: &SubjectValue, _theme: &'a TailwindTheme) -> PluginResult<'a> {
Ok(to_lit(&[("content", rest.as_str())]))
pub fn content<'a>(
c: Option<Content>,
rest: &Option<SubjectValue>,
_theme: &'a TailwindTheme,
) -> PluginResult<'a> {
let rule = match c {
None | Some(Content::None) => "content",
_ => "alignContent",
};

let value = match (c, rest) {
(None, Some(rest)) => rest.as_str(),
(Some(Content::None), None) => "none",
(Some(Content::Around), None) => "space-around",
(Some(Content::Between), None) => "space-between",
(Some(Content::Center), None) => "center",
(Some(Content::End), None) => "flex-end",
(Some(Content::Evenly), None) => "space-evenly",
(Some(Content::Start), None) => "flex-start",
(Some(Content::Baseline), None) => "baseline",
_ => return Err(vec![]),
};

Ok(to_lit(&[(rule, value)]))
}

array_map_plugin!(
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 @@ -123,6 +123,7 @@ impl<'a> Literal<'a> {
Backdrop(b) => OptionalAbitraryBox(StdBox::new(move |v, t| plugin::backdrop(b, v, t))),
Snap(s) => OptionalAbitraryBox(StdBox::new(move |v, t| plugin::snap(s, v, t))),
Scroll(s) => OptionalAbitraryBox(StdBox::new(move |v, t| plugin::scroll(s, v, t))),
Content(c) => OptionalAbitraryBox(StdBox::new(move |v, t| plugin::content(c, v, t))),

Auto(Auto::Cols) => Required(plugin::auto_cols),
Auto(Auto::Rows) => Required(plugin::auto_rows),
Expand All @@ -146,7 +147,6 @@ impl<'a> Literal<'a> {
Aspect => RequiredArbitrary(plugin::aspect),
Outline => OptionalArbitrary(plugin::outline),
Mix => Required(plugin::mix),
Content => RequiredArbitrary(plugin::content),
Grow => Optional(plugin::grow),
Shrink => Optional(plugin::shrink),
Basis => Required(plugin::basis),
Expand Down
14 changes: 13 additions & 1 deletion crates/tailwind-parse/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ mod plugin {
#[rename("align")]
VerticalAlign,
Pb,
Content,
Content(Option<Content>),
M,
Mx,
My,
Expand Down Expand Up @@ -353,6 +353,18 @@ mod plugin {
Hidden,
}

#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum Content {
None,
Center,
Start,
End,
Between,
Around,
Evenly,
Baseline,
}

#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum TextTransform {
Uppercase,
Expand Down

0 comments on commit 41b4d60

Please sign in to comment.