Skip to content

Styling

phil/text-diff-bundle

assets/styles/text-diff.css styles a difference inside an element with the class text-diff, or under the comparison controller, and nowhere else:

WhatHow
insGreen background and text, underlined
delRed background and text, struck through
.text-diff-blockA block of a document difference, with a border on its starting side: green when added, red when removed, blue when changed, amber with a background when moved
[data-text-diff-mode="old"]Hides the insertions and the added blocks
[data-text-diff-mode="new"]Hides the deletions and the removed blocks
.text-diff-currentAn outline around the current change
[aria-pressed="true"]The button of the view shown, in bold

Insertions and deletions are told apart by their decoration as well as their colour, so that no change depends on colour alone.

Themes

The colours are custom properties, light by default and dark when the system prefers it, unless an ancestor carries data-theme="light" or data-theme="dark"; on paper they are the light ones and the outline is dropped. Each meets the WCAG AA contrast for normal text against the background it is shown on.

PropertyRole
--text-diff-inserted, --text-diff-inserted-backgroundInsertions and added blocks
--text-diff-deleted, --text-diff-deleted-backgroundDeletions and removed blocks
--text-diff-moved, --text-diff-moved-backgroundMoved blocks
--text-diff-changedThe border of changed blocks
--text-diff-focusThe outline of the current change

A page redefines any of them on :root, or on one difference:

.revision-history {
    --text-diff-inserted-background: #dff6dd;
}