tailwind_css_fixes/modules/typography/font/font_weight/
mod.rs

1use super::*;
2
3// #[doc = include_str!("font-weight.md")]
4#[derive(Debug, Clone)]
5pub struct TailwindFontWeight {
6    weight: i32,
7}
8
9impl Display for TailwindFontWeight {
10    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
11        let text = match self.weight {
12            100 => "thin",
13            _ => return write!(f, "font-[{}]", self.weight),
14        };
15        write!(f, "font-{}", text)
16    }
17}
18
19impl TailwindInstance for TailwindFontWeight {
20    fn attributes(&self, _: &TailwindBuilder) -> CssAttributes {
21        css_attributes! {
22            "font-weight" => self.weight
23        }
24    }
25}
26
27impl TailwindFontWeight {
28    pub const THIN: Self = Self { weight: 100 };
29    pub const EXTRA_LIGHT: Self = Self { weight: 200 };
30    pub const LIGHT: Self = Self { weight: 300 };
31    pub const NORMAL: Self = Self { weight: 400 };
32    pub const MEDIUM: Self = Self { weight: 500 };
33    pub const SEMI_BOLD: Self = Self { weight: 600 };
34    pub const BOLD: Self = Self { weight: 700 };
35    pub const EXTRA_BOLD: Self = Self { weight: 800 };
36    pub const BLACK: Self = Self { weight: 900 };
37    #[inline]
38    pub fn new(weight: i32) -> Self {
39        Self { weight }
40    }
41}