tailwind_css/systems/breakpoints/
mod.rs

1use std::collections::BTreeMap;
2
3mod traits;
4
5#[derive(Clone, Debug, Default)]
6pub struct BreakPointSystem {
7    inner: BTreeMap<String, BreakPoint>,
8}
9
10impl BreakPointSystem {
11    /// Builtin ranges
12    /// https://tailwindcss.com/docs/screens
13    pub fn builtin() -> Self {
14        let mut new = Self::default();
15        new.register("sm".to_string(), 640);
16        new.register("md".to_string(), 768);
17        new.register("lg".to_string(), 1024);
18        new.register("xl".to_string(), 1280);
19        new.register("2xl".to_string(), 1536);
20        new
21    }
22
23    #[inline]
24    pub fn register(&mut self, name: String, width: usize) -> Option<BreakPoint> {
25        self.inner.insert(name, BreakPoint { width })
26    }
27}
28
29#[derive(Clone, Debug)]
30pub struct BreakPoint {
31    /// min-width
32    /// unit: px
33    width: usize,
34}