Skip to content

Commit

Permalink
feat: add row plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed Dec 1, 2022
1 parent 217644d commit 73291ca
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/tailwind-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ pub struct TailwindTheme<'a> {

#[serde(borrow, rename = "gridTemplateRows")]
pub grid_template_rows: HashMap<&'a str, &'a str>,
#[serde(borrow, rename = "gridRow")]
pub grid_row: HashMap<&'a str, &'a str>,
#[serde(borrow, rename = "gridRowStart")]
pub grid_row_start: HashMap<&'a str, &'a str>,
#[serde(borrow, rename = "gridRowEnd")]
pub grid_row_end: HashMap<&'a str, &'a str>,
#[serde(borrow, rename = "gridTemplateColumns")]
pub grid_template_columns: HashMap<&'a str, &'a str>,
#[serde(borrow, rename = "gridColumn")]
Expand Down
8 changes: 8 additions & 0 deletions crates/tailwind-parse/src/eval/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,14 @@ pub fn col(Value(rest): &Value, theme: &TailwindTheme) -> Option<ObjectLit> {
})
}

pub fn row(Value(rest): &Value, theme: &TailwindTheme) -> Option<ObjectLit> {
simple_lookup(&theme.grid_row, rest, "gridRow").or_else(|| match rest.split_once('-') {
Some(("start", rest)) => simple_lookup(&theme.grid_row_start, rest, "gridRowStart"),
Some(("end", rest)) => simple_lookup(&theme.grid_row_end, rest, "gridRowEnd"),
_ => None,
})
}

pub fn justify(Value(rest): &Value, _theme: &TailwindTheme) -> Option<ObjectLit> {
match *rest {
"start" => Some("flex-start"),
Expand Down
1 change: 1 addition & 0 deletions crates/tailwind-parse/src/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ impl<'a> Literal<'a> {
Outline => Optional(plugin::outline),
Mix => Required(plugin::mix),
Col => Required(plugin::col),
Row => Required(plugin::row),
Grow => Optional(plugin::grow),
Shrink => Optional(plugin::shrink),
Basis => Required(plugin::basis),
Expand Down
1 change: 1 addition & 0 deletions crates/tailwind-parse/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ mod plugin {
Flex(Option<Flex>),
Grid(Option<Grid>),
Col,
Row,
Grow,
Shrink,
Basis,
Expand Down

0 comments on commit 73291ca

Please sign in to comment.