1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
6pub enum Size {
7 Xs,
8 Sm,
9 #[default]
10 Md,
11 Lg,
12 Xl,
13}
14
15impl Size {
16 pub fn label(self) -> &'static str {
18 match self {
19 Size::Xs => "xs",
20 Size::Sm => "sm",
21 Size::Md => "md",
22 Size::Lg => "lg",
23 Size::Xl => "xl",
24 }
25 }
26}
27
28#[derive(Debug, Clone, Copy)]
30pub struct Scale {
31 pub xs: f32,
32 pub sm: f32,
33 pub md: f32,
34 pub lg: f32,
35 pub xl: f32,
36}
37
38impl Scale {
39 pub const fn new(xs: f32, sm: f32, md: f32, lg: f32, xl: f32) -> Self {
40 Scale { xs, sm, md, lg, xl }
41 }
42
43 pub fn get(&self, size: Size) -> f32 {
45 match size {
46 Size::Xs => self.xs,
47 Size::Sm => self.sm,
48 Size::Md => self.md,
49 Size::Lg => self.lg,
50 Size::Xl => self.xl,
51 }
52 }
53
54 pub fn spacing() -> Self {
55 Scale::new(10.0, 12.0, 16.0, 20.0, 32.0)
56 }
57
58 pub fn radius() -> Self {
59 Scale::new(2.0, 4.0, 8.0, 16.0, 32.0)
60 }
61
62 pub fn font_size() -> Self {
63 Scale::new(12.0, 14.0, 16.0, 18.0, 20.0)
64 }
65}