tailwind_css_fixes/modules/effects/box_shadow/
mod.rs1use super::*;
2
3#[derive(Clone, Debug)]
5pub struct TailwindShadow {
6 kind: StandardValue,
7 drop: Backdrop,
8}
9
10impl Display for TailwindShadow {
11 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
12 if self.drop.0 {
13 write!(f, "drop-")?;
14 }
15 match &self.kind {
16 StandardValue::Keyword(s) if s.is_empty() => write!(f, "shadow"),
17 StandardValue::Keyword(s) => write!(f, "shadow-{}", s),
18 StandardValue::Arbitrary(s) => s.write_class(f, "shadow-"),
19 }
20 }
21}
22
23impl TailwindInstance for TailwindShadow {
24 fn attributes(&self, ctx: &TailwindBuilder) -> CssAttributes {
25 let shadow = match &self.kind {
26 StandardValue::Keyword(s) if self.drop.0 => ctx.effects.get_drop_shadow(s),
28 StandardValue::Keyword(s) => ctx.effects.get_box_shadow(s),
29 StandardValue::Arbitrary(s) => s.get_properties(),
30 };
31 self.drop.get_shadow(shadow)
32 }
33}
34
35impl TailwindShadow {
36 pub fn parse(input: &[&str], arbitrary: &TailwindArbitrary, drop: bool) -> Result<Self> {
38 let kind = match input {
39 [] if arbitrary.is_some() => StandardValue::parse_arbitrary(arbitrary)?,
40 _ => StandardValue::Keyword(input.join("-")),
41 };
42 Ok(Self { kind, drop: Backdrop(drop) })
43 }
44 pub fn parse_arbitrary(arbitrary: &TailwindArbitrary, drop: bool) -> Result<Self> {
46 Ok(Self { kind: StandardValue::parse_arbitrary(arbitrary)?, drop: Backdrop(drop) })
47 }
48}