( scale: S )
| 90 | } |
| 91 | |
| 92 | export function simpleColorScale<S extends string>( |
| 93 | scale: S |
| 94 | ): Record<Extract<TokenName, `${S}-${number}`>, string> { |
| 95 | let res: any = {}; |
| 96 | let re = new RegExp(`^${scale}-\\d+$`); |
| 97 | for (let token in tokens) { |
| 98 | if (re.test(token)) { |
| 99 | res[token] = (tokens as any)[token].value; |
| 100 | } |
| 101 | } |
| 102 | return res; |
| 103 | } |
| 104 | |
| 105 | function extractOpacity(color: string): number { |
| 106 | return Number(color.match(/^rgba\(\d+, \d+, \d+, ([.\d]+)\)$/)?.[1] ?? 1); |