Skip to content

Commit 5d279c3

Browse files
committed
Minor hierarchy quality of life improvements
1 parent c2c1289 commit 5d279c3

File tree

3 files changed

+37
-9
lines changed

3 files changed

+37
-9
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ title: Changelog
77
### Bug Fixes
88

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

1214
## v0.27.0 (2024-11-27)

src/lib/output/themes/default/assets/typedoc/Hierarchy.ts

+21-9
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,26 @@ async function buildHierarchyToggle() {
112112
.stream()
113113
.pipeThrough(new DecompressionStream("gzip"));
114114

115+
const baseReflId = +container.dataset.refl!;
116+
const hierarchy: JsonHierarchy = await new Response(json).json();
117+
118+
const collapsedHierarchy = container.querySelector("ul")!;
119+
const expandedHierarchy = document.createElement("ul");
120+
expandedHierarchy.classList.add("tsd-hierarchy");
121+
buildExpandedHierarchy(expandedHierarchy, hierarchy, baseReflId);
122+
123+
// No point in showing the expand button if it will be the same content.
124+
// It won't be the exact same innerHTML due to links being generated less
125+
// intelligently here than in the theme (though they still go to the same place)
126+
// but if there are the same number of elements in the hierarchy, there's
127+
// no point.
128+
if (
129+
collapsedHierarchy.querySelectorAll("li").length ==
130+
expandedHierarchy.querySelectorAll("li").length
131+
) {
132+
return;
133+
}
134+
115135
const expandCollapseButton = document.createElement("span");
116136
expandCollapseButton.classList.add("tsd-hierarchy-toggle");
117137
expandCollapseButton.textContent = window.translations.hierarchy_expand;
@@ -141,14 +161,6 @@ async function buildHierarchyToggle() {
141161
window.translations.hierarchy_expand;
142162
}
143163
});
144-
145-
const baseReflId = +container.dataset.refl!;
146-
const hierarchy: JsonHierarchy = await new Response(json).json();
147-
148-
const collapsedHierarchy = container.querySelector("ul")!;
149-
const expandedHierarchy = document.createElement("ul");
150-
expandedHierarchy.classList.add("tsd-hierarchy");
151-
buildExpandedHierarchy(expandedHierarchy, hierarchy, baseReflId);
152164
}
153165

154166
function buildExpandedHierarchy(
@@ -177,7 +189,7 @@ function followHierarchy(
177189

178190
const item = hierarchy.reflections[id];
179191
const container = document.createElement("li");
180-
container.classList.add("tsd-hierarchy");
192+
container.classList.add("tsd-hierarchy-item");
181193

182194
if (id === targetId) {
183195
const text = container.appendChild(document.createElement("span"));

static/style.css

+14
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,20 @@
784784
cursor: pointer;
785785
}
786786

787+
.tsd-full-hierarchy:not(:last-child) {
788+
margin-bottom: 1em;
789+
padding-bottom: 1em;
790+
border-bottom: 1px solid var(--color-accent);
791+
}
792+
.tsd-full-hierarchy,
793+
.tsd-full-hierarchy ul {
794+
list-style: none;
795+
margin: 0;
796+
padding: 0;
797+
}
798+
.tsd-full-hierarchy ul {
799+
padding-left: 1.5rem;
800+
}
787801
.tsd-full-hierarchy a {
788802
padding: 0.25rem 0 !important;
789803
font-size: 1rem;

0 commit comments

Comments
 (0)