Skip to content

Commit ad6ec43

Browse files
committed
chore: use semantic css classes on tables and headers
1 parent 45d7bd7 commit ad6ec43

File tree

2 files changed

+32
-38
lines changed

2 files changed

+32
-38
lines changed

src/lib/reporters/html/pages/details.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
const headers = [
2-
"Filename",
3-
"Percent",
4-
"Threshold",
5-
"Total",
6-
"Covered",
7-
"Uncovered"
8-
];
9-
101
type Annotation = {
112
file: string;
123
line: number;
134
character: number;
145
text: string;
156
};
167

17-
type Props = {
8+
type GenerateDetailsPageContext = {
189
filename: string;
1910
sourceCode: string;
2011
totalCount: number;
@@ -30,19 +21,24 @@ export const generateDetailsPage = ({
3021
correctCount,
3122
annotations,
3223
threshold
33-
}: Props) => {
24+
}: GenerateDetailsPageContext) => {
3425
const percentage = totalCount === 0 ? 100 : (correctCount * 100) / totalCount;
3526
const percentageCoverage = percentage.toFixed(2) + "%";
3627
const isValid = percentage >= threshold;
3728

38-
return `<section style="margin-top: 3em;">
39-
<h1>
29+
return `<div style="margin-top: 3em;" class="ui container">
30+
<h1 class="ui header">
4031
<a href="/index.html">TypeScript coverage report</a>
4132
</h1>
42-
<table>
33+
<table class="ui table celled">
4334
<thead>
4435
<tr>
45-
${headers.map((header) => `<th>${header}</th>`).join("\n")}
36+
<th>Filename</th>
37+
<th>Percent</th>
38+
<th>Threshold</th>
39+
<th>Total</th>
40+
<th>Covered</th>
41+
<th>Uncovered</th>
4642
</tr>
4743
</thead>
4844
<tbody>
@@ -58,10 +54,9 @@ export const generateDetailsPage = ({
5854
</table>
5955
<textarea
6056
id="editor"
61-
value="${sourceCode}"
6257
readonly
6358
style="margin-top: 3em;"
64-
/>
59+
>${sourceCode}</textarea>
6560
<pre id="annotations" style="display: none;">
6661
${JSON.stringify(annotations)}
6762
</pre>

src/lib/reporters/html/pages/summary.ts

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { CoverageData } from "../../../getCoverage";
22

3-
const globalHeaders = ["Percent", "Threshold", "Total", "Covered", "Uncovered"];
3+
const reportHeaders = ["Percent", "Threshold", "Total", "Covered", "Uncovered"];
44

55
const headers = ["Filename", "Percent", "Total", "Covered", "Uncovered"];
66

7-
type Props = Omit<CoverageData, "anys"> & {
7+
type GenerateSummaryPageContext = Omit<CoverageData, "anys"> & {
88
threshold: number;
99
};
1010

@@ -15,39 +15,39 @@ export const generateSummaryPage = ({
1515
covered,
1616
uncovered,
1717
threshold
18-
}: Props) => {
18+
}: GenerateSummaryPageContext) => {
1919
const isSummaryValid = percentage >= threshold;
2020

2121
return `
22-
<section style="margin-top: 3em;">
23-
<h1>TypeScript coverage report</h1>
24-
<h2>Summary</h2>
25-
<table>
22+
<div style="margin-top: 3em;" class="ui container">
23+
<h1 class="ui header">TypeScript coverage report</h1>
24+
<h2 class="ui header">Summary</h2>
25+
<table class="ui table celled">
2626
<thead>
2727
<tr>
28-
${globalHeaders.map((header) => `<th>${header}</th>`).join("\n")}
28+
${reportHeaders.map((header) => `<th>${header}</th>`).join("\n")}
2929
</tr>
3030
</thead>
3131
<tbody>
3232
<tr class="${isSummaryValid ? "positive" : "negative"}">
33-
<td>${percentage.toFixed(2) + "%"}</td>
34-
<td>${threshold}%</td>
35-
<td>${total}</td>
36-
<td>${covered}</td>
37-
<td>${uncovered}</td>
33+
<td data-label="Percent">${percentage.toFixed(2) + "%"}</td>
34+
<td data-label="Threshold">${threshold}%</td>
35+
<td data-label="Total">${total}</td>
36+
<td data-label="Covered">${covered}</td>
37+
<td data-label="Uncovered">${uncovered}</td>
3838
</tr>
3939
</tbody>
4040
</table>
41-
<h2>Files</h2>
42-
<table style="margin-top: 2em;" class="sortable">
41+
<h2 class="ui header">Files</h2>
42+
<table style="margin-top: 2em" class="ui table celled sortable">
4343
<thead>
4444
<tr>
4545
${headers.map((header) => `<th>${header}</th>`).join("\n")}
4646
</tr>
4747
</thead>
4848
<tbody>
49-
${Array.from(fileCounts).map(
50-
([filename, { correctCount, totalCount }]) => {
49+
${Array.from(fileCounts)
50+
.map(([filename, { correctCount, totalCount }]) => {
5151
const percentage =
5252
totalCount === 0 ? 100 : (correctCount * 100) / totalCount;
5353
const percentageCoverage = percentage.toFixed(2) + "%";
@@ -62,10 +62,9 @@ export const generateSummaryPage = ({
6262
<td>${totalCount}</td>
6363
<td>${correctCount}</td>
6464
<td>${totalCount - correctCount}</td>
65-
</tr>
66-
`;
67-
}
68-
)}
65+
</tr>`;
66+
})
67+
.join("\n")}
6968
</tbody>
7069
</table>
7170
</section>`;

0 commit comments

Comments
 (0)