Skip to content

Commit df20c3d

Browse files
author
Filip Łukasik
committed
add searchbar basic style
1 parent 49d75b1 commit df20c3d

File tree

7 files changed

+68
-2
lines changed

7 files changed

+68
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class SearchbarComponent(engine: SearchbarEngine, inkuireEngine: InkuireJSSearch
172172
icon
173173

174174
private val inputElem: html.Input =
175-
input(id := "scaladoc-searchbar-input").tap { element =>
175+
input(id := "scaladoc-searchbar-input", `type` := "search").tap { element =>
176176
element.addEventListener("input", { e =>
177177
val inputValue = e.target.asInstanceOf[html.Input].value
178178
if inputValue.isEmpty then showHints()

scaladoc-js/main/src/versions-dropdown/DropdownHandler.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class DropdownHandler:
2525
val ver = JSON.parse(json).asInstanceOf[Versions]
2626
val ddc = document.getElementById("version-dropdown")
2727
for (k, v) <- ver.versions do
28-
val child = a(cls := "text-button", href := v)(k)
28+
var child = a(cls := "text-button", href := v)(k)
2929
ddc.appendChild(child)
3030

3131
private def disableButton() =
@@ -57,6 +57,7 @@ class DropdownHandler:
5757

5858
document.addEventListener("click", (e: Event) => {
5959
document.getElementById("version-dropdown").classList.remove("expanded")
60+
document.getElementById("dropdown-trigger").classList.remove("selected")
6061
})
6162

6263
document.getElementById("version-dropdown").asInstanceOf[html.Span].addEventListener("click", (e: Event) => e.stopPropagation())
@@ -69,6 +70,7 @@ def dropdownHandler(e: Event) =
6970
if document.getElementById("version-dropdown").getElementsByTagName("a").size > 0 &&
7071
window.getSelection.toString.length == 0 then
7172
document.getElementById("version-dropdown").classList.toggle("expanded")
73+
document.getElementById("dropdown-trigger").classList.toggle("selected")
7274

7375
@JSExportTopLevel("filterFunction")
7476
def filterFunction() =
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

scaladoc/resources/dotty_res/styles/theme/components/button/text-button.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,19 @@
4848
.theme-dark .text-button.with-arrow::after {
4949
content: url("../../../../images/icon-buttons/arrow-down/dark/default.svg");
5050
}
51+
52+
.text-button.with-arrow:hover::after {
53+
content: url("../../../../images/icon-buttons/arrow-down/light/hover.svg");
54+
}
55+
56+
.theme-dark .text-button.with-arrow:hover::after {
57+
content: url("../../../../images/icon-buttons/arrow-down/dark/hover.svg");
58+
}
59+
60+
.text-button.with-arrow.selected::after {
61+
content: url("../../../../images/icon-buttons/arrow-down/light/selected.svg");
62+
}
63+
64+
.theme-dark .text-button.with-arrow.selected::after {
65+
content: url("../../../../images/icon-buttons/arrow-down/dark/selected.svg");
66+
}

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,56 @@
1010

1111
#scaladoc-searchbar {
1212
z-index: 5;
13+
width: calc(125 * var(--base-spacing));
1314
}
1415

1516
#scaladoc-searchbar-input {
1617
width: 100%;
1718
background-color: var(--action-primary-background-default-solid);
19+
color: var(--action-primary-content-active);
1820
background-image: url("../../../images/icon-buttons/search/dark/default.svg");
1921
background-repeat: no-repeat;
2022
padding: calc(2 * var(--base-spacing)) calc(2 * var(--base-spacing))
2123
calc(2 * var(--base-spacing)) calc(5 * var(--base-spacing));
2224
border-radius: 4px;
2325
background-size: 16px;
2426
background-position: 10px 15px;
27+
border: none;
28+
}
29+
30+
#scaladoc-searchbar-input:focus-visible {
31+
border: none;
32+
outline: none;
33+
}
34+
35+
#scaladoc-searchbar-input::-webkit-search-cancel-button {
36+
-webkit-appearance: none;
37+
height: 1em;
38+
width: 1em;
39+
border-radius: 50em;
40+
background: url("../../../images/icon-buttons/close/light/default.svg")
41+
no-repeat 50% 50%;
42+
background-size: contain;
43+
opacity: 0;
44+
pointer-events: none;
45+
}
46+
47+
.theme-dark #scaladoc-searchbar-input::-webkit-search-cancel-button {
48+
background: url("../../../images/icon-buttons/close/dark/default.svg")
49+
no-repeat 50% 50%;
50+
}
51+
52+
#scaladoc-searchbar-input:focus::-webkit-search-cancel-button {
53+
opacity: 1;
54+
pointer-events: all;
55+
}
56+
57+
#scaladoc-searchbar-input.dark::-webkit-search-cancel-button {
58+
filter: invert(1);
59+
}
60+
61+
#scaladoc-searchbar-results {
62+
background-color: var(--background-default);
63+
border-radius: 4px;
64+
margin-top: calc(1.5 * var(--base-spacing));
2565
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ trait Resources(using ctx: DocContext) extends Locations, Writer:
333333
dottyRes("images/icon-buttons/arrow-right/light/hover.svg"),
334334
dottyRes("images/icon-buttons/arrow-right/light/selected.svg"),
335335
dottyRes("images/icon-buttons/arrow-right/light/default.svg"),
336+
dottyRes("images/icon-buttons/close/light/default.svg"),
337+
dottyRes("images/icon-buttons/close/dark/default.svg"),
336338
searchData(pages),
337339
scastieConfiguration(),
338340
)

0 commit comments

Comments
 (0)