1/// The stylesheet every page of the site links, written once next to `index.html`.
2///
3/// Every colour is a token with a light and a dark value; the page follows the
4/// viewer's system setting. Covered code stays plain to read: only the 3 px stripe
5/// beside the count says it ran, and only missed lines get a background
6/// (docs/DESIGN.md, D4).
7public enum SiteStylesheet {
8 public static let fileName = "report.css"
9
10 /// One column per metric, the change beside its share: the page's Compact choice, and
11 /// the only layout phones have room for (DESIGN.md D4).
12 /// - Parameter page: the selector of the pages laid out this way.
132 private static func compactTable(_ page: String) -> String {
142 """
152 \(page) .row {
162 grid-template-columns:
172 minmax(0, 1fr) var(--bar-column,) var(--share-column) var(--change-column,)
182 var(--regions-column,) var(--regions-change-column,)
192 var(--branches-column,) var(--conditions-column,);
202 }
212 \(page) .row .missed, \(page) .row .regions-missed,
222 \(page) .columns [data-sort="missed"], \(page) .columns [data-sort="change"],
232 \(page) .columns [data-sort="regionChange"] { display: none; }
242 \(page).has-baseline .columns [data-sort="percent"],
252 \(page).has-baseline .columns [data-sort="regionPercent"] {
262 grid-column: span 2; justify-self: center;
272 }
282 /* Each change leans on its own share, away from the next metric's. */
292 \(page) .row .change, \(page) .row .regions-change { text-align: left; }
302 """
312 }
32
33 public static let contents = """
34 :root {
35 --bg: #fbfbfc; --surface: #ffffff; --fg: #1c1f23; --muted: #6a737d; --line: #e3e6ea;
36 --accent: #2f5fb3; --neutral: #f0f2f4; --target: #e8effb;
37 --hit: #2e8540; --partial: #b7791f; --miss: #c2362f;
38 --miss-soft: #fdecea; --unrun-soft: #f7d4d0;
39 --sans: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
40 --mono: ui-monospace, "SF Mono", Menlo, monospace;
41 color-scheme: light;
42 }
43 @media (prefers-color-scheme: dark) {
44 :root {
45 --bg: #15171a; --surface: #1b1e22; --fg: #e4e7eb; --muted: #8f98a3; --line: #2a2f35;
46 --accent: #7aa2ec; --neutral: #24282d; --target: #1f2a3d;
47 --hit: #5cbf72; --partial: #e0a84a; --miss: #ef6b63;
48 --miss-soft: #3a1f1e; --unrun-soft: #5c2623;
49 color-scheme: dark;
50 }
51 }
52 * { box-sizing: border-box; }
53 /* Rows set their own display, which would otherwise win over the attribute. */
54 [hidden] { display: none !important; }
55 body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--sans); }
56 a { color: var(--accent); }
57
58 .page-header {
59 position: sticky; top: 0; z-index: 2;
60 display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
61 gap: 12px 16px; padding: 16px 24px;
62 background: var(--surface); border-bottom: 1px solid var(--line);
63 }
64 .site-heading { min-width: 0; overflow-wrap: anywhere; }
65 .site-title { display: inline; margin: 0; font-size: 18px; font-weight: 600; }
66 .run { margin-left: 12px; color: var(--muted); font: 12px var(--mono); }
67 .tabs { display: flex; flex-wrap: nowrap; gap: 4px; }
68 .tabs a {
69 padding: 6px 12px; border-radius: 8px;
70 color: var(--muted); text-decoration: none; white-space: nowrap;
71 }
72 .tabs a[aria-current="page"] { color: var(--fg); background: var(--neutral); font-weight: 600; }
73 .page-header > .totals, .page-header > .path { flex-basis: 100%; }
74 .page-header .path { margin: 0; padding: 6px 0; font: 13px var(--mono); overflow-wrap: anywhere; }
75 .page-header .totals { padding: 6px 0; }
76 .totals { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
77 .percent { font-weight: 600; }
78 .percent.high { color: var(--hit); }
79 .percent.medium { color: var(--partial); }
80 .percent.low { color: var(--miss); }
81
82 /* Wide lines scroll inside main, never the page; the right padding keeps code
83 clear of the minimap. */
84 .source-page main { overflow-x: auto; padding-right: 12px; }
85 .source { border-collapse: collapse; font: 12.5px/1.6 var(--mono); min-width: 100%; }
86 .source td { padding: 0; vertical-align: top; }
87 .source td.number, .source td.count {
88 width: 1%; text-align: right; white-space: nowrap; user-select: none;
89 color: var(--muted); font-variant-numeric: tabular-nums;
90 }
91 .source td.number { padding-left: 16px; padding-right: 10px; }
92 .source td.number a { color: inherit; text-decoration: none; }
93 .source td.count { padding-right: 8px; border-right: 3px solid transparent; }
94 .source td.code { padding-left: 12px; white-space: pre; }
95 /* --header-height is set by the page script; the header wraps on narrow screens. */
96 .source tr { scroll-margin-top: calc(var(--header-height, 3rem) + 24px); }
97 .source tr.covered td.count { border-right-color: var(--hit); }
98 .source tr.partly td.count { border-right-color: var(--partial); }
99 .source tr.missed td.count { border-right-color: var(--miss); }
100 .source tr.missed td.code { background: var(--miss-soft); }
101 .source tr:target td { background: var(--target); }
102 .unrun {
103 background: var(--unrun-soft);
104 text-decoration: underline wavy var(--miss) 1px; text-underline-offset: 3px;
105 }
106
107 /* Above the sticky header, so every mark stays reachable. */
108 .minimap {
109 position: fixed; top: 0; bottom: 0; right: 0; z-index: 3; width: 10px;
110 background: var(--surface); border-left: 1px solid var(--line);
111 }
112 .minimap .mark { position: absolute; left: 1px; right: 1px; min-height: 3px; }
113 .minimap .mark.missed { background: var(--miss); }
114 .minimap .mark.partly { background: var(--partial); }
115
116 .index-page main { max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; }
117 .coverage-trend { display: block; width: 100%; max-width: 40rem; }
118 .card .coverage-trend { width: 7.5rem; margin-top: .5rem; }
119 .coverage-trend polyline { fill: none; stroke-width: 2; }
120 .trend-lines { stroke: var(--hit); fill: var(--hit); }
121 .trend-regions { stroke: var(--accent); fill: var(--accent); }
122 .trend-branches { stroke: var(--partial); fill: var(--partial); }
123 .trend-conditions { stroke: var(--fg); fill: var(--fg); }
124 .trend-gap { stroke-dasharray: 3 3; opacity: .6; }
125 .trend-unavailable { fill: var(--muted); }
126 .cards { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; margin-bottom: 20px; }
127 .cards.pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
128 .cards.counts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
129 .cards.secondary { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
130 .card { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
131 .card h2 { margin: 0 0 8px; font-size: 12px; color: var(--muted); font-weight: 500; }
132 .card .value { margin: 0; font: 600 28px/1.2 var(--mono); }
133 .card .detail { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
134 .legend, .toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
135 .legend { margin: 0; padding: 0 16px 10px; color: var(--muted); font-size: 13px; }
136 .legend .key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: -8px; }
137 .key.high, .fill.high { background: var(--hit); }
138 .key.medium, .fill.medium { background: var(--partial); }
139 .key.low, .fill.low { background: var(--miss); }
140 .toolbar { padding: 0 16px 12px; }
141 #filter {
142 width: min(320px, 100%); padding: 6px 10px; font: inherit;
143 color: var(--fg); background: var(--surface);
144 border: 1px solid var(--line); border-radius: 6px;
145 }
146 #filter:focus-visible, .columns button:focus-visible, summary:focus-visible {
147 outline: 2px solid var(--accent); outline-offset: 1px;
148 }
149
150 /* One grid for the header, module and file rows, so their columns line up. */
151 .row {
152 display: grid; align-items: center; gap: 12px;
153 grid-template-columns:
154 minmax(0, 1fr) 100px var(--share-column, 64px) 64px var(--change-column,)
155 var(--regions-column,) var(--regions-missed-column,) var(--regions-change-column,)
156 var(--branches-column,) var(--conditions-column,);
157 padding: 6px 16px; font-variant-numeric: tabular-nums;
158 }
159 .row > :not(.name):not(.bar) { text-align: right; }
160 .row .name { overflow-wrap: anywhere; }
161 .columns { border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
162 .columns button {
163 padding: 0; font: inherit; color: inherit; background: none; border: 0; cursor: pointer;
164 }
165 /* Buttons keep their own width in a grid cell, so they are placed, not aligned. */
166 .columns button { justify-self: end; white-space: nowrap; }
167 .columns button[data-sort="name"] { justify-self: start; }
168 .columns button[data-direction="ascending"]::after { content: " ↑"; }
169 .columns button[data-direction="descending"]::after { content: " ↓"; }
170 /* The share headings name their metric, and so open each metric's group of columns;
171 the wider share column sets the groups apart. */
172 .has-regions .columns [data-sort="percent"], .has-regions .columns [data-sort="regionPercent"] {
173 color: var(--fg); font-weight: 600;
174 }
175 .module { border-bottom: 1px solid var(--line); }
176 .module > summary { cursor: pointer; list-style: none; font-weight: 600; }
177 .module > summary::-webkit-details-marker, .suite > summary::-webkit-details-marker {
178 display: none;
179 }
180 .module > summary .name::before, .suite > summary::before {
181 content: "▸"; display: inline-block; width: 1em; color: var(--muted);
182 transition: transform 0.15s;
183 }
184 .module[open] > summary .name::before, .suite[open] > summary::before {
185 transform: rotate(90deg);
186 }
187 .row.file { color: var(--fg); text-decoration: none; font-size: 13px; }
188 .row.file .name { padding-left: 1em; font-family: var(--mono); font-size: 12.5px; }
189 .module > summary:hover, .row.file:hover { background: var(--target); }
190 .bar { height: 6px; border-radius: 3px; overflow: hidden; background: var(--line); }
191 /* The bar's heading shares its class, to be placed and dropped with the bars. */
192 .columns .bar { justify-self: start; height: auto; overflow: visible; background: none; }
193 .fill { display: block; height: 100%; }
194 @media (prefers-reduced-motion: reduce) { .module > summary .name::before, .suite > summary::before { transition: none; } }
195 .history-page main, .unavailable-page main { max-width: 1100px; margin: 0 auto; padding: 12px 16px 48px; }
196 .history { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
197 .history th { padding: 4px 12px 6px 0; text-align: left; color: var(--muted); font: 12px var(--sans); }
198 .history td { padding: 6px 12px 6px 0; border-top: 1px solid var(--line); vertical-align: top; }
199 .history .unavailable, .unavailable-page .reason { color: var(--muted); }
200 .unavailable-card { max-width: 720px; padding: 24px; margin-top: 16px; }
201 .unavailable-page .notice { margin: 0 0 4px; font-weight: 600; }
202 .unavailable-page .reason { margin: 0; overflow-wrap: anywhere; }
203 .history .commit { font-family: var(--mono); }
204 .history .date { white-space: nowrap; color: var(--muted); }
205 .history .subject { overflow-wrap: anywhere; }
206 .history .lines, .history .regions, .history .branches, .history .conditions { white-space: nowrap; }
207 .history .unavailable { white-space: normal; }
208 .history-chart { margin-bottom: 24px; }
209 /* The height matches the chart's viewBox, so only its width ever stretches. Visible
210 overflow keeps a grown dot whole on the outermost values and runs. */
211 .history-chart .coverage-trend { width: 100%; max-width: none; height: 160px; overflow: visible; }
212 .history-chart polyline, .trend-dot { vector-effect: non-scaling-stroke; }
213 .trend-dot { fill: none; stroke-width: 5; stroke-linecap: round; transition: stroke-width .12s; }
214 .trend-dot.trend-unavailable { stroke: var(--muted); stroke-width: 7; }
215 .trend-dot:hover { stroke-width: 9; }
216 .trend-dot.trend-unavailable:hover { stroke-width: 11; }
217 .trend-plot {
218 display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 8px;
219 padding-top: 8px; color: var(--muted); font: 11px var(--mono);
220 }
221 .trend-values { position: relative; min-width: 6ch; }
222 .trend-value { position: absolute; right: 0; transform: translateY(-50%); white-space: nowrap; }
223 .trend-area { position: relative; }
224 .trend-grid { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
225 .trend-data { position: relative; }
226 .trend-tooltip {
227 position: absolute; z-index: 1; width: max-content; max-width: 20rem; padding: 6px 8px;
228 border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg);
229 box-shadow: 0 4px 12px rgb(0 0 0 / .2); font: 12px var(--mono); white-space: pre-line;
230 pointer-events: none;
231 }
232 .trend-legend {
233 display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 0; list-style: none;
234 color: var(--muted); font-size: 12px;
235 }
236 .trend-legend li, .trend-legend label { display: flex; align-items: center; gap: 6px; }
237 .trend-legend label { position: relative; cursor: pointer; user-select: none; }
238 .trend-legend input { position: absolute; opacity: 0; pointer-events: none; }
239 .trend-legend label:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
240 .trend-legend label:has(input:not(:checked)) { opacity: .5; text-decoration: line-through; }
241 .history-chart:has([data-toggle="lines"]:not(:checked)) [data-series="lines"],
242 .history-chart:has([data-toggle="regions"]:not(:checked)) [data-series="regions"],
243 .history-chart:has([data-toggle="branches"]:not(:checked)) [data-series="branches"],
244 .history-chart:has([data-toggle="conditions"]:not(:checked)) [data-series="conditions"] {
245 display: none;
246 }
247 .swatch { width: 10px; height: 10px; border-radius: 2px; }
248 .trend-lines-swatch { background: var(--hit); }
249 .trend-regions-swatch { background: var(--accent); }
250 .trend-branches-swatch { background: var(--partial); }
251 .trend-conditions-swatch { background: var(--fg); }
252 .no-data-swatch { border-radius: 50%; background: var(--muted); }
253 .tests-page main { max-width: 1100px; margin: 0 auto; padding: 24px; }
254 .test-cards { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
255 .test-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 20px; }
256 .test-filters button, #test-search {
257 min-height: 34px; padding: 6px 12px; font: inherit; color: var(--fg);
258 background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
259 }
260 .test-filters button { cursor: pointer; }
261 .test-filters button[aria-pressed="true"] { background: var(--target); border-color: var(--accent); }
262 .failed-only {
263 display: inline-flex; align-items: center; gap: 6px; min-height: 34px;
264 margin-inline-start: 4px; padding-inline: 12px; border-inline-start: 1px solid var(--line);
265 cursor: pointer;
266 }
267 .failed-only input { margin: 0; accent-color: var(--accent); }
268 #test-search { min-width: 0; max-width: 100%; }
269 .test-group { margin-top: 24px; }
270 .test-group h2 { font-size: 15px; overflow-wrap: anywhere; }
271 .failures h2 { margin: 0 0 8px; font-size: 15px; color: var(--miss); }
272 .failure { margin-bottom: 12px; padding: 8px 12px; border-left: 3px solid var(--miss);
273 background: var(--miss-soft); }
274 .failure h3 { margin: 0; font: 600 13px var(--mono); overflow-wrap: anywhere; }
275 .failure p { margin: 4px 0 0; }
276 .failure pre { margin: 6px 0 0; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; }
277 .suite { border-bottom: 1px solid var(--line); }
278 .suite > summary {
279 padding: 6px 0; cursor: pointer; list-style: none; font-family: var(--mono);
280 }
281 .suite .count, .suite .time, .suite .reason { color: var(--muted); }
282 .suite ul { margin: 0 0 8px; padding-left: 1.5em; font: 12.5px/1.6 var(--mono); }
283 .suite li { overflow-wrap: anywhere; }
284 .suite li.failed { color: var(--miss); }
285 .suite li.skipped { color: var(--muted); }
286 /* Optional columns are tracks only on the pages that have them; an unset one
287 is an empty fallback, so it adds no track and no gap. */
288 .has-baseline { --change-column: 56px; }
289 .has-regions {
290 --bar-column: 100px; --share-column: 92px;
291 --regions-column: 92px; --regions-missed-column: 64px;
292 }
293 .has-regions.has-baseline { --regions-change-column: 56px; }
294 .has-branches { --branches-column: 112px; }
295 .has-conditions { --conditions-column: 112px; }
296 /* The change since the baseline: the sign carries the meaning, colour only echoes it. */
297 .change.up { color: var(--hit); }
298 .change.down { color: var(--miss); }
299 .change.flat, .change.new { color: var(--muted); }
300 /* Narrow windows have no room for the bars once there is more than lines. */
301 @media (min-width: 561px) and (max-width: 860px) {
302 .has-regions .row, .has-branches .row {
303 grid-template-columns:
304 minmax(0, 1fr) var(--share-column, 56px) 48px var(--change-column,)
305 var(--regions-column,) var(--regions-missed-column,) var(--regions-change-column,)
306 var(--branches-column,) var(--conditions-column,);
307 gap: 8px;
308 }
309 .has-regions .row .bar, .has-branches .row .bar { display: none; }
310 .has-regions {
311 --bar-column: initial; --share-column: 64px; --regions-column: 64px; --regions-missed-column: 48px;
312 }
313 .has-branches { --branches-column: 88px; }
314 .has-branches.has-conditions { --conditions-column: 88px; }
315 }
316 /* Regions and branches together need that room sooner, and tighter still. */
317 @media (min-width: 561px) and (max-width: 1040px) {
318 .has-regions.has-branches .row {
319 grid-template-columns:
320 minmax(0, 1fr) var(--share-column, 56px) 48px var(--change-column,)
321 var(--regions-column,) var(--regions-missed-column,) var(--regions-change-column,)
322 var(--branches-column,) var(--conditions-column,);
323 gap: 8px;
324 }
325 .has-regions.has-branches .row .bar { display: none; }
326 .has-regions.has-branches {
327 --bar-column: initial; --share-column: 64px; --regions-column: 64px;
328 --regions-missed-column: 48px; --branches-column: 72px;
329 }
330 .has-regions.has-branches.has-conditions { --conditions-column: 72px; }
331 }
332 @media (min-width: 561px) and (max-width: 700px) {
333 .has-regions.has-branches .row {
334 grid-template-columns:
335 minmax(0, 1fr) var(--share-column) var(--change-column,) var(--regions-column,)
336 var(--regions-change-column,) var(--branches-column,) var(--conditions-column,);
337 }
338 .has-regions.has-branches .row .missed, .has-regions.has-branches .row .regions-missed,
339 .has-regions.has-branches .columns [data-sort="missed"] { display: none; }
340 }
341 .compact-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; }
342 .compact-toggle input { margin: 0; accent-color: var(--accent); }
343 \(compactTable(".has-regions.compact"))
344 /* Phones retain file names, line and region coverage and the optional changes. */
345 @media (max-width: 560px) {
346 .page-header { padding: 12px 16px; }
347 .tabs a { padding: 6px 8px; }
348 .tests-page main { padding: 16px; }
349 .cards, .cards.counts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
350 .cards.counts > :last-child { grid-column: 1 / -1; }
351 .card { padding: 14px; }
352 .card .value { font-size: 24px; }
353 .row { grid-template-columns: minmax(0, 1fr) 64px; gap: 8px; padding: 8px; }
354 .has-baseline .row { grid-template-columns: minmax(0, 1fr) 64px 48px; }
355 .row .bar, .row .missed, .columns [data-sort="missed"], .row .branches, .row .conditions, .compact-toggle { display: none; }
356 \(compactTable(".index-page.has-regions"))
357 .index-page.has-regions {
358 --bar-column: initial; --share-column: 64px; --regions-column: 64px;
359 --branches-column: initial; --conditions-column: initial;
360 }
361 /* With a change beside it a share needs less: its heading spans both. */
362 .index-page.has-regions.has-baseline {
363 --share-column: 52px; --regions-column: 52px;
364 --change-column: 44px; --regions-change-column: 44px;
365 }
366 .history .date, .history .branches, .history .conditions { display: none; }
367 .trend-plot { font-size: 10px; }
368 .trend-dot { stroke-width: 3.5; }
369 }
370 """
371}