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

Function highlightDiff

packages/dev/s2-docs/src/Code.tsx:431–453  ·  view source on GitHub ↗
(code: string)

Source from the content-addressed store, hash-verified

429}
430
431function highlightDiff(code: string) {
432 let lines = code.split('\n');
433 let result: ReactNode[] = [];
434 for (let line of lines) {
435 if (line[0] === '-') {
436 result.push(
437 <span key={result.length} className={style({color: 'red-1000'})}>
438 {line}
439 </span>
440 );
441 } else if (line[0] === '+') {
442 result.push(
443 <span key={result.length} className={style({color: 'green-1000'})}>
444 {line}
445 </span>
446 );
447 } else {
448 result.push(line);
449 }
450 result.push('\n');
451 }
452 return result;
453}

Callers 1

CodeFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected