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

Function simpleColorScale

packages/@react-spectrum/s2/style/tokens.ts:92–103  ·  view source on GitHub ↗
(
  scale: S
)

Source from the content-addressed store, hash-verified

90}
91
92export 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
105function extractOpacity(color: string): number {
106 return Number(color.match(/^rgba\(\d+, \d+, \d+, ([.\d]+)\)$/)?.[1] ?? 1);

Callers 1

spectrum-theme.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected