Skip to content

Commit

Permalink
feat: add px, py, pt, pb, pl, pr, and m_ plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed Aug 19, 2022
1 parent 2cbbad0 commit 11e1297
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/parse/literal.rs
Expand Up @@ -42,7 +42,19 @@ pub fn parse_literal<'a>(theme: &TailwindTheme, s: &'a str) -> Result<ObjectLit,
"h" => plugin::h,
"w" => plugin::w,
"p" => plugin::p,
"px" => plugin::px,
"pl" => plugin::pl,
"pr" => plugin::pr,
"py" => plugin::py,
"pt" => plugin::pt,
"pb" => plugin::pb,
"m" => plugin::m,
"mx" => plugin::mx,
"ml" => plugin::ml,
"mr" => plugin::mr,
"my" => plugin::my,
"mt" => plugin::mt,
"mb" => plugin::mb,
"z" => plugin::z,
_ => return Err(s),
};
Expand Down
60 changes: 60 additions & 0 deletions src/plugin.rs
Expand Up @@ -281,10 +281,70 @@ pub fn p(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
simple_lookup(&theme.spacing, rest, "padding")
}

pub fn px(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
theme
.spacing
.get(rest)
.map(|s| to_lit(&[("paddingLeft", s), ("paddingRight", s)]))
}

pub fn pl(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
simple_lookup(&theme.spacing, rest, "paddingLeft")
}

pub fn pr(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
simple_lookup(&theme.spacing, rest, "paddingRight")
}

pub fn py(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
theme
.spacing
.get(rest)
.map(|s| to_lit(&[("paddingTop", s), ("paddingBottom", s)]))
}

pub fn pt(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
simple_lookup(&theme.spacing, rest, "paddingTop")
}

pub fn pb(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
simple_lookup(&theme.spacing, rest, "paddingBottom")
}

pub fn m(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
simple_lookup(&theme.spacing, rest, "margin")
}

pub fn mx(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
theme
.spacing
.get(rest)
.map(|s| to_lit(&[("marginLeft", s), ("marginRight", s)]))
}

pub fn ml(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
simple_lookup(&theme.spacing, rest, "marginLeft")
}

pub fn mr(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
simple_lookup(&theme.spacing, rest, "marginRight")
}

pub fn my(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
theme
.spacing
.get(rest)
.map(|s| to_lit(&[("marginTop", s), ("marginBottom", s)]))
}

pub fn mt(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
simple_lookup(&theme.spacing, rest, "marginTop")
}

pub fn mb(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
simple_lookup(&theme.spacing, rest, "marginBottom")
}

pub fn z(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
simple_lookup(&theme.z_index, rest, "z-index")
}

0 comments on commit 11e1297

Please sign in to comment.