Skip to content

Commit cce944d

Browse files
Merge pull request #19 from szymon-rd/scaladoc-fixes-part3
Scaladoc fixes part3 pt2
2 parents ad0b88e + 7883710 commit cce944d

File tree

7 files changed

+191
-66
lines changed

7 files changed

+191
-66
lines changed

scaladoc/resources/dotty_res/scripts/ux.js

+93-26
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,89 @@ function attachAllListeners() {
55
observer.disconnect()
66
}
77

8-
var elements = document.getElementsByClassName("documentableElement")
8+
var scrollPosition = sessionStorage.getItem("scroll_value");
9+
console.log(scrollPosition);
10+
if (scrollPosition) {
11+
var sideMenu = document.querySelector(".side-menu");
12+
sideMenu.scrollTo(0, scrollPosition);
13+
}
14+
15+
var elements = document.getElementsByClassName("documentableElement");
916
if (elements) {
1017
for (i = 0; i < elements.length; i++) {
11-
var expanderChild = elements[i].querySelector(".documentableElement-expander")
12-
if (elements[i].querySelector(".show-content") !== null && expanderChild !== null) {
18+
var expanderChild = elements[i].querySelector(
19+
".documentableElement-expander",
20+
);
21+
if (
22+
elements[i].querySelector(".show-content") !== null &&
23+
expanderChild !== null
24+
) {
1325
expanderChild.onclick = function (e) {
1426
if (!$(e.target).is("a") && e.fromSnippet !== true) {
15-
this.parentElement.classList.toggle("expand")
16-
this.querySelector(".show-content").classList.toggle("expand")
27+
this.parentElement.classList.toggle("expand");
28+
this.querySelector(".show-content").classList.toggle("expand");
1729
}
18-
}
30+
};
1931
}
2032
}
2133
}
2234

23-
var documentableLists = document.getElementsByClassName("documentableList")
35+
var documentableLists = document.getElementsByClassName("documentableList");
2436
if (documentableLists) {
2537
for (i = 0; i < documentableLists.length; i++) {
2638
documentableLists[i].children[0].onclick = function (e) {
2739
this.classList.toggle("expand");
2840
this.parentElement.classList.toggle("expand");
29-
}
41+
};
3042
}
3143
}
3244

33-
var memberLists = document.getElementsByClassName("tab")
45+
var memberLists = document.getElementsByClassName("tab");
3446
if (memberLists) {
3547
for (i = 0; i < memberLists.length; i++) {
3648
if ($(memberLists[i].children[0]).is("button")) {
3749
memberLists[i].children[0].onclick = function (e) {
3850
this.classList.toggle("expand");
3951
this.parentElement.classList.toggle("expand");
40-
}
52+
};
4153
}
4254
}
4355
}
56+
$(".side-menu span").on("click", function () {
57+
$(this).parent().toggleClass("expanded");
58+
});
59+
document.querySelectorAll('a').forEach(el => {
60+
const href = el.href
61+
if (href === "") { return }
62+
const url = new URL(href)
63+
el.addEventListener('click', e => {
64+
if (url.href.replace("#", "") === window.location.href.replace("#", "")) { return }
65+
if (url.origin !== window.location.origin) { return }
66+
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) { return }
67+
e.preventDefault()
68+
e.stopPropagation()
69+
$.get(href, function (data) {
70+
const html = $.parseHTML(data)
71+
const title = html.find(node => node.nodeName === "TITLE").innerText
72+
const bodyDiv = html.find(node => node.nodeName === "DIV")
73+
const { children } = document.body.firstChild
74+
if (window.history.state === null) {
75+
window.history.replaceState({
76+
leftColumn: children[3].innerHTML,
77+
mainDiv: children[6].innerHTML,
78+
title: document.title,
79+
}, '')
80+
}
81+
document.title = title
82+
const leftColumn = bodyDiv.children[3].innerHTML
83+
const mainDiv = bodyDiv.children[6].innerHTML
84+
window.history.pushState({ leftColumn, mainDiv, title }, '', href)
85+
children[3].innerHTML = leftColumn
86+
children[6].innerHTML = mainDiv
87+
attachAllListeners()
88+
})
89+
})
90+
})
4491

4592
document.querySelectorAll('a').forEach(el => {
4693
const href = el.href
@@ -75,10 +122,10 @@ function attachAllListeners() {
75122
})
76123
})
77124

78-
$(".ar").on('click', function (e) {
79-
$(this).parent().parent().toggleClass("expanded")
80-
$(this).toggleClass("expanded")
81-
e.stopPropagation()
125+
$(".ar").on("click", function (e) {
126+
$(this).parent().parent().toggleClass("expanded");
127+
$(this).toggleClass("expanded");
128+
e.stopPropagation();
82129
});
83130

84131
document.querySelectorAll(".nh").forEach(el => el.addEventListener('click', () => {
@@ -90,18 +137,38 @@ function attachAllListeners() {
90137
}
91138
}))
92139

93-
document.querySelectorAll(".supertypes").forEach(el => el.firstChild.addEventListener('click', () => {
94-
el.classList.toggle("collapsed");
95-
el.firstChild.classList.toggle("expand");
96-
}))
97-
98-
99-
document.querySelectorAll(".subtypes").forEach(el => el.firstChild.addEventListener('click', () => {
100-
el.classList.toggle("collapsed");
101-
el.firstChild.classList.toggle("expand");
102-
}))
103-
104-
observer = new IntersectionObserver(entries => {
140+
document.querySelectorAll(".supertypes").forEach((el) =>
141+
el.firstChild.addEventListener("click", () => {
142+
el.classList.toggle("collapsed");
143+
el.firstChild.classList.toggle("expand");
144+
}),
145+
);
146+
147+
document.querySelectorAll(".subtypes").forEach((el) =>
148+
el.firstChild.addEventListener("click", () => {
149+
el.classList.toggle("collapsed");
150+
el.firstChild.classList.toggle("expand");
151+
}),
152+
);
153+
154+
document.querySelectorAll(".nh").forEach((el) =>
155+
el.addEventListener("click", () => {
156+
el.lastChild.click();
157+
el.first.addClass("expanded");
158+
el.parent.addClass("expanded");
159+
}),
160+
);
161+
162+
document.querySelectorAll(".ni").forEach((link) =>
163+
link.addEventListener("mouseenter", (e) => {
164+
sessionStorage.setItem(
165+
"scroll_value",
166+
link.offsetTop - window.innerHeight / 2,
167+
);
168+
}),
169+
);
170+
171+
const observer = new IntersectionObserver(entries => {
105172
entries.forEach(entry => {
106173
const id = entry.target.getAttribute('id');
107174
if (entry.intersectionRatio > 0) {

scaladoc/resources/dotty_res/styles/theme/colors.css

+52-24
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,32 @@
33
*/
44
:root {
55
/* grey colors */
6-
--grey1: #ffffff;
7-
--grey2: #f9f8f9;
8-
--grey3: #f4f2f4;
9-
--grey4: #eeedef;
10-
--grey5: #e9e8ea;
11-
--grey6: #e4e2e4;
12-
--grey7: #dcdbdd;
13-
--grey8: #c8c7cb;
14-
--grey9: #908e96;
15-
--grey10: #86848d;
16-
--grey11: #6f6e77;
17-
--grey12: #1a1523;
6+
--grey1: #fcfcfc;
7+
--grey2: #f8f8f8;
8+
--grey3: #f3f3f3;
9+
--grey4: #ededed;
10+
--grey5: #e8e8e8;
11+
--grey6: #e2e2e2;
12+
--grey7: #dbdbdb;
13+
--grey8: #c7c7c7;
14+
--grey9: #8f8f8f;
15+
--grey10: #858585;
16+
--grey11: #6f6f6f;
17+
--grey12: #171717;
18+
19+
/* mauve colors */
20+
--mauve1: #ffffff;
21+
--mauve2: #f9f8f9;
22+
--mauve3: #f4f2f4;
23+
--mauve4: #eeedef;
24+
--mauve5: #e9e8ea;
25+
--mauve6: #e4e2e4;
26+
--mauve7: #dcdbdd;
27+
--mauve8: #c8c7cb;
28+
--mauve9: #908e96;
29+
--mauve10: #86848d;
30+
--mauve11: #6f6e77;
31+
--mauve12: #1a1523;
1832

1933
/* red colors */
2034
--red1: #fffcfc;
@@ -165,18 +179,32 @@
165179
dark theme
166180
*/
167181
:root.theme-dark {
168-
--grey1: #161618;
169-
--grey2: #1c1c1f;
170-
--grey3: #232326;
171-
--grey4: #28282c;
172-
--grey5: #2e2e32;
173-
--grey6: #34343a;
174-
--grey7: #3e3e44;
175-
--grey8: #504f57;
176-
--grey9: #706f78;
177-
--grey10: #7e7d86;
178-
--grey11: #a09fa6;
179-
--grey12: #ededef;
182+
--grey1: #161616;
183+
--grey2: #1c1c1c;
184+
--grey3: #232323;
185+
--grey4: #282828;
186+
--grey5: #2e2e2e;
187+
--grey6: #343434;
188+
--grey7: #3e3e3e;
189+
--grey8: #505050;
190+
--grey9: #707070;
191+
--grey10: #7e7e7e;
192+
--grey11: #a0a0a0;
193+
--grey12: #ededed;
194+
195+
/* muave colors */
196+
--mauve1: #161618;
197+
--mauve2: #1c1c1f;
198+
--mauve3: #232326;
199+
--mauve4: #28282c;
200+
--mauve5: #2e2e32;
201+
--mauve6: #34343a;
202+
--mauve7: #3e3e44;
203+
--mauve8: #504f57;
204+
--mauve9: #706f78;
205+
--mauve10: #7e7d86;
206+
--mauve11: #a09fa6;
207+
--mauve12: #ededef;
180208

181209
/* red colors */
182210
--red1: #1f1315;

scaladoc/resources/dotty_res/styles/theme/components/code-snippet.css

+4
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696
border: 1px solid var(--border-default);
9797
}
9898

99+
.snippet:hover::-webkit-scrollbar-thumb {
100+
border: 3px solid var(--action-primary-background-hover);
101+
}
102+
99103
.snippet .copy-button {
100104
position: absolute;
101105
top: calc(3 * var(--base-spacing));

scaladoc/resources/dotty_res/styles/theme/components/table-of-content.css

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#toc {
22
display: flex;
33
flex-direction: column;
4-
padding: 0 calc(1 * var(--base-spacing));
5-
width: calc(29 * var(--base-spacing));
4+
margin-left: calc(6 * var(--base-spacing));
5+
width: 232px;
66
}
77

88
#toc-container {
9-
position: absolute;
9+
width: 232px;
1010
}
1111

1212
#toc ul {
@@ -20,7 +20,6 @@
2020

2121
#toc li > ul {
2222
margin-top: calc(2.5 * var(--base-spacing));
23-
margin-left: calc(1.5 * var(--base-spacing));
2423
}
2524

2625
@media (min-width: 1920px) {
@@ -35,7 +34,7 @@
3534
}
3635
}
3736

38-
@media (max-width: 1436px) {
37+
@media (max-width: 1467px) {
3938
#toc {
4039
margin-left: calc(8.5 * var(--base-spacing));
4140
margin-right: calc(8.5 * var(--base-spacing));
@@ -58,11 +57,6 @@
5857
}
5958

6059
@media (max-width: 1024px) {
61-
#toc {
62-
margin-left: calc(6 * var(--base-spacing));
63-
margin-right: 0;
64-
}
65-
6660
#toc.sidebar-shown {
6761
display: none;
6862
}

scaladoc/resources/dotty_res/styles/theme/layout/arrowNavigation.css

+10-5
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@
44
margin-top: calc(6 * var(--base-spacing));
55
}
66

7+
.arrow-navigation > div {
8+
width: 50%;
9+
}
10+
11+
.arrow-navigation > div:first-child {
12+
padding-right: 12px;
13+
}
14+
715
.arrow-navigation > div:last-child {
8-
margin-left: auto;
16+
text-align: right;
17+
padding-left: 12px;
918
}
1019

1120
.arrow-navigation > div > span {
1221
display: block;
1322
margin-bottom: calc(1 * var(--base-spacing));
1423
color: var(--text-secondary);
15-
}
16-
17-
.arrow-navigation--next {
18-
text-align: right;
1924
}

scaladoc/resources/dotty_res/styles/theme/layout/content.css

+27-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@
88
display: flex;
99
flex-flow: row;
1010
color: var(--text-primary);
11+
-webkit-transition: width 0.3s ease-in-out;
12+
-moz-transition: width 0.3s ease-in-out;
13+
-o-transition: width 0.3s ease-in-out;
14+
transition: width 0.3s ease-in-out;
1115
}
1216

17+
1318
#content > div:first-child {
1419
overflow: clip;
1520
}
@@ -44,7 +49,7 @@
4449
}
4550
}
4651

47-
@media (max-width: 1436px) {
52+
@media (max-width: 1467px) {
4853
#content {
4954
margin-left: 0;
5055
width: calc(100% - calc(56 * var(--base-spacing)));
@@ -170,8 +175,29 @@
170175
/* content table */
171176
#content table {
172177
color: var(--text-primary);
178+
border-collapse: collapse;
179+
}
180+
181+
#content table tbody {
182+
text-align: right;
183+
}
184+
185+
#content table tr td:last-child,
186+
#content table th:last-child {
187+
text-align: left;
188+
}
189+
190+
#content table * {
191+
padding: calc(2 * var(--base-spacing)) var(--base-spacing) 17px;
192+
}
193+
194+
#content table tr {
195+
border-bottom: 1px solid var(--border-default);
173196
}
174197

198+
#content table tr:last-child {
199+
border-bottom: none;
200+
}
175201

176202
/* content link */
177203
#content a {

0 commit comments

Comments
 (0)