Skip to content

Commit

Permalink
feat: add auto plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed Dec 26, 2022
1 parent fe9f20d commit 4c24526
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
20 changes: 20 additions & 0 deletions crates/tailwind-parse/src/eval/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ lookup_plugin!(basis, flex_basis, "flexBasis");
lookup_plugin_opt!(grow, flex_grow, "flexGrow");
lookup_plugin_opt!(shrink, flex_shrink, "flexShrink");
lookup_plugin_arbitrary!(top, height, "top");
array_map_plugin!(
auto_rows,
[
("auto", "auto"),
("min", "min-content"),
("max", "max-content"),
("fr", "minmax(0, 1fr)")
],
"gridAutoRows"
);
array_map_plugin!(
auto_cols,
[
("auto", "auto"),
("min", "min-content"),
("max", "max-content"),
("fr", "minmax(0, 1fr)")
],
"gridAutoColumns"
);
lookup_plugin!(opacity, opacity, "opacity");
lookup_plugin!(animation, animation, "animation");
lookup_plugin!(order, order, "order");
Expand Down
4 changes: 4 additions & 0 deletions crates/tailwind-parse/src/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl<'a> Literal<'a> {
_span: Span,
theme: &'a TailwindTheme,
) -> Result<ObjectLit, LiteralConversionError<'a>> {
use crate::Auto;
use crate::Gap;
use crate::Inset;
use crate::Max;
Expand Down Expand Up @@ -98,6 +99,9 @@ impl<'a> Literal<'a> {
Overflow(o) => RequiredBox(StdBox::new(move |v, t| plugin::overflow(o, v, t))),
Not(_) => todo!(),

Auto(Auto::Cols) => Required(plugin::auto_cols),
Auto(Auto::Rows) => Required(plugin::auto_rows),

// all other plugins
Text => RequiredArbitrary(plugin::text),
Font => Required(plugin::font),
Expand Down
7 changes: 7 additions & 0 deletions crates/tailwind-parse/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ mod plugin {
P,
Px,
Pl,
Auto(Auto),
Pr,
LineClamp,
Py,
Expand Down Expand Up @@ -120,6 +121,12 @@ mod plugin {
Not(Not),
}

#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum Auto {
Cols,
Rows,
}

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

0 comments on commit 4c24526

Please sign in to comment.