Sat Apr 12 2025
Tucker McKnight
Can switch between the before and after diffs being shown side-by-side or stacked on top of each other. Also added some tasks for later.
ff579b8ae2e980b6400229ee6d930221e99af2a0
- [ ] remember the user's side-by-side/unified diff choice
- [ ] move javascript into its own file instead of being at the bottom of `_includes/main.njk`
const toggleUnifiedMode = (e) => {
const diffs = document.getElementById('diffs')
const afterDiffs = document.querySelectorAll('.diff-right')
if (e.checked) {
diffs.classList.add("unified")
afterDiffs.forEach((elem) => {
elem.classList.remove('border-start', 'ps-2')
})
}
else {
diffs.classList.remove("unified")
afterDiffs.forEach((elem) => {
elem.classList.add('border-start', 'ps-2')
})
}
}
padding: 10px 4px;
.unified {
[data-bs-theme=dark] [data-type=after] mark {
background-color: rgba(51, 247, 160, .1); /* different green for dark mode; looks better */
}
.unified .diff {
flex: auto;
flex-basis: 100%;
<div class="row ">
<div class="row my-2">
<div class="col-auto d-flex align-items-center fs-4">
<i class="bi bi-layout-split"></i>
<div class="form-check form-switch ms-2 mb-1">
<input class="form-check-input" type="checkbox" id="unifiedModeSwitch" value="unified" onchange="toggleUnifiedMode(this)" aria-label="Toggle switch for unified or side by side diff view">
</div>
<i class="bi bi-hr"></i>
</div>
</div>
<div class="row" id="diffs">
<div class="d-flex">
<div class="diff d-flex">