MCPcopy Create free account
hub / github.com/adobe/react-spectrum / nextColorStop

Function nextColorStop

packages/@react-spectrum/s2/style/spectrum-theme.ts:164–188  ·  view source on GitHub ↗
(name: string, token: string | ColorToken | ColorRef)

Source from the content-addressed store, hash-verified

162// Bumps up a color token by one stop, e.g. for hover/press states.
163let colorList = Object.keys(baseColors);
164function 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
190class SpectrumColorProperty<C extends string> extends ArbitraryProperty<C> {
191 mapping: {[name in C]: string | ColorToken | ColorRef};

Callers 1

toCSSValueMethod · 0.85

Calls 1

resolveColorTokenFunction · 0.85

Tested by

no test coverage detected