Skip to main content

Diff viewer

Structured schema changes or a unified text diff.

Guidance​

The diff viewer shows what changed between two versions of an asset. In columns mode it is a table of schema changes: each row says what happened in a word with a glyph ("+ Added", "− Removed", "± Type changed") and shows the before and after types in mono. Added rows carry a faint moss tint and removed rows a faint crimson tint, always with the word, never colour alone. Unchanged columns fold behind a "Show unchanged columns" button.

In text mode it is a unified line diff of two texts (DDL, YAML, a pipeline config) on mm-surface, with old and new line numbers and + and − gutters; runs of unchanged lines beyond context fold behind buttons that expand them in place. Long lines scroll sideways, or wrap with wrap.

The header is a sentence-case caption of the comparison ("Schema version 41 → 42 · 3 changes") with who or what made the change and when. Column names, types and diff lines stay mono.

The fold buttons are ordinary buttons with aria-expanded: Tab reaches them, and Enter or Space toggles them.

Properties​

PropertyAttributeTypeDefaultDescription
modemode'columns' | 'text''columns'columns (structured schema changes) or text (unified line diff).
oldColumnsDiffColumn[][]Columns of the older version (columns mode).
newColumnsDiffColumn[][]Columns of the newer version (columns mode).
changesSchemaChange[] | undefinedPrecomputed changes. Overrides oldColumns and newColumns.
oldTextold-textstring''Older text (text mode).
newTextnew-textstring''Newer text (text mode).
subjectsubjectstring''What is being compared, for the readout. Defaults to "Schema version".
fromVersionfrom-versionstring''
toVersionto-versionstring''
changedAtchanged-atstring''When the newer version was recorded (ISO 8601).
actoractorstring''Who or what made the change: "Jane Doe", "postgresql plugin".
actorKindactor-kind'person' | 'plugin' | 'agent''person'person, plugin or agent; picks the icon.
contextcontextnumber3Unchanged lines kept around each change in text mode.
wrapwrapbooleanfalseWrap long lines in text mode instead of scrolling.
labellabelstring''Accessible name of the table, e.g. "Changes to shop.public.orders".

CSS parts​

PartDescription
headerThe comparison caption and actor line.
tableThe changes or lines table.

CSS custom properties​

PropertyDescription
--mm-diff-max-heightHeight at which the text diff scrolls. Defaults to none.

Examples​

Every state of mm-diff-viewer in Storybook, with keyboard and screen reader tests.