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
use super::*;
#[doc = include_str!("readme.md")]
#[derive(Debug, Clone)]
pub struct TailwindFontFamily {
kind: FontFamily,
}
#[derive(Debug, Clone)]
enum FontFamily {
Standard(String),
Arbitrary(String),
}
impl<T> From<T> for TailwindFontFamily
where
T: Into<String>,
{
fn from(kind: T) -> Self {
Self { kind: FontFamily::Standard(kind.into()) }
}
}
impl Display for TailwindFontFamily {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match &self.kind {
FontFamily::Standard(s) => write!(f, "font-{}", s),
FontFamily::Arbitrary(s) => write!(f, "font-[{}]", s),
}
}
}
impl TailwindInstance for TailwindFontFamily {
fn attributes(&self, ctx: &TailwindBuilder) -> BTreeSet<CssAttribute> {
let family = match &self.kind {
FontFamily::Standard(s) => ctx.fonts.get_family(s),
FontFamily::Arbitrary(s) => s.to_owned(),
};
css_attributes! {
"font-family" => family
}
}
}