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