* Generates a color map for a specific mode (light or dark).
(mode: 'light' | 'dark')
| 190 | * Generates a color map for a specific mode (light or dark). |
| 191 | */ |
| 192 | function buildColorMapForMode(mode: 'light' | 'dark'): Record<string, [number, number, number]> { |
| 193 | const colorMap: Record<string, [number, number, number]> = {}; |
| 194 | |
| 195 | // Add static colors |
| 196 | colorMap['black'] = [0, 0, 0]; |
| 197 | colorMap['white'] = [255, 255, 255]; |
| 198 | |
| 199 | // Add background colors |
| 200 | for (const [name, tokenName] of Object.entries(backgroundColorTokens)) { |
| 201 | const rgb = getColorRgb(tokenName, mode); |
| 202 | if (rgb) { |
| 203 | colorMap[name] = rgb; |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | // Add text colors |
| 208 | for (const [name, tokenName] of Object.entries(textColorTokens)) { |
| 209 | const rgb = getColorRgb(tokenName, mode); |
| 210 | if (rgb) { |
| 211 | colorMap[name] = rgb; |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | // Add semantic color scales |
| 216 | for (const scale of semanticScales) { |
| 217 | for (const value of scaleValues) { |
| 218 | const tokenName = `${scale}-${value}`; |
| 219 | const displayName = `${scale.replace('-color', '')}-${value}`; |
| 220 | const rgb = getColorRgb(tokenName, mode); |
| 221 | if (rgb) { |
| 222 | colorMap[displayName] = rgb; |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | // Add global color scales |
| 228 | for (const scale of globalScales) { |
| 229 | const values = scale === 'gray' ? grayValues : standardValues; |
| 230 | for (const value of values) { |
| 231 | const tokenName = `${scale}-${value}`; |
| 232 | const rgb = getColorRgb(tokenName, mode); |
| 233 | if (rgb) { |
| 234 | colorMap[tokenName] = rgb; |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | return colorMap; |
| 240 | } |
| 241 | |
| 242 | export interface ColorHexMaps { |
| 243 | light: Record<string, [number, number, number]>; |
no test coverage detected