logo
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use super::*;

#[doc = include_str!("readme.md")]
#[derive(Copy, Clone, Debug)]
pub struct TailwindBackgroundAttachment {
    kind: AttachmentKind,
}

#[derive(Copy, Clone, Debug)]
enum AttachmentKind {
    Scroll,
    Fixed,
    Local,
    // Global(CssBehavior),
}

impl Display for AttachmentKind {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Scroll => write!(f, "scroll"),
            Self::Fixed => write!(f, "fixed"),
            Self::Local => write!(f, "local"),
        }
    }
}

impl Display for TailwindBackgroundAttachment {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(f, "bg-{}", self.kind)
    }
}

impl TailwindInstance for TailwindBackgroundAttachment {
    fn attributes(&self, _: &TailwindBuilder) -> BTreeSet<CssAttribute> {
        css_attributes! {
            "background-attachment" => self.kind
        }
    }
}

impl TailwindBackgroundAttachment {
    /// `bg-fixed`
    pub const Fixed: Self = Self { kind: AttachmentKind::Fixed };
    /// `bg-local`
    pub const Local: Self = Self { kind: AttachmentKind::Local };
    /// `bg-scroll`
    pub const Scroll: Self = Self { kind: AttachmentKind::Scroll };
}