# `<llumi-code-diff>`

Side-by-side code diff: Myers line diff, then a word diff on each changed line,
with syntax colors from `<llumi-code>`'s themes. Renders in **shadow DOM**.
React: `CodeDiff` in `code-diff.react.tsx`.

## Usage

```html
<link rel="stylesheet" href="https://esm.sh/@llumi/ui@1/base.css" />
<script type="module" src="https://esm.sh/@llumi/ui@1/code-diff.mjs"></script>

<llumi-code-diff language="typescript"></llumi-code-diff>
<script>
  const diff = document.querySelector("llumi-code-diff");
  diff.oldCode = "const x = 1;";
  diff.newCode = "const y = 1;";
</script>
```

## Properties / attributes

| Name | Attr | Type | Default | Description |
|------|------|------|---------|-------------|
| `oldCode` | `old-code` | `string` | `""` | Left side (the original). |
| `newCode` | `new-code` | `string` | `""` | Right side (the modified version). |
| `language` | `language` | `string` | `""` | Prism language id (same list and aliases as `<llumi-code>`); also shown in each side's header. Empty → plain text. |
| `theme` | `theme` | `ghcolors \| oneLight \| oneDark \| dracula` | `ghcolors` | Color theme. |
| `maxSize` | `max-size` | `number \| false` | `102400` | UTF-8 byte limit for **both sides combined**. Above it nothing is diffed; a notice is shown and the copy buttons keep working. `max-size="false"` disables it. |
| `copyButton` | `copy-button` | `boolean` | `true` | One copy button per side. Disable with `copy-button="false"`. |

Rows stay aligned: a line only on one side gets an empty row on the other. Both
sides scroll together. Multi-line tokens (block comments, template strings)
keep their colors across lines.

## Events

All bubble and are composed.

| Event | Detail |
|-------|--------|
| `llumi-copy` | `{ text, side: "old" \| "new" }` |
| `llumi-copy-error` | `{ error }` |
| `llumi-code-diff-too-large` | `{ size, maxSize }` |

## Dependencies

`lit`, `diff`, `refractor` (via `<llumi-code>`'s highlighter); embeds `<llumi-copy-button>`.

## React

```tsx
import { CodeDiff } from "./code-diff.react";

<CodeDiff oldCode={before} newCode={after} language="ts" onCopy={({ side }) => track(side)} />
```

Props are the properties above, plus `onCopy({ text, side })`,
`onTooLarge({ size, maxSize })`, `ref` (the `LlumiCodeDiff` element),
`className` and `style`.
