1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2pub enum ThemeColorKey {
3 Background,
4 Foreground,
5 Card,
6 CardForeground,
7 Popover,
8 PopoverForeground,
9 Primary,
10 PrimaryForeground,
11 Secondary,
12 SecondaryForeground,
13 Muted,
14 MutedForeground,
15 Accent,
16 AccentForeground,
17 Destructive,
18 DestructiveForeground,
19 Border,
20 Input,
21 Ring,
22 RingOffsetBackground,
23}
24
25impl ThemeColorKey {
26 pub const ALL: &'static [ThemeColorKey] = &[
27 ThemeColorKey::Background,
28 ThemeColorKey::Foreground,
29 ThemeColorKey::Card,
30 ThemeColorKey::CardForeground,
31 ThemeColorKey::Popover,
32 ThemeColorKey::PopoverForeground,
33 ThemeColorKey::Primary,
34 ThemeColorKey::PrimaryForeground,
35 ThemeColorKey::Secondary,
36 ThemeColorKey::SecondaryForeground,
37 ThemeColorKey::Muted,
38 ThemeColorKey::MutedForeground,
39 ThemeColorKey::Accent,
40 ThemeColorKey::AccentForeground,
41 ThemeColorKey::Destructive,
42 ThemeColorKey::DestructiveForeground,
43 ThemeColorKey::Border,
44 ThemeColorKey::Input,
45 ThemeColorKey::Ring,
46 ThemeColorKey::RingOffsetBackground,
47 ];
48
49 pub const fn canonical_name(self) -> &'static str {
50 match self {
51 ThemeColorKey::Background => "background",
52 ThemeColorKey::Foreground => "foreground",
53 ThemeColorKey::Card => "card",
54 ThemeColorKey::CardForeground => "card-foreground",
55 ThemeColorKey::Popover => "popover",
56 ThemeColorKey::PopoverForeground => "popover-foreground",
57 ThemeColorKey::Primary => "primary",
58 ThemeColorKey::PrimaryForeground => "primary-foreground",
59 ThemeColorKey::Secondary => "secondary",
60 ThemeColorKey::SecondaryForeground => "secondary-foreground",
61 ThemeColorKey::Muted => "muted",
62 ThemeColorKey::MutedForeground => "muted-foreground",
63 ThemeColorKey::Accent => "accent",
64 ThemeColorKey::AccentForeground => "accent-foreground",
65 ThemeColorKey::Destructive => "destructive",
66 ThemeColorKey::DestructiveForeground => "destructive-foreground",
67 ThemeColorKey::Border => "border",
68 ThemeColorKey::Input => "input",
69 ThemeColorKey::Ring => "ring",
70 ThemeColorKey::RingOffsetBackground => "ring-offset-background",
71 }
72 }
73
74 pub fn from_canonical_name(name: &str) -> Option<Self> {
75 match name {
76 "background" => Some(Self::Background),
77 "foreground" => Some(Self::Foreground),
78 "card" => Some(Self::Card),
79 "card-foreground" => Some(Self::CardForeground),
80 "popover" => Some(Self::Popover),
81 "popover-foreground" => Some(Self::PopoverForeground),
82 "primary" => Some(Self::Primary),
83 "primary-foreground" => Some(Self::PrimaryForeground),
84 "secondary" => Some(Self::Secondary),
85 "secondary-foreground" => Some(Self::SecondaryForeground),
86 "muted" => Some(Self::Muted),
87 "muted-foreground" => Some(Self::MutedForeground),
88 "accent" => Some(Self::Accent),
89 "accent-foreground" => Some(Self::AccentForeground),
90 "destructive" => Some(Self::Destructive),
91 "destructive-foreground" => Some(Self::DestructiveForeground),
92 "border" => Some(Self::Border),
93 "input" => Some(Self::Input),
94 "ring" => Some(Self::Ring),
95 "ring-offset-background" => Some(Self::RingOffsetBackground),
96 _ => None,
97 }
98 }
99}
100
101#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
102pub enum ThemeNamedColorKey {
103 White,
104 Black,
105}
106
107impl ThemeNamedColorKey {
108 pub const ALL: &'static [ThemeNamedColorKey] =
109 &[ThemeNamedColorKey::White, ThemeNamedColorKey::Black];
110
111 pub const fn canonical_name(self) -> &'static str {
112 match self {
113 ThemeNamedColorKey::White => "white",
114 ThemeNamedColorKey::Black => "black",
115 }
116 }
117
118 pub fn from_canonical_name(name: &str) -> Option<Self> {
119 match name {
120 "white" => Some(Self::White),
121 "black" => Some(Self::Black),
122 _ => None,
123 }
124 }
125}
126
127#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
128pub enum ThemeMetricKey {
129 Radius,
130 FontSize,
131 FontLineHeight,
132 MonoFontSize,
133 MonoFontLineHeight,
134}
135
136impl ThemeMetricKey {
137 pub const ALL: &'static [ThemeMetricKey] = &[
138 ThemeMetricKey::Radius,
139 ThemeMetricKey::FontSize,
140 ThemeMetricKey::FontLineHeight,
141 ThemeMetricKey::MonoFontSize,
142 ThemeMetricKey::MonoFontLineHeight,
143 ];
144
145 pub const fn canonical_name(self) -> &'static str {
146 match self {
147 ThemeMetricKey::Radius => "radius",
148 ThemeMetricKey::FontSize => "font.size",
149 ThemeMetricKey::FontLineHeight => "font.line_height",
150 ThemeMetricKey::MonoFontSize => "mono_font.size",
151 ThemeMetricKey::MonoFontLineHeight => "mono_font.line_height",
152 }
153 }
154
155 pub fn from_canonical_name(name: &str) -> Option<Self> {
156 match name {
157 "radius" => Some(Self::Radius),
158 "font.size" => Some(Self::FontSize),
159 "font.line_height" => Some(Self::FontLineHeight),
160 "mono_font.size" => Some(Self::MonoFontSize),
161 "mono_font.line_height" => Some(Self::MonoFontLineHeight),
162 _ => None,
163 }
164 }
165}