Skip to content

Commit

Permalink
fix: correctly color legend at the top (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
kilianc authored May 22, 2024
1 parent 17d7b5c commit 9e4a20d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
26 changes: 13 additions & 13 deletions assets/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,20 @@ body {
padding: 0 16px;
}
}
}
}

.cov-covered {
color: var(--covered);
background-color: color-mix(in srgb, var(--covered) 10%, transparent);
}
.cov-covered {
color: var(--covered);
background-color: color-mix(in srgb, var(--covered) 10%, transparent);
}

.cov-uncovered {
color: var(--uncovered);
background-color: color-mix(in srgb, var(--uncovered) 20%, transparent);
}
.cov-uncovered {
color: var(--uncovered);
background-color: color-mix(in srgb, var(--uncovered) 20%, transparent);
}

.cov-mixed {
color: var(--mixed);
background-color: color-mix(in srgb, var(--mixed) 10%, transparent);
}
}
.cov-mixed {
color: var(--mixed);
background-color: color-mix(in srgb, var(--mixed) 10%, transparent);
}
14 changes: 14 additions & 0 deletions assets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function main() {
}

// setup the layout
configureLegend()
configureFileSelect()
addIncrementalButton()
addThemeButton()
Expand All @@ -42,6 +43,19 @@ function main() {
document.documentElement.style.setProperty('opacity', '1')
}

function configureLegend() {
let spans = document.querySelectorAll('#legend span')
for (let i = 0; i < spans.length; i++) {
if (spans[i].classList.length === 0) continue

if (spans[i].classList[0] === 'cov0') {
spans[i].classList.add('cov-uncovered')
} else {
spans[i].classList.add('cov-covered')
}
}
}

function addCoverageSpans(cssSelector) {
let spans = Array.from(document.querySelectorAll(`${cssSelector} span`))

Expand Down

0 comments on commit 9e4a20d

Please sign in to comment.