cosmic_theme/model/
density.rs
1use crate::Spacing;
2use serde::{Deserialize, Serialize};
3
4#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
6pub enum Density {
7 Compact,
9 Spacious,
11 #[default]
13 Standard,
14}
15
16impl From<Density> for Spacing {
17 fn from(value: Density) -> Self {
18 match value {
19 Density::Compact => Spacing {
20 space_none: 0,
21 space_xxxs: 4,
22 space_xxs: 4,
23 space_xs: 8,
24 space_s: 8,
25 space_m: 16,
26 space_l: 24,
27 space_xl: 32,
28 space_xxl: 48,
29 space_xxxl: 64,
30 },
31 Density::Spacious => Spacing {
32 space_none: 4,
33 space_xxxs: 8,
34 space_xxs: 12,
35 space_xs: 16,
36 space_s: 24,
37 space_m: 32,
38 space_l: 48,
39 space_xl: 64,
40 space_xxl: 128,
41 space_xxxl: 160,
42 },
43 Density::Standard => Spacing {
44 space_none: 0,
45 space_xxxs: 4,
46 space_xxs: 8,
47 space_xs: 12,
48 space_s: 16,
49 space_m: 24,
50 space_l: 32,
51 space_xl: 48,
52 space_xxl: 64,
53 space_xxxl: 128,
54 },
55 }
56 }
57}
58
59impl From<Spacing> for Density {
60 fn from(value: Spacing) -> Self {
61 if value.space_m.saturating_sub(16) == 0 {
62 Self::Compact
63 } else if value.space_m.saturating_sub(24) == 0 {
64 Self::Standard
65 } else {
66 Self::Spacious
67 }
68 }
69}