diff --git a/CHANGELOG.md b/CHANGELOG.md index dac8e368e..891aef8fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/lib/output/themes/default/assets/typedoc/Hierarchy.ts b/src/lib/output/themes/default/assets/typedoc/Hierarchy.ts index 038f7bb54..45ca360ee 100644 --- a/src/lib/output/themes/default/assets/typedoc/Hierarchy.ts +++ b/src/lib/output/themes/default/assets/typedoc/Hierarchy.ts @@ -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; @@ -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( @@ -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")); diff --git a/static/style.css b/static/style.css index bb51d4b99..499bc2840 100644 --- a/static/style.css +++ b/static/style.css @@ -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;