Metadata diff
ProThe change as files: one tab per file, each named by the thing it is (a field, a layout) as well as its path, with a unified diff that highlights the exact words that changed inside a line.
Preview
Install
With the Candor CLI
First time? Get started sets up the registry and theme. Or with shadcn directly: npx shadcn@latest add @candor/metadata-diff
Brings in: entity-chip, locale, work, utils · npm: lucide-react@^1.67.0, radix-ui@^1.8.1
Usage
"use client"
import type { FileDiff } from "@/lib/work"
import { ChangeDiff } from "@/components/metadata-diff"
const files: FileDiff[] = [
{
path: "db/migrations/0142_add_customer_region.sql",
entity: { kind: "migration", name: "0142_add_customer_region", label: "Add customers.region" },
change: "create",
language: "sql",
hunks: [
{
lines: [
{ kind: "add", text: "CREATE TYPE region AS ENUM ('us', 'eu', 'apac', 'other');", newNo: 1 },
{ kind: "add", text: "ALTER TABLE customers ADD COLUMN region region;", newNo: 2 },
{ kind: "add", text: "CREATE INDEX customers_region_idx ON customers (region);", newNo: 3 },
],
},
],
},
{
path: "web/src/customers/CustomerHeader.tsx",
entity: { kind: "component", name: "web/src/customers/CustomerHeader.tsx", label: "CustomerHeader" },
change: "update",
language: "tsx",
hunks: [
{
header: "@@ function CustomerHeader @@",
lines: [
{ kind: "context", text: ' <Fact label="Plan" value={customer.plan} />', oldNo: 43, newNo: 43 },
{ kind: "remove", text: ' <Fact label="Partner tier" value={customer.partnerTierOld} />', oldNo: 44 },
{ kind: "add", text: ' <Fact label="Region" value={regionLabel(customer.region)} />', newNo: 44 },
{ kind: "context", text: " </dl>", oldNo: 45, newNo: 45 },
],
},
],
},
]
export default function Example() {
return <ChangeDiff className="max-w-3xl" files={files} />
}<ChangeDiff>
| Prop | Type | Default | Description |
|---|---|---|---|
| filesrequired | FileDiff[] | — | The changed files, one tab each. |
| className | string | undefined | — | Extra classes for the outer element. |
Strings
The fixed words, in English by default. Change any of them under metadataDiff in <LocaleProvider strings={{ … }}>; the table is exported as metadataDiffStrings.
| Key | English |
|---|---|
| label | Changes |
| files | { one: "{count} file", other: "{count} files" } |
| fileTabs | Files |
| create | New |
| update | Changed |
| delete | Deleted |
| added | Added: |
| removed | Removed: |