Skip to content

Commit

Permalink
fix: allow optional borderWidth
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed Aug 20, 2022
1 parent d840025 commit 97b7233
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/parse/literal.rs
Expand Up @@ -28,6 +28,7 @@ pub fn parse_literal<'a>(theme: &TailwindTheme, s: &'a str) -> Result<ObjectLit,
"delay" => Required(plugin::delay),
"duration" => Optional(plugin::duration),
"ease" => Optional(plugin::ease),
"border" => Optional(plugin::border),
"rounded" => Optional(plugin::rounded),
"flex" => Required(plugin::flex),
"grid" => Required(plugin::grid),
Expand Down
12 changes: 9 additions & 3 deletions src/plugin.rs
Expand Up @@ -119,9 +119,15 @@ pub fn shadow(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
})
}

pub fn border(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
simple_lookup(&theme.colors, rest, "borderColor")
.or_else(|| simple_lookup(&theme.border_width, rest, "borderWidth"))
pub fn border(rest: Option<&str>, theme: &TailwindTheme) -> Option<ObjectLit> {
rest.and_then(|rest| simple_lookup(&theme.colors, rest, "borderColor"))
.or_else(|| {
simple_lookup(
&theme.border_width,
rest.unwrap_or("DEFAULT"),
"borderWidth",
)
})
}

pub fn flex(rest: &str, theme: &TailwindTheme) -> Option<ObjectLit> {
Expand Down

0 comments on commit 97b7233

Please sign in to comment.