Skip to content

Commit

Permalink
Minor hierarchy quality of life improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Nov 28, 2024
1 parent c2c1289 commit 5d279c3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ title: Changelog
### Bug Fixes

- Fixed automatic discovery of entry points in packages mode.
- Reverted accidental style change for hierarchy page introduced in 0.27.0
- The hierarchy Expand/Collapse link will now only appear if the hierarchies are different.
- Fixed handling of `@categoryDescription` and `@groupDescription` on module pages, #2787.

## v0.27.0 (2024-11-27)
Expand Down
30 changes: 21 additions & 9 deletions src/lib/output/themes/default/assets/typedoc/Hierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,26 @@ async function buildHierarchyToggle() {
.stream()
.pipeThrough(new DecompressionStream("gzip"));

const baseReflId = +container.dataset.refl!;
const hierarchy: JsonHierarchy = await new Response(json).json();

const collapsedHierarchy = container.querySelector("ul")!;
const expandedHierarchy = document.createElement("ul");
expandedHierarchy.classList.add("tsd-hierarchy");
buildExpandedHierarchy(expandedHierarchy, hierarchy, baseReflId);

// No point in showing the expand button if it will be the same content.
// It won't be the exact same innerHTML due to links being generated less
// intelligently here than in the theme (though they still go to the same place)
// but if there are the same number of elements in the hierarchy, there's
// no point.
if (
collapsedHierarchy.querySelectorAll("li").length ==
expandedHierarchy.querySelectorAll("li").length
) {
return;
}

const expandCollapseButton = document.createElement("span");
expandCollapseButton.classList.add("tsd-hierarchy-toggle");
expandCollapseButton.textContent = window.translations.hierarchy_expand;
Expand Down Expand Up @@ -141,14 +161,6 @@ async function buildHierarchyToggle() {
window.translations.hierarchy_expand;
}
});

const baseReflId = +container.dataset.refl!;
const hierarchy: JsonHierarchy = await new Response(json).json();

const collapsedHierarchy = container.querySelector("ul")!;
const expandedHierarchy = document.createElement("ul");
expandedHierarchy.classList.add("tsd-hierarchy");
buildExpandedHierarchy(expandedHierarchy, hierarchy, baseReflId);
}

function buildExpandedHierarchy(
Expand Down Expand Up @@ -177,7 +189,7 @@ function followHierarchy(

const item = hierarchy.reflections[id];
const container = document.createElement("li");
container.classList.add("tsd-hierarchy");
container.classList.add("tsd-hierarchy-item");

if (id === targetId) {
const text = container.appendChild(document.createElement("span"));
Expand Down
14 changes: 14 additions & 0 deletions static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,20 @@
cursor: pointer;
}

.tsd-full-hierarchy:not(:last-child) {
margin-bottom: 1em;
padding-bottom: 1em;
border-bottom: 1px solid var(--color-accent);
}
.tsd-full-hierarchy,
.tsd-full-hierarchy ul {
list-style: none;
margin: 0;
padding: 0;
}
.tsd-full-hierarchy ul {
padding-left: 1.5rem;
}
.tsd-full-hierarchy a {
padding: 0.25rem 0 !important;
font-size: 1rem;
Expand Down

0 comments on commit 5d279c3

Please sign in to comment.