Skip to content

Commit c3d7b19

Browse files
committed
feat: make col plugin support arbitrary CSS
1 parent dd7656b commit c3d7b19

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

crates/tailwind-parse/src/eval/plugin.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,11 @@ pub fn white_space(
808808
Ok(to_lit(&rule))
809809
}
810810

811-
pub fn col<'a>(col: Option<Col>, value: &Value, theme: &'a TailwindTheme) -> PluginResult<'a> {
811+
pub fn col<'a>(
812+
col: Option<Col>,
813+
value: &SubjectValue,
814+
theme: &'a TailwindTheme,
815+
) -> PluginResult<'a> {
812816
match col {
813817
None => grid_col(value, theme),
814818
Some(Col::Start) => grid_col_start(value, theme),

crates/tailwind-parse/src/literal.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ enum PluginType<'a> {
5757
Optional(fn(Option<&Value>, &'a TailwindTheme) -> PluginResult<'a>),
5858
/// This plugin requires a value, or arbitrary css.
5959
RequiredArbitrary(fn(&SubjectValue, &'a TailwindTheme) -> PluginResult<'a>),
60+
RequiredArbitraryBox(Box<dyn Fn(&SubjectValue, &'a TailwindTheme) -> PluginResult<'a>>),
6061
/// This plugin takes an optional value, or arbitrary css.
61-
OptionalArbitrary(fn(&Option<SubjectValue>, &'a TailwindTheme) -> PluginResult<'a>),
62+
OptionalArbitrary(fn(Option<&SubjectValue>, &'a TailwindTheme) -> PluginResult<'a>),
6263
}
6364

6465
impl<'a> Literal<'a> {
@@ -107,7 +108,7 @@ impl<'a> Literal<'a> {
107108
Translate(tr) => {
108109
OptionalAbitraryBox(StdBox::new(move |v, t| plugin::translate(tr, v, t)))
109110
}
110-
Col(c) => RequiredBox(StdBox::new(move |v, t| plugin::col(c, v, t))),
111+
Col(c) => RequiredArbitraryBox(StdBox::new(move |v, t| plugin::col(c, v, t))),
111112
Row(r) => RequiredBox(StdBox::new(move |v, t| plugin::row(r, v, t))),
112113
Overflow(o) => RequiredBox(StdBox::new(move |v, t| plugin::overflow(o, v, t))),
113114
Not(_) => todo!(),
@@ -213,6 +214,7 @@ impl<'a> Literal<'a> {
213214
(Optional(p), Some(SubjectValue::Value(s))) => p(Some(s), theme),
214215
(Optional(p), None) => p(None, theme),
215216
(RequiredArbitrary(p), Some(value)) => p(value, theme),
217+
(RequiredArbitraryBox(p), Some(value)) => p(value, theme),
216218
(Singular(p), None) => Ok(p()),
217219
(RequiredBox(p), Some(SubjectValue::Value(value))) => p(value, theme),
218220
(OptionalAbitraryBox(p), value) => p(value, theme),

0 commit comments

Comments
 (0)