(name: string, token: string | ColorToken | ColorRef)
| 162 | // Bumps up a color token by one stop, e.g. for hover/press states. |
| 163 | let colorList = Object.keys(baseColors); |
| 164 | function nextColorStop(name: string, token: string | ColorToken | ColorRef): ColorToken { |
| 165 | if (typeof token === 'object' && token.type === 'ref') { |
| 166 | let light = nextColorStop(token.light, baseColors[token.light]); |
| 167 | let dark = nextColorStop(token.dark, baseColors[token.dark]); |
| 168 | |
| 169 | return { |
| 170 | type: 'color', |
| 171 | light: light.light, |
| 172 | dark: dark.dark, |
| 173 | forcedColors: token.forcedColors |
| 174 | }; |
| 175 | } |
| 176 | |
| 177 | let index = colorList.indexOf(name); |
| 178 | if (index === -1) { |
| 179 | throw new Error(`${name} does not support states`); |
| 180 | } |
| 181 | |
| 182 | let key = colorList[index + 1]; |
| 183 | if (key.split('-')[0] !== name.split('-')[0]) { |
| 184 | throw new Error(`${name} does not support states`); |
| 185 | } |
| 186 | |
| 187 | return resolveColorToken(baseColors[key]); |
| 188 | } |
| 189 | |
| 190 | class SpectrumColorProperty<C extends string> extends ArbitraryProperty<C> { |
| 191 | mapping: {[name in C]: string | ColorToken | ColorRef}; |
no test coverage detected