| 1 | // Generated from vendor/codewhale-design/tokens.json 1.1.2 by tests/generated.rs. |
| 2 | // Do not edit. Regenerate: CODEWHALE_BLESS=1 cargo test --test generated |
| 3 | |
| 4 | /// The design tokens version these roles were generated from. |
| 5 | pub const TOKENS_VERSION: &str = "1.1.2"; |
| 6 | |
| 7 | /// What a color is for. Components name roles; they never name colors. |
| 8 | /// Names follow `tokens.json`, so one vocabulary covers the desktop app, |
| 9 | /// the web and the terminal. Four roles the tokens do not name are |
| 10 | /// derived from ones they do ([`Role::is_derived`]). |
| 11 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] |
| 12 | pub enum Role { |
| 13 | /// The deepest ground: rails and things put away. |
| 14 | Sidebar, |
| 15 | /// The stage. |
| 16 | Background, |
| 17 | /// A raised panel. |
| 18 | Surface, |
| 19 | /// A row under the pointer. |
| 20 | Hover, |
| 21 | /// The selected row. |
| 22 | Selected, |
| 23 | /// Body ink. |
| 24 | Foreground, |
| 25 | /// Ink that recedes: details, verbs in hints, asides. |
| 26 | Muted, |
| 27 | /// Quiet lines that separate. |
| 28 | Border, |
| 29 | /// Edges that identify a control or a decision. |
| 30 | BorderStrong, |
| 31 | /// Actions, focus and links. |
| 32 | Primary, |
| 33 | /// Ink on a `Primary` ground. |
| 34 | PrimaryForeground, |
| 35 | /// Work happening now, and work done. |
| 36 | Live, |
| 37 | /// Needs you. |
| 38 | Attention, |
| 39 | /// Failed or destructive. |
| 40 | Danger, |
| 41 | /// Ink one step quieter than `Muted`: asides and placeholders. Derived: `muted_foreground` receded toward `background` until it just holds 4.5:1 on every ground. |
| 42 | Hint, |
| 43 | /// The quietest ink: disabled and decorative words, never the only carrier of meaning. Derived: `muted_foreground` receded toward `background` until it just holds 3:1 on every ground. |
| 44 | Dim, |
| 45 | /// Ground behind an added line, under `Foreground` ink. Derived: `live` at 16% over `background`. |
| 46 | DiffAddedTint, |
| 47 | /// Ground behind a removed line, under `Foreground` ink. Derived: `danger` at 16% over `background`. |
| 48 | DiffRemovedTint, |
| 49 | } |
| 50 | |
| 51 | impl Role { |
| 52 | pub const COUNT: usize = 18; |
| 53 | pub const ALL: [Role; Self::COUNT] = [ |
| 54 | Role::Sidebar, |
| 55 | Role::Background, |
| 56 | Role::Surface, |
| 57 | Role::Hover, |
| 58 | Role::Selected, |
| 59 | Role::Foreground, |
| 60 | Role::Muted, |
| 61 | Role::Border, |
| 62 | Role::BorderStrong, |
| 63 | Role::Primary, |
| 64 | Role::PrimaryForeground, |
| 65 | Role::Live, |
| 66 | Role::Attention, |
| 67 | Role::Danger, |
| 68 | Role::Hint, |
| 69 | Role::Dim, |
| 70 | Role::DiffAddedTint, |
| 71 | Role::DiffRemovedTint, |
| 72 | ]; |
| 73 | |
| 74 | /// The `tokens.json` key this role reads, or `None` for a role the |
| 75 | /// kit derives from other tokens ([`Role::is_derived`]). |
| 76 | #[must_use] |
| 77 | pub const fn token_name(self) -> Option<&'static str> { |
| 78 | match self { |
| 79 | Role::Sidebar => Some("sidebar"), |
| 80 | Role::Background => Some("background"), |
| 81 | Role::Surface => Some("surface"), |
| 82 | Role::Hover => Some("hover"), |
| 83 | Role::Selected => Some("selected"), |
| 84 | Role::Foreground => Some("foreground"), |
| 85 | Role::Muted => Some("muted_foreground"), |
| 86 | Role::Border => Some("border"), |
| 87 | Role::BorderStrong => Some("border_strong"), |
| 88 | Role::Primary => Some("primary"), |
| 89 | Role::PrimaryForeground => Some("primary_foreground"), |
| 90 | Role::Live => Some("live"), |
| 91 | Role::Attention => Some("attention"), |
| 92 | Role::Danger => Some("danger"), |
| 93 | Role::Hint => None, |
| 94 | Role::Dim => None, |
| 95 | Role::DiffAddedTint => None, |
| 96 | Role::DiffRemovedTint => None, |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | /// Position in [`Role::ALL`] and in the color tables. |
| 101 | #[must_use] |
| 102 | pub const fn index(self) -> usize { |
| 103 | self as usize |
| 104 | } |
| 105 | |
| 106 | /// Whether the kit derives this role from other tokens, because |
| 107 | /// `tokens.json` does not name it. |
| 108 | #[must_use] |
| 109 | pub const fn is_derived(self) -> bool { |
| 110 | matches!(self, Role::Hint | Role::Dim | Role::DiffAddedTint | Role::DiffRemovedTint) |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | /// dark token colors, `0xRRGGBB`, indexed by [`Role::index`]. |
| 115 | pub(crate) const DARK: [u32; Role::COUNT] = [ |
| 116 | 0x191a1c, // Sidebar |
| 117 | 0x202123, // Background |
| 118 | 0x2a2b2e, // Surface |
| 119 | 0x303134, // Hover |
| 120 | 0x37393d, // Selected |
| 121 | 0xefeeeb, // Foreground |
| 122 | 0xc2c1bd, // Muted |
| 123 | 0x3b3c3f, // Border |
| 124 | 0x828386, // BorderStrong |
| 125 | 0x90b9ff, // Primary |
| 126 | 0x15243e, // PrimaryForeground |
| 127 | 0x9ec7b2, // Live |
| 128 | 0xe8b077, // Attention |
| 129 | 0xe39a90, // Danger |
| 130 | 0xa3a3a0, // Hint |
| 131 | 0x838381, // Dim |
| 132 | 0x343c3a, // DiffAddedTint |
| 133 | 0x3f3434, // DiffRemovedTint |
| 134 | ]; |
| 135 | |
| 136 | /// dark xterm 256-color indices (16..=255 only; 0..=15 belong to the |
| 137 | /// user's profile). Nearest index, except where contrast needed a move: |
| 138 | /// - dark danger: 174 -> 210 (nearest failed its contrast floor) |
| 139 | /// - dark hint: 247 -> 248 (nearest failed its contrast floor) |
| 140 | /// - dark dim: 244 -> 245 (nearest failed its contrast floor) |
| 141 | /// - dark diff_added_tint: 237 -> 22 (the cube has no tint this faint; nearest index that keeps the hue of live) |
| 142 | /// - dark diff_removed_tint: 237 -> 52 (the cube has no tint this faint; nearest index that keeps the hue of danger) |
| 143 | pub(crate) const DARK_256: [u8; Role::COUNT] = [ |
| 144 | 234, // Sidebar |
| 145 | 235, // Background |
| 146 | 236, // Surface |
| 147 | 236, // Hover |
| 148 | 237, // Selected |
| 149 | 255, // Foreground |
| 150 | 250, // Muted |
| 151 | 237, // Border |
| 152 | 102, // BorderStrong |
| 153 | 111, // Primary |
| 154 | 235, // PrimaryForeground |
| 155 | 151, // Live |
| 156 | 180, // Attention |
| 157 | 210, // Danger |
| 158 | 248, // Hint |
| 159 | 245, // Dim |
| 160 | 22, // DiffAddedTint |
| 161 | 52, // DiffRemovedTint |
| 162 | ]; |
| 163 | |
| 164 | /// light token colors, `0xRRGGBB`, indexed by [`Role::index`]. |
| 165 | pub(crate) const LIGHT: [u32; Role::COUNT] = [ |
| 166 | 0xf0ede8, // Sidebar |
| 167 | 0xfaf8f5, // Background |
| 168 | 0xffffff, // Surface |
| 169 | 0xe8e5e0, // Hover |
| 170 | 0xdfdcd6, // Selected |
| 171 | 0x28292b, // Foreground |
| 172 | 0x535451, // Muted |
| 173 | 0xd9d5cf, // Border |
| 174 | 0x807c76, // BorderStrong |
| 175 | 0x245bc7, // Primary |
| 176 | 0xfbf5ee, // PrimaryForeground |
| 177 | 0x3a6352, // Live |
| 178 | 0x86520d, // Attention |
| 179 | 0x9e3f36, // Danger |
| 180 | 0x60615e, // Hint |
| 181 | 0x7d7d7a, // Dim |
| 182 | 0xdbe0db, // DiffAddedTint |
| 183 | 0xebdad6, // DiffRemovedTint |
| 184 | ]; |
| 185 | |
| 186 | /// light xterm 256-color indices (16..=255 only; 0..=15 belong to the |
| 187 | /// user's profile). Nearest index, except where contrast needed a move: |
| 188 | /// - light primary: 26 -> 25 (nearest failed its contrast floor) |
| 189 | /// - light live: 239 -> 23 (nearest lost its hue) |
| 190 | /// - light attention: 94 -> 58 (nearest failed its contrast floor) |
| 191 | /// - light danger: 131 -> 124 (nearest failed its contrast floor) |
| 192 | /// - light dim: 244 -> 243 (nearest failed its contrast floor) |
| 193 | /// - light border_strong: 244 -> 242 (nearest failed its contrast floor) |
| 194 | /// - light diff_added_tint: 253 -> 158 (the cube has no tint this faint; nearest index that keeps the hue of live) |
| 195 | /// - light diff_removed_tint: 253 -> 224 (the cube has no tint this faint; nearest index that keeps the hue of danger) |
| 196 | pub(crate) const LIGHT_256: [u8; Role::COUNT] = [ |
| 197 | 255, // Sidebar |
| 198 | 231, // Background |
| 199 | 231, // Surface |
| 200 | 254, // Hover |
| 201 | 253, // Selected |
| 202 | 235, // Foreground |
| 203 | 239, // Muted |
| 204 | 188, // Border |
| 205 | 242, // BorderStrong |
| 206 | 25, // Primary |
| 207 | 255, // PrimaryForeground |
| 208 | 23, // Live |
| 209 | 58, // Attention |
| 210 | 124, // Danger |
| 211 | 59, // Hint |
| 212 | 243, // Dim |
| 213 | 158, // DiffAddedTint |
| 214 | 224, // DiffRemovedTint |
| 215 | ]; |
| 216 | |
| 217 | /// The blue ombre (`Ground::Ocean`): the dark table with its grounds and |
| 218 | /// quiet line tinted 0.5 toward `LOGO_BOTTOM` at their own luminance, |
| 219 | /// so every contrast floor holds. The diff tints are re-mixed over its own |
| 220 | /// background. Truecolor only; 256 colors use `DARK_256`. |
| 221 | pub(crate) const OCEAN: [u32; Role::COUNT] = [ |
| 222 | 0x06183c, // Sidebar |
| 223 | 0x0a1f47, // Background |
| 224 | 0x122957, // Surface |
| 225 | 0x162f60, // Hover |
| 226 | 0x1b376b, // Selected |
| 227 | 0xefeeeb, // Foreground |
| 228 | 0xc2c1bd, // Muted |
| 229 | 0x1e3a70, // Border |
| 230 | 0x828386, // BorderStrong |
| 231 | 0x90b9ff, // Primary |
| 232 | 0x15243e, // PrimaryForeground |
| 233 | 0x9ec7b2, // Live |
| 234 | 0xe8b077, // Attention |
| 235 | 0xe39a90, // Danger |
| 236 | 0xa3a3a0, // Hint |
| 237 | 0x838381, // Dim |
| 238 | 0x223a58, // DiffAddedTint |
| 239 | 0x2d3353, // DiffRemovedTint |
| 240 | ]; |
| 241 |