* Finds a color in the theme under one of the given theme keys that matches * `candidateValue`. * * The values `inherit`, `transparent` and `current` are special-cased as they * are universal and don't need to be resolved from the theme.
(
candidate: Extract<Candidate, { kind: 'functional' }>,
theme: Theme,
themeKeys: T[],
)
| 244 | * are universal and don't need to be resolved from the theme. |
| 245 | */ |
| 246 | function resolveThemeColor<T extends ThemeKey>( |
| 247 | candidate: Extract<Candidate, { kind: 'functional' }>, |
| 248 | theme: Theme, |
| 249 | themeKeys: T[], |
| 250 | ) { |
| 251 | if (process.env.NODE_ENV === 'test') { |
| 252 | if (!candidate.value) { |
| 253 | throw new Error('resolveThemeColor must be called with a named candidate') |
| 254 | } |
| 255 | |
| 256 | if (candidate.value.kind !== 'named') { |
| 257 | throw new Error('resolveThemeColor must be called with a named value') |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | let value: string | null = null |
| 262 | |
| 263 | switch (candidate.value!.value) { |
| 264 | case 'inherit': { |
| 265 | value = 'inherit' |
| 266 | break |
| 267 | } |
| 268 | case 'transparent': { |
| 269 | value = 'transparent' |
| 270 | break |
| 271 | } |
| 272 | case 'current': { |
| 273 | value = 'currentcolor' |
| 274 | break |
| 275 | } |
| 276 | default: { |
| 277 | value = theme.resolve(candidate.value!.value, themeKeys) |
| 278 | break |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | return value ? asColor(value, candidate.modifier, theme) : null |
| 283 | } |
| 284 | |
| 285 | /** |
| 286 | * The alpha and beta releases used `_` in theme keys to represent a `.`. This meant we used |
no test coverage detected