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

Function CodeClient

packages/dev/s2-docs/src/CodeClient.tsx:21–45  ·  view source on GitHub ↗
({tokens}: CodeClientProps)

Source from the content-addressed store, hash-verified

19}
20
21export function CodeClient({tokens}: CodeClientProps) {
22 let i = 0;
23 let children: ReactNode[] = [];
24 while (i < tokens.length) {
25 let value = tokens[i++];
26 if (typeof value === 'number') {
27 // A number represents a token type. The following value is its children.
28 let type = value;
29 value = tokens[i++];
30 let child = Array.isArray(value) ? <CodeClient tokens={value} /> : value;
31 children.push(
32 <span key={i} className={styles[type]}>
33 {child}
34 </span>
35 );
36 } else if (Array.isArray(value)) {
37 // A nested array of tokens.
38 children.push(<CodeClient key={i} tokens={value} />);
39 } else {
40 children.push(value);
41 }
42 }
43
44 return children;
45}

Callers

nothing calls this directly

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected