Skip to content

Commit 6e8f61e

Browse files
committed
manage diagram visibility
1 parent 4b1bfae commit 6e8f61e

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

scaladoc/resources/dotty_res/scripts/ux.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,16 @@ window.addEventListener("DOMContentLoaded", () => {
121121

122122

123123
// when document is loaded graph needs to be shown
124-
showGraph();
125124
});
126125

127126
var zoom;
128127
var transform;
129128

130129
function showGraph() {
130+
document.getElementById("inheritance-diagram").classList.add("shown")
131131
if ($("svg#graph").children().length == 0) {
132132
var dotNode = document.querySelector("#dot")
133+
133134
if (dotNode) {
134135
var svg = d3.select("#graph");
135136
var radialGradient = svg.append("defs").append("radialGradient").attr("id", "Gradient");
@@ -202,6 +203,10 @@ function showGraph() {
202203
}
203204
}
204205

206+
function hideGraph() {
207+
document.getElementById("inheritance-diagram").classList.remove("shown")
208+
}
209+
205210
function zoomOut() {
206211
var svg = d3.select("#graph");
207212
svg
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
11
.diagram-class {
22
position: relative;
33
}
4+
5+
#inheritance-diagram > button:nth-of-type(1) {
6+
display: none;
7+
position: absolute;
8+
right: 0;
9+
}
10+
11+
#inheritance-diagram > button:nth-of-type(2) {
12+
display: none;
13+
position: absolute;
14+
right: calc(13 * var(--base-spacing));
15+
}
16+
17+
#inheritance-diagram.shown > button:nth-of-type(3) {
18+
display: none;
19+
}
20+
21+
#inheritance-diagram.shown > button:nth-of-type(1) {
22+
display: block;
23+
}
24+
25+
#inheritance-diagram.shown > button:nth-of-type(2) {
26+
display: block;
27+
}
28+
29+
#graph {
30+
display: none;
31+
}
32+
33+
#inheritance-diagram.shown #graph {
34+
display: block;
35+
width: 100%;
36+
height: calc(50 * var(--base-spacing));
37+
}

scaladoc/src/dotty/tools/scaladoc/renderers/MemberRenderer.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ class MemberRenderer(signatureRenderer: SignatureRenderer)(using DocContext) ext
349349
case graph if graph.edges.nonEmpty =>
350350
Seq(div( id := "inheritance-diagram", cls := "diagram-class showGraph")(
351351
button(`type` := "button", cls := "label-only-button", onclick := "zoomOut()")("Reset zoom"),
352+
button(`type` := "button", cls := "label-only-button", onclick := "hideGraph()")("Hide graph"),
353+
button(`type` := "button", cls := "label-only-button", onclick := "showGraph()")("Show graph"),
352354
svg(id := "graph"),
353355
script(`type` := "text/dot", id := "dot")(
354356
raw(DotDiagramBuilder.build(graph, signatureRenderer))

0 commit comments

Comments
 (0)