i don't rember

This commit is contained in:
りき萌 2023-08-21 21:12:06 +02:00
parent 782758f7e7
commit 02d2010808
9 changed files with 84 additions and 36 deletions

View file

@ -1,17 +1,11 @@
/* The tree indents shouldn't be too spaced out */
.tree ul {
padding-left: clamp(12px, 2vw, 24px);
}
/* But the first block should not be indented. */
.tree>ul {
padding-left: 0;
}
/* Make the tree have + and - instead of the default details/summary arrow */
.tree {
--tree-icon-position: 8px 50%;
--tree-icon-space: 28px;
@ -76,7 +70,7 @@
background-color: rgba(0, 0, 0, 5%);
}
.tree li.leaf {
.tree li>div {
background-image: url('../svg/leaf.svg');
background-repeat: no-repeat;
background-position: var(--tree-icon-position);
@ -157,3 +151,11 @@
padding-left: 24px;
opacity: 50%;
}
.tree :target>details>summary,
.tree :target>div {
border-bottom: 1px dashed rgba(0, 0, 0, 30%);
margin-bottom: -1px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}

View file

@ -66,3 +66,23 @@ class LinkedBranch extends HTMLLIElement {
}
customElements.define("th-linked-branch", LinkedBranch, { extends: "li" });
function expandDetailsRecursively(element) {
while (element && element.tagName != "MAIN") {
if (element.tagName == "DETAILS") {
element.open = true;
}
element = element.parentElement;
}
}
// When you click on a link, and the destination is within a <details> that is not expanded,
// expand the <details> recursively.
window.addEventListener("popstate", _ => {
let element = document.getElementById(window.location.hash.substring(1));
if (element !== undefined) {
// If the element is already loaded on the page, we're good.
expandDetailsRecursively(element);
window.location.hash = window.location.hash;
}
})