Skip to content

Commit

Permalink
fix line height and add details
Browse files Browse the repository at this point in the history
  • Loading branch information
owickstrom committed Aug 26, 2024
1 parent c362a0b commit 329d842
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 23 deletions.
26 changes: 24 additions & 2 deletions index.css
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,26 @@ img, video {
object-fit: contain;
}

details {
border: var(--border-thickness) solid var(--text-color);
padding: calc(var(--line-height) - var(--border-thickness)) 1ch;
}

summary {
font-weight: 600;
margin-bottom: var(--line-height);
}

details ::marker {
display: inline-block;
content: '►';
margin: 0;
}

details :last-child {
margin-bottom: 0;
}

pre {
white-space: pre;
overflow-x: auto;
Expand Down Expand Up @@ -245,7 +265,7 @@ li {
padding: 0;
}

::marker {
li::marker {
line-height: 0;
}

Expand Down Expand Up @@ -275,7 +295,7 @@ input, button, textarea {
input[type=checkbox] {
display: inline-grid;
place-content: center;
vertical-align: middle;
vertical-align: top;
width: 2ch;
height: var(--line-height);
cursor: pointer;
Expand Down Expand Up @@ -323,6 +343,8 @@ button:active {
label {
display: block;
width: calc(round(down, 100%, 1ch));
height: auto;
line-height: var(--line-height);
font-weight: 600;
margin: 0;
}
Expand Down
11 changes: 10 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,16 @@ <h2 id="the-basics">The Basics</h2>
it’s just markup. This, for instance, is a regular paragraph.</p>
<p>Look at this horizontal break:</p>
<hr>
<p>Lovely.</p>
<p>Lovely. We can hide stuff in the <code>&lt;details</code>&gt;
element:</p>
<details>
<summary>
A short summary of the contents
</summary>
<p>
Hidden gems.
</p>
</details>
<h2 id="lists">Lists</h2>
<p>This is a plain old bulleted list:</p>
<ul class="incremental">
Expand Down
28 changes: 9 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,16 @@ function setRatios() {
setRatios();

function checkOffsets() {
const targetNode = document.body;
const config = { childList: true, subtree: true };

const callback = () => {
const elements = document.querySelectorAll("body :not(.debug-grid, .debug-toggle)");
for (const element of elements) {
const offset = element.offsetTop % 10;
if(element.offsetParent == document.body && offset > 0) {
element.classList.add("off-grid");
console.error("Incorrect vertical offset:", element, element.offsetTop % 20);
} else {
element.classList.remove("off-grid");
}
const elements = document.querySelectorAll("body :not(.debug-grid, .debug-toggle)");
for (const element of elements) {
const offset = element.offsetTop % 10;
if(element.offsetParent == document.body && offset > 0) {
element.classList.add("off-grid");
console.error("Incorrect vertical offset:", element, element.offsetTop % 20);
} else {
element.classList.remove("off-grid");
}
};

callback();

const observer = new MutationObserver(callback);
observer.observe(targetNode, config);
}
}

const debugToggle = document.querySelector(".debug-toggle");
Expand Down
7 changes: 6 additions & 1 deletion index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ Look at this horizontal break:

<hr>

Lovely.
Lovely. We can hide stuff in the `<details`> element:

<details>
<summary>A short summary of the contents</summary>
<p>Hidden gems.</p>
</details>

## Lists

Expand Down

0 comments on commit 329d842

Please sign in to comment.