Skip to content

Commit 2b6cc6a

Browse files
Merge pull request #35 from szymon-rd/ux-fixes
adding layout and ux fixes
2 parents 98bead0 + 1a11cfd commit 2b6cc6a

File tree

9 files changed

+65
-40
lines changed

9 files changed

+65
-40
lines changed

scaladoc-js/main/src/searchbar/SearchbarComponent.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ class SearchbarComponent(engine: PageSearchEngine, inkuireEngine: InkuireJSSearc
103103
searchTask.map { result =>
104104
if result.isEmpty then
105105
val noResultsDiv = div(id := "no-results-container")(
106-
// TODO fix path to the element
107-
img(src := "../images/no-results-icon.svg", alt := "Sick face"),
106+
div(cls := "no-result-icon"),
108107
h2(cls := "h200 no-result-header")("No results match your filter criteria."),
109108
p(cls := "body-small no-result-content")("Try adjusting or clearing your filters", p("to display better result")),
110109
button(id := "searchbar-clear-button", cls := "clearButton label-only-button")("Clear all filters").tap(_.addEventListener("click", _ => {

scaladoc/resources/dotty_res/scripts/components/FilterBar.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class FilterBar extends Component {
5252
this.setState((prevState) => ({
5353
filter: prevState.filter.onInputValueChange(""),
5454
}));
55+
const noResultContainer = document.querySelector("#no-results-container");
56+
if (noResultContainer) noResultContainer.remove();
5557
};
5658

5759
onFilterVisibilityChange = () => {
@@ -90,7 +92,7 @@ class FilterBar extends Component {
9092
emptySpace.insertAdjacentHTML(
9193
"beforeend",
9294
`<div id='no-results-container'>
93-
<img src="../images/no-results-icon.svg" alt="Sick face" >
95+
<div class="no-result-icon" ></div>
9496
<h2 class='h200 no-result-header'>No results match your filter criteria</h2>
9597
<p class='no-result-content'>Try adjusting or clearing your filters<br>to display better result</p>
9698
<button class='clearButton label-only-button'>Clear all filters</button>

scaladoc/resources/dotty_res/scripts/ux.js

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ function attachAllListeners() {
4949
observer.disconnect();
5050
}
5151

52-
var anyNodeExpanded = document.querySelectorAll(".ni.n0.expanded").length > 0
53-
var firstNavNode = document.querySelector(".ni.n0")
54-
if(!anyNodeExpanded && firstNavNode != null) {
55-
var firstNavNodeAddress = firstNavNode.querySelector("a")
56-
firstNavNode.classList.add("expanded")
57-
var button = firstNavNode.querySelector("button.ar")
58-
if(button != null) {
59-
button.classList.add("expanded")
52+
var anyNodeExpanded = document.querySelectorAll(".ni.n0.expanded").length > 0;
53+
var firstNavNode = document.querySelector(".ni.n0");
54+
if (!anyNodeExpanded && firstNavNode != null) {
55+
var firstNavNodeAddress = firstNavNode.querySelector("a");
56+
firstNavNode.classList.add("expanded");
57+
var button = firstNavNode.querySelector("button.ar");
58+
if (button != null) {
59+
button.classList.add("expanded");
6060
}
6161
}
6262

@@ -161,6 +161,9 @@ function attachAllListeners() {
161161
window.history.pushState(state, "", href);
162162
loadPageState(document, state);
163163
window.dispatchEvent(new Event(DYNAMIC_PAGE_LOAD));
164+
document
165+
.querySelector("#main")
166+
.scrollTo({ top: 0, left: 0, behavior: "instant" });
164167
});
165168
});
166169
});
@@ -342,8 +345,6 @@ window.addEventListener("DOMContentLoaded", () => {
342345
window.dispatchEvent(new Event(DYNAMIC_PAGE_LOAD));
343346
});
344347

345-
346-
347348
const elements = document.querySelectorAll(".documentableElement");
348349

349350
// show/hide side menu on mobile view
@@ -359,18 +360,22 @@ sideMenuToggler.addEventListener("click", (_e) => {
359360
});
360361

361362
// show/hide mobile menu on mobile view
362-
document.getElementById("mobile-menu-toggle").addEventListener('click', _e => {
363-
document.getElementById("mobile-menu").classList.add("show")
364-
})
365-
document.getElementById("mobile-menu-close").addEventListener('click', _e => {
366-
document.getElementById("mobile-menu").classList.remove("show")
367-
})
368-
369-
window.addEventListener('popstate', e => {
370-
if (e.state === null) { return }
371-
loadPageState(document, e.state)
372-
window.dispatchEvent(new Event(DYNAMIC_PAGE_LOAD))
373-
})
363+
document
364+
.getElementById("mobile-menu-toggle")
365+
.addEventListener("click", (_e) => {
366+
document.getElementById("mobile-menu").classList.add("show");
367+
});
368+
document.getElementById("mobile-menu-close").addEventListener("click", (_e) => {
369+
document.getElementById("mobile-menu").classList.remove("show");
370+
});
371+
372+
window.addEventListener("popstate", (e) => {
373+
if (e.state === null) {
374+
return;
375+
}
376+
loadPageState(document, e.state);
377+
window.dispatchEvent(new Event(DYNAMIC_PAGE_LOAD));
378+
});
374379

375380
var zoom;
376381
var transform;
@@ -503,15 +508,16 @@ function zoomOut() {
503508
svg.transition().duration(2000).call(zoom.transform, transform);
504509
}
505510

506-
507511
const members = [...document.querySelectorAll("[id]")];
508512
members.forEach((member) => {
509513
window.addEventListener("resize", () => {
510514
const navbarHeight = document.querySelector("#header").clientHeight;
511515
const filtersHeight = document.querySelector(
512516
".documentableFilter",
513517
).clientHeight;
514-
member.style.scrollMarginTop = `${navbarHeight + filtersHeight}px`;
518+
if (navbarHeight && filtersHeight) {
519+
member.style.scrollMarginTop = `${navbarHeight + filtersHeight}px`;
520+
}
515521
});
516522
});
517523

@@ -521,6 +527,8 @@ members.forEach((member) => {
521527
const filtersHeight = document.querySelector(
522528
".documentableFilter",
523529
).clientHeight;
524-
member.style.scrollMarginTop = `${navbarHeight + filtersHeight}px`;
530+
if (navbarHeight && filtersHeight) {
531+
member.style.scrollMarginTop = `${navbarHeight + filtersHeight}px`;
532+
}
525533
});
526534
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
border-bottom: none;
5454
}
5555

56-
#toc li:hover > a {
56+
#toc li a:hover {
5757
color: var(--action-primary-content-hover);
5858
}
5959

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ p {
1111
margin-block: calc(3 * var(--base-spacing));
1212
}
1313

14-
p, span, a, h1, h2, h3, h4, h5, h6, strong, dt, dl {
15-
word-break: break-all;
16-
}
17-
1814
[id] {
1915
scroll-margin-top: calc(18 * var(--base-spacing));
2016
}

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,7 @@
187187
border-collapse: collapse;
188188
}
189189

190-
#content table tbody {
191-
text-align: right;
192-
}
193-
194-
#content table tr td:last-child,
195-
#content table th:last-child {
190+
#content table {
196191
text-align: left;
197192
}
198193

@@ -208,6 +203,17 @@
208203
border-bottom: none;
209204
}
210205

206+
207+
/* contributors table */
208+
#contributors table tr td:not(:last-child),
209+
#contributors table th:not(:last-child) {
210+
text-align: right;
211+
}
212+
213+
#contributors table td {
214+
vertical-align: top;
215+
}
216+
211217
/* content link */
212218
#content a {
213219
color: var(--text-primary);
@@ -583,3 +589,7 @@ main :is(ul, ol) li .snippet {
583589
.membersList.concise .documentableElement.expand .modifiers {
584590
display: unset;
585591
}
592+
593+
.show-all-code {
594+
margin-top: calc(2* var(--base-spacing));
595+
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
margin: calc(10 * var(--base-spacing));
88
}
99

10+
#no-results-container .no-result-icon {
11+
height: 30px;
12+
width: 30px;
13+
}
14+
15+
#no-results-container .no-result-icon::before {
16+
content: url('../../../images/no-results-icon.svg');
17+
}
18+
1019
#no-results-container .no-result-header {
1120
margin-block-start: 27px;
1221
margin-block-end: var(--base-spacing);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
@media (max-width: 768px) {
7272
.scaladoc-searchbar-cancel-button {
7373
display: inline;
74+
min-width: 44px;
7475
}
7576
}
7677

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ class MemberRenderer(signatureRenderer: SignatureRenderer)(using DocContext) ext
432432
else Seq(div(cls := s"mono-small-block $className")(
433433
list.map(link =>
434434
div(link.kind.name," ", link.signature.map(renderElement(_)))),
435-
if(expandable) then span(cls := "show-all-code show-content")("Show all") else span()
435+
if(expandable) then span(cls := "show-all-code show-content text-button h100")("Show all") else span()
436436
))
437437

438438
def selfTypeList(list: List[LinkToType]): Seq[AppliedTag] =

0 commit comments

Comments
 (0)