nandi/rustnimpublic Fork 0
af6e50f646055dc5b291c9e602bc9ee01874f9d6
Commits
Clone
git clone https://git.rickub.com/nandi/rustnim.git
git clone ssh://git@rickub.com/nandi/rustnim.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Add generics; transpile the part of cosmic-theme that is reachable ff34e1b · on af6e50f646055dc5b291c9e602bc9ee01874f9d6 · nandithebull · 16h ago
spacing.rs · 98 lines · 2.4 KBRust Blame HistoryRaw
 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

/// Spacing variables for the Cosmic theme
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Spacing {
    /// No spacing
    pub space_none: u16,
    /// smallest spacing that can be non-zero
    pub space_xxxs: u16,
    /// extra extra small spacing
    pub space_xxs: u16,
    /// extra small spacing
    pub space_xs: u16,
    /// small spacing
    pub space_s: u16,
    /// medium spacing
    pub space_m: u16,
    /// large spacing
    pub space_l: u16,
    /// extra large spacing
    pub space_xl: u16,
    /// extra extra large spacing
    pub space_xxl: u16,
    /// largest possible spacing
    pub space_xxxl: u16,
}

impl Default for Spacing {
    fn default() -> Self {
        Self {
            space_none: 0,
            space_xxxs: 4,
            space_xxs: 8,
            space_xs: 12,
            space_s: 16,
            space_m: 24,
            space_l: 32,
            space_xl: 48,
            space_xxl: 64,
            space_xxxl: 128,
        }
    }
}

/// Density options for the Cosmic theme
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
pub enum Density {
    /// Lower padding/spacing of elements
    Compact,
    /// Standard padding/spacing of elements
    #[default]
    Standard,
    /// Higher padding/spacing of elements
    Spacious,
}

impl From<Density> for Spacing {
    fn from(value: Density) -> Self {
        match value {
            Density::Compact => Spacing {
                space_none: 0,
                space_xxxs: 4,
                space_xxs: 4,
                space_xs: 8,
                space_s: 8,
                space_m: 16,
                space_l: 24,
                space_xl: 32,
                space_xxl: 48,
                space_xxxl: 64,
            },
            Density::Standard => Spacing::default(),
            Density::Spacious => Spacing {
                space_none: 4,
                space_xxxs: 8,
                space_xxs: 12,
                space_xs: 16,
                space_s: 24,
                space_m: 32,
                space_l: 48,
                space_xl: 64,
                space_xxl: 128,
                space_xxxl: 160,
            },
        }
    }
}

impl From<Spacing> for Density {
    fn from(value: Spacing) -> Self {
        if value.space_m.saturating_sub(16) == 0 {
            Self::Compact
        } else if value.space_m.saturating_sub(24) == 0 {
            Self::Standard
        } else {
            Self::Spacious
        }
    }
}