Files
TheWitness e29581b68a Make package/diff viewer colors theme-aware (#8093)
* Make package/diff viewer colors theme-aware

The jfcherng/php-diff Inline renderer output is styled by each theme's
Diff.css, but every theme shipped an identical copy that hard-coded a
light palette (color: black, background: #fff, opaque #fbe1e1/#e1fbe1
add/remove tints). Inside the diff dialog this painted a light box with
dark text over dark themes (dark, sunrise, paper-plane) and over
midwinter's dark color-mode, so the modal did not match the theme.

Derive the base surface from the themed dialog instead of hard-coding it
(color: inherit, background: transparent, neutral translucent borders and
gutters) and express the add/remove/replace highlights as translucent
rgba overlays that read correctly on both light and dark surfaces. Light
themes render essentially as before; dark themes now inherit their dark
surface and light text. Applied to every theme so the shared stylesheet
stays identical.

* Band diff code columns on dark themes

On the dark themes the unchanged (context) code column and the
line-number gutter read too similarly, making the actual diff on the
right hard to pick out. Give the context old/new code cells a subtle
dark band (rgba(0,0,0,.25)) so the code reads as a panel distinct from
the lighter line-number gutter. Applied to dark, sunrise and paper-plane;
for midwinter the band is scoped to its dark color-mode only. Light
themes are unchanged.
2026-09-28 15:21:51 -04:00

123 lines
3.5 KiB
CSS

.diff-wrapper.diff {
--tab-size: 4;
background: transparent;
border-collapse: collapse;
border-spacing: 0;
border: 1px solid rgba(127, 127, 127, 0.5);
color: inherit;
empty-cells: show;
font-family: monospace;
font-size: 13px;
width: 100%;
word-break: break-all;
}
.diff-wrapper.diff th {
font-weight: 700;
cursor: default;
-webkit-user-select: none;
user-select: none;
}
.diff-wrapper.diff td {
vertical-align: baseline;
}
.diff-wrapper.diff td,
.diff-wrapper.diff th {
border-collapse: separate;
border: none;
padding: 1px 2px;
background: transparent;
}
.diff-wrapper.diff td:empty:after,
.diff-wrapper.diff th:empty:after {
content: " ";
visibility: hidden;
}
.diff-wrapper.diff td a,
.diff-wrapper.diff th a {
color: inherit;
cursor: inherit;
pointer-events: none;
}
.diff-wrapper.diff thead th {
background: rgba(127, 127, 127, 0.28);
border-bottom: 1px solid rgba(127, 127, 127, 0.5);
padding: 4px;
text-align: left;
}
.diff-wrapper.diff tbody.skipped {
border-top: 1px solid rgba(127, 127, 127, 0.5);
}
.diff-wrapper.diff tbody.skipped td,
.diff-wrapper.diff tbody.skipped th {
display: none;
}
.diff-wrapper.diff tbody th {
background: rgba(127, 127, 127, 0.15);
border-right: 1px solid rgba(127, 127, 127, 0.5);
text-align: right;
vertical-align: top;
width: 4em;
}
.diff-wrapper.diff tbody th.sign {
background: transparent;
border-right: none;
padding: 1px 0;
text-align: center;
width: 1em;
}
.diff-wrapper.diff tbody th.sign.del {
background: rgba(200, 60, 60, 0.22);
}
.diff-wrapper.diff tbody th.sign.ins {
background: rgba(70, 180, 80, 0.22);
}
.diff-wrapper.diff.diff-html {
white-space: pre-wrap;
tab-size: var(--tab-size);
}
.diff-wrapper.diff.diff-html .ch {
line-height: 1em;
background-clip: border-box;
background-repeat: repeat-x;
background-position: left center;
}
.diff-wrapper.diff.diff-html .ch.sp {
background-image: url('data:image/svg+xml,%3Csvg preserveAspectRatio="xMinYMid meet" viewBox="0 0 12 24" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath d="M4.5 11C4.5 10.1716 5.17157 9.5 6 9.5C6.82843 9.5 7.5 10.1716 7.5 11C7.5 11.8284 6.82843 12.5 6 12.5C5.17157 12.5 4.5 11.8284 4.5 11Z" fill="rgba%2860, 60, 60, 50%25%29"/%3E%3C/svg%3E');
background-size: 1ch 1.25em;
}
.diff-wrapper.diff.diff-html .ch.tab {
background-image: url('data:image/svg+xml,%3Csvg preserveAspectRatio="xMinYMid meet" viewBox="0 0 12 24" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath d="M9.5 10.44L6.62 8.12L7.32 7.26L12.04 11V11.44L7.28 14.9L6.62 13.9L9.48 11.78H0V10.44H9.5Z" fill="rgba%2860, 60, 60, 50%25%29"/%3E%3C/svg%3E');
background-size: calc(var(--tab-size) * 1ch) 1.25em;
background-position: 2px center;
}
.diff-wrapper.diff.diff-html .change.change-eq .old,
.diff-wrapper.diff.diff-html .change.change-eq .new {
background: transparent;
}
.diff-wrapper.diff.diff-html .change .old {
background: rgba(200, 60, 60, 0.22);
}
.diff-wrapper.diff.diff-html .change .new {
background: rgba(70, 180, 80, 0.22);
}
.diff-wrapper.diff.diff-html .change .rep {
background: rgba(210, 170, 40, 0.22);
}
.diff-wrapper.diff.diff-html .change .old.none,
.diff-wrapper.diff.diff-html .change .new.none,
.diff-wrapper.diff.diff-html .change .rep.none {
background: transparent;
cursor: not-allowed;
}
.diff-wrapper.diff.diff-html .change ins,
.diff-wrapper.diff.diff-html .change del {
font-weight: bold;
text-decoration: none;
}
.diff-wrapper.diff.diff-html .change ins {
background: rgba(70, 180, 80, 0.45);
}
.diff-wrapper.diff.diff-html .change del {
background: rgba(200, 60, 60, 0.45);
}