tailwind_css_fixes/modules/transition/ease/
mod.rs1use super::*;
2use crate::StandardValue;
3
4#[doc=include_str!("readme.md")]
5#[derive(Clone, Debug)]
6pub struct TailwindEase {
7 kind: StandardValue,
8}
9
10impl Display for TailwindEase {
11 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
12 write!(f, "ease-{}", self.kind)
13 }
14}
15
16impl TailwindInstance for TailwindEase {
18 fn attributes(&self, _: &TailwindBuilder) -> CssAttributes {
19 let value = match self.kind.to_string().as_str() {
20 "in" => "var(--ease-in)",
21 "out" => "var(--ease-out)",
22 "in-out" => "var(--ease-in-out)",
23 "linear" => "linear",
24 _ => self.kind.get_properties(),
26 };
27
28 css_attributes! {
29 "--tw-ease" => value,
30 "transition-timing-function" => value
31 }
32 }
33}
34
35
36impl TailwindEase {
37 pub fn parse(pattern: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
39 Ok(Self { kind: StandardValue::parser("ease", &Self::check_valid)(pattern, arbitrary)? })
40
41 }
42
43 pub fn parse_arbitrary(arbitrary: &TailwindArbitrary) -> Result<Self> {
46 StandardValue::parse_arbitrary(arbitrary).map(|kind| Self { kind })
47 }
48
49 pub fn check_valid(mode: &str) -> bool {
52 let set = BTreeSet::from_iter(vec![
53 "",
54 "in",
55 "in-out",
56 "out",
57 "inherit",
58 "initial",
59 "linear",
60 "revert",
61 "step-end",
62 "step-start",
63 "unset",
64 ]);
65 set.contains(mode)
66 }
67}