Skip to content

Commit fdc0e5e

Browse files
committed
Apply review suggestions from PR #11822
1 parent 1dd064d commit fdc0e5e

File tree

4 files changed

+57
-13
lines changed

4 files changed

+57
-13
lines changed

scaladoc-js/resources/scaladoc-searchbar.css

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,29 @@
103103
margin-left: auto;
104104
}
105105

106-
.hide-snippet-comments-button {
106+
.snippet-comment-button {
107107
position: absolute;
108-
left: 90%;
108+
left: 50%;
109+
width: 24px;
110+
height: 24px;
111+
}
112+
113+
.show-snippet-comments-button {
114+
-ms-transform: translate(calc(-50% + 5em), -50%);
115+
transform: translate(calc(-50% + 5em), -50%);
116+
background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Ccircle cx='12' cy='12' r='12' fill='white'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M19 11.0053L19 13.1085H12.9873L12.988 19H10.8714L10.8721 13.1085L5 13.1085L5 11.0053L10.8721 11.0053V5L12.9865 5.00074L12.988 11.0045L19 11.0053Z' fill='%2327282C' fill-opacity='0.75'/%3E %3C/svg%3E");
117+
}
118+
119+
.show-snippet-comments-button:hover {
120+
background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Ccircle cx='12' cy='12' r='12' fill='light grey'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M19 11.0053L19 13.1085H12.9873L12.988 19H10.8714L10.8721 13.1085L5 13.1085L5 11.0053L10.8721 11.0053V5L12.9865 5.00074L12.988 11.0045L19 11.0053Z' fill='%2327282C' fill-opacity='0.75'/%3E %3C/svg%3E");
121+
}
122+
123+
.hide-snippet-comments-button {
124+
-ms-transform: translate(calc(-50% + 5em), -50%) rotate(45deg);
125+
transform: translate(calc(-50% + 5em), -50%) rotate(45deg);
126+
background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Ccircle cx='12' cy='12' r='12' fill='white'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M19 11.0053L19 13.1085H12.9873L12.988 19H10.8714L10.8721 13.1085L5 13.1085L5 11.0053L10.8721 11.0053V5L12.9865 5.00074L12.988 11.0045L19 11.0053Z' fill='%2327282C' fill-opacity='0.75'/%3E %3C/svg%3E");
127+
}
128+
129+
.hide-snippet-comments-button:hover {
130+
background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Ccircle cx='12' cy='12' r='12' fill='light grey'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M19 11.0053L19 13.1085H12.9873L12.988 19H10.8714L10.8721 13.1085L5 13.1085L5 11.0053L10.8721 11.0053V5L12.9865 5.00074L12.988 11.0045L19 11.0053Z' fill='%2327282C' fill-opacity='0.75'/%3E %3C/svg%3E");
109131
}

scaladoc-js/src/searchbar/code-snippets/CodeSnippets.scala

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,19 @@ class CodeSnippets:
2525
toggleHide(document)
2626

2727
document.querySelectorAll("pre").foreach {
28-
case e: html.Element =>
28+
case e: html.Element if e.querySelectorAll("code span.hideable").nonEmpty =>
2929
val a = document.createElement("a")
30-
a.textContent = "Show"
3130
a.addEventListener("click", { (_: MouseEvent) =>
32-
a.textContent = if a.textContent == "Show" then "Hide" else "Show"
31+
if(a.classList.contains("hide-snippet-comments-button")) {
32+
a.classList.add("show-snippet-comments-button")
33+
a.classList.remove("hide-snippet-comments-button")
34+
} else {
35+
a.classList.add("hide-snippet-comments-button")
36+
a.classList.remove("show-snippet-comments-button")
37+
}
3338
toggleHide(e)
3439
})
35-
a.classList.add("hide-snippet-comments-button")
40+
a.classList.add("snippet-comment-button")
41+
a.classList.add("show-snippet-comments-button")
3642
e.insertBefore(a, e.firstChild)
3743
}

scaladoc-testcases/src/tests/snippetComments.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package tests.snippetComments
1616
* /*
1717
* multi line comment
1818
* */
19-
*
19+
* val reallyFLongDeclaration = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
2020
* val y = 2 // comment in the same line
2121
* // comment in new line
2222
* val z = 3

scaladoc/resources/dotty_res/styles/scalastyle.css

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
--border-light: #DADFE6;
66
--border-medium: #abc;
77

8+
--body-bg: #f0f3f6;
89
--code-bg: #F4F5FA;
10+
--documentable-bg: #FFFFFF;
911
--symbol-fg: #333;
1012
--link-fg: #00607D;
1113
--link-hover-fg: #00A0D0;
@@ -45,6 +47,7 @@ body {
4547
padding: 0;
4648
font-family: "Lato", sans-serif;
4749
font-size: 16px;
50+
background-color: var(--body-bg);
4851
}
4952

5053
/* Page layout */
@@ -75,7 +78,12 @@ h1, h2, h3 {
7578
font-family: var(--title-font);
7679
color: var(--title-fg);
7780
}
78-
pre, code, .monospace, .hljs {
81+
.monospace {
82+
font-family: var(--mono-font);
83+
background: var(--documentable-bg);
84+
font-variant-ligatures: none;
85+
}
86+
pre, code, .hljs {
7987
font-family: var(--mono-font);
8088
background: var(--code-bg);
8189
font-variant-ligatures: none;
@@ -84,12 +92,15 @@ code {
8492
font-size: .8em;
8593
padding: 0 .3em;
8694
}
95+
pre {
96+
overflow-x: auto;
97+
}
8798
pre code, pre code.hljs {
8899
font-size: 1em;
89100
padding: 0;
90101
}
91102
pre, .symbol.monospace {
92-
padding: 10px 8px 10px 12px;
103+
padding: 12px 8px 10px 12px;
93104
font-weight: 500;
94105
font-size: 12px;
95106
}
@@ -468,12 +479,18 @@ footer .pull-right {
468479
padding-right: 0.5em;
469480
min-width: 10em;
470481
max-width: 10em;
482+
width: 10em;
471483
overflow: hidden;
472484
direction: rtl;
473485
white-space: nowrap;
474486
text-indent: 0em;
475487
}
476488

489+
.documentableElement .docs {
490+
width: 100%;
491+
table-layout: fixed;
492+
}
493+
477494
.documentableElement .modifiers .other-modifiers {
478495
color: gray;
479496
}
@@ -514,8 +531,8 @@ footer .pull-right {
514531
padding: 5px 4px 5px 4px;
515532
font-weight: 500;
516533
font-size: 12px;
517-
background: var(--code-bg);
518-
border: 0.25em solid white;
534+
background: var(--documentable-bg);
535+
border: 0.25em solid var(--body-bg);
519536
}
520537

521538
.documentableElement>div {
@@ -524,12 +541,11 @@ footer .pull-right {
524541

525542
.expand.documentableElement>div {
526543
display: block;
527-
padding-left: 3em;
528544
}
529545

530546
.expand.documentableElement>div.header {
531547
display: block;
532-
padding-left: 7.5em;
548+
padding-left: 4.5em;
533549
text-indent: -4.5em;
534550
}
535551

0 commit comments

Comments
 (0)