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

Function token

packages/@react-spectrum/ai/src/tokens.macro.ts:90–107  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

88}
89
90export function token(name: string) {
91 let token = name.split('.').reduce((acc, curr) => {
92 let res = acc[curr];
93 if (res == null) {
94 throw new Error(`Token ${name} not found`);
95 }
96 return res;
97 }, tokens) as any;
98 if (token?.light && token.dark) {
99 return `light-dark(${convertColor(token.light)}, ${convertColor(token.dark)})`;
100 } else if (token?.light) {
101 return convertColor(token.light);
102 } else if (token?.dark) {
103 return convertColor(token.dark);
104 } else {
105 return convertColor(token.value ?? token);
106 }
107}
108
109export function mix(gray: string, stop: string, opacity: string) {
110 let stopColor = token(stop);

Callers 5

mixFunction · 0.70
stopsFunction · 0.70
outerBorderStopsFunction · 0.70
outerBorderStopFunction · 0.70

Calls 1

convertColorFunction · 0.70

Tested by

no test coverage detected