Skip to content

Commit

Permalink
feat: add truncate plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed Nov 3, 2022
1 parent 7ca223a commit eb143cf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/tailwind-parse/src/lib.rs
Expand Up @@ -63,6 +63,7 @@ mod plugin {
Divide(Option<Divide>),
Rotate,
Appearance,
Truncate,
Pointer,
Ease,
Order,
Expand Down
1 change: 1 addition & 0 deletions src/parse/literal.rs
Expand Up @@ -104,6 +104,7 @@ pub fn parse_literal<'a>(theme: &TailwindTheme, lit: Literal<'a>) -> Result<Obje
Inset(Some(Inset::X)) => Required(plugin::inset_x),
Inset(Some(Inset::Y)) => Required(plugin::inset_y),
Leading => Required(plugin::leading),
Truncate => Optional(plugin::truncate),
};

match (plugin, lit.value) {
Expand Down
8 changes: 8 additions & 0 deletions src/plugin.rs
Expand Up @@ -288,6 +288,14 @@ pub fn text_decoration(
)]))
}

pub fn truncate(_rest: Option<&str>, _theme: &TailwindTheme) -> Option<ObjectLit> {
Some(to_lit(&[
("overflow", "hidden"),
("textOverflow", "ellipsis"),
("whiteSpace", "nowrap"),
]))
}

pub fn appearance(rest: &str, _theme: &TailwindTheme) -> Option<ObjectLit> {
(rest == "none").then_some(to_lit(&[("appearance", "none")]))
}
Expand Down

0 comments on commit eb143cf

Please sign in to comment.