Skip to content

Commit c2b4d45

Browse files
authored
Merge pull request #14 from pikinier20/scaladoc/header-component
header component
2 parents b330a69 + 1e350c9 commit c2b4d45

File tree

134 files changed

+2194
-632
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+2194
-632
lines changed

docs/_assets/images/logo.svg

Lines changed: 9 additions & 15 deletions
Loading

docs/_assets/images/logo_dark.svg

Lines changed: 10 additions & 0 deletions
Loading

docs/_layouts/static-site-main.html

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,34 @@
11
---
22
layout: main
33
---
4+
45
<div class="container">
5-
<div id="site-header">
6-
<div class="wrap">
7-
<nav class="navigation" role="menu">
8-
<ul class="navigation-menu">
9-
<li class="navigation-menu-item">
10-
<a href="https://docs.scala-lang.org/" class="active">Learn</a>
11-
</li>
12-
<li class="navigation-menu-item">
13-
<a href="https://www.scala-lang.org/download/">Install</a>
14-
</li>
15-
<li class="navigation-menu-item">
16-
<a href="https://scastie.scala-lang.org">Playground</a>
17-
</li>
18-
<li class="navigation-menu-item">
19-
<a href="https://index.scala-lang.org">Find A Library</a>
20-
</li>
21-
<li class="navigation-menu-item">
22-
<a href="https://www.scala-lang.org/community/">Community</a>
23-
</li>
24-
<li class="navigation-menu-item">
25-
<a href="https://www.scala-lang.org/blog/">Blog</a>
26-
</li>
27-
</ul>
28-
</nav>
29-
</div>
30-
</div>
6+
<div id="site-header"></div>
317
{% if page.movedTo %}
328
<aside class="warning">
33-
The content of this page is outdated. Click <a href="{{ page.movedTo }}">here</a> to find the up to date version of this page.
9+
The content of this page is outdated. Click
10+
<a href="{{ page.movedTo }}">here</a> to find the up to date version of this
11+
page.
3412
</aside>
35-
{% endif %}
36-
{{ content }}
13+
{% endif %} {{ content }}
3714
<nav class="arrows-wrapper" aria-label="Page navigation">
3815
{% if page.previous %}
39-
<a rel="prev" href="{{ page.previous.url }}" class="arrows previous" aria-keyshortcuts="Left">
40-
<span>{{ page.previous.title }}</span>
41-
<i class="fa fa-angle-left"></i>
16+
<a
17+
rel="prev"
18+
href="{{ page.previous }}"
19+
class="arrows previous"
20+
aria-keyshortcuts="Left"
21+
>
22+
<i class="fa fa-angle-left"></i>
4223
</a>
43-
{% endif %}
44-
{% if page.next %}
45-
<a rel="next" href="{{ page.next.url }}" class="arrows next" aria-keyshortcuts="Right">
46-
<span>{{ page.next.title }}</span>
47-
<i class="fa fa-angle-right"></i>
24+
{% endif %} {% if page.next %}
25+
<a
26+
rel="next"
27+
href="{{ page.next }}"
28+
class="arrows next"
29+
aria-keyshortcuts="Right"
30+
>
31+
<i class="fa fa-angle-right"></i>
4832
</a>
4933
{% endif %}
5034
</nav>

scaladoc-js/common/css/searchbar.css

Lines changed: 7 additions & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,13 @@
1-
/* Global search */
2-
.search-content {
3-
padding: 0;
4-
margin: var(--content-padding);
5-
position: fixed;
6-
top: 0;
7-
right: 0;
8-
z-index: 5;
9-
background: none;
10-
}
11-
12-
/* popup */
13-
.popup-wrapper {
14-
box-shadow: 0 0 10px var(--border-light) !important;
15-
border: 2px solid var(--border-light) !important;
16-
font-family: var(--mono-font) !important;
17-
width: calc(100% - var(--side-width) - 84px);
18-
left: calc(var(--side-width) + 42px) !important;
19-
}
20-
.popup-wrapper .indented {
21-
text-indent: 1.5em !important;
22-
}
23-
.popup-wrapper .disabled {
24-
color: var(--inactive-fg) !important;
25-
font-weight: 500 !important;
26-
}
27-
.action_def:hover, .action_def.hover_a79 {
28-
color: var(--selected-fg);
29-
background: var(--selected-bg) !important;
30-
font-weight: 500;
31-
}
32-
.action_def .template-description {
33-
margin-left: 2rem;
34-
font-style: italic;
35-
}
36-
37-
/* Landscape phones, portait tablets */
38-
@media(max-width: 768px) {
39-
.popup-wrapper {
40-
width: calc(100% - 48px);
41-
left: 24px !important;
42-
}
43-
}
44-
45-
/* Portrait phones */
46-
@media(max-width: 576px) {
47-
.search-content {
48-
margin: 0 !important;
49-
top: 9px !important;
50-
right: 12px !important;
51-
}
52-
.popup-wrapper {
53-
width: 100%;
54-
left: 0 !important;
55-
top: 36px !important;
56-
}
57-
/* Allow to scroll horizontally in the search results, which is useful on small screens */
58-
.popup-wrapper div.ReactVirtualized__Grid__innerScrollContainer {
59-
overflow: auto !important;
60-
}
61-
.popup-wrapper div.ReactVirtualized__Grid__innerScrollContainer > div {
62-
min-width: 100%;
63-
width: auto !important;
64-
}
65-
}
66-
671
/* Loading */
682
.loading-wrapper {
693
text-align: center;
704
padding: 4px;
715
}
726

73-
.loading, .loading::before, .loading::after {
74-
content: '';
7+
.loading,
8+
.loading::before,
9+
.loading::after {
10+
content: "";
7511
width: 10px;
7612
height: 10px;
7713
border-radius: 5px;
@@ -89,7 +25,7 @@
8925

9026
.loading {
9127
position: relative;
92-
animation-delay: .2s;
28+
animation-delay: 0.2s;
9329
}
9430

9531
.loading::before {
@@ -99,7 +35,7 @@
9935

10036
.loading::after {
10137
left: 15px;
102-
animation-delay: .4s;
38+
animation-delay: 0.4s;
10339
}
10440

10541
@keyframes dotFlashing {
@@ -116,126 +52,21 @@
11652

11753
.scaladoc-searchbar-inkuire-package {
11854
display: none;
119-
color: var(--symbol-fg)
55+
color: var(--symbol-fg);
12056
}
12157

12258
div[selected] > .scaladoc-searchbar-inkuire-package {
12359
display: flex;
12460
}
12561

126-
.scaladoc-searchbar-inkuire-package > .micon {
127-
float: right;
128-
margin-left: auto !important;
129-
}
130-
131-
/* button */
132-
.search span {
133-
background: var(--red500);
134-
fill: var(--white);
135-
cursor: pointer;
136-
border: none;
137-
padding: 9px;
138-
border-radius: 24px;
139-
box-shadow: 0 0 16px var(--code-bg);
140-
}
141-
.search span:hover {
142-
background: var(--red600);
143-
}
144-
145-
@media(max-width: 576px) {
146-
.search span {
147-
background: none;
148-
fill: var(--icon-color);
149-
cursor: pointer;
150-
border: none;
151-
padding: 0;
152-
box-shadow: none;
153-
margin-top: 2px;
154-
}
155-
156-
.search span:hover {
157-
fill: var(--link-hover-fg);
158-
}
159-
160-
#scaladoc-searchbar span.pull-right {
161-
display: none;
162-
}
163-
}
164-
165-
#scaladoc-search {
166-
margin-top: 16px;
167-
cursor: pointer;
168-
position: fixed;
169-
top: 0;
170-
right: 20px;
171-
z-index: 5;
172-
}
173-
17462
#scaladoc-searchbar.hidden {
17563
display: none;
17664
}
17765

178-
#scaladoc-searchbar {
179-
position: fixed;
180-
top: 50px;
181-
left: calc(5% + var(--side-width));
182-
z-index: 5;
183-
width: calc(90% - var(--side-width));
184-
box-shadow: 2px 2px 8px 0 var(--shadow);
185-
font-size: 13px;
186-
font-family: system-ui, -apple-system, Segoe UI, Roboto, Noto Sans, Ubuntu, Cantarell, Helvetica Neue, Arial, sans-serif;
187-
background-color: var(--leftbar-bg);
188-
color: var(--leftbar-fg);
189-
}
190-
191-
#scaladoc-searchbar-input {
192-
width: 100%;
193-
min-height: 32px;
194-
border: none;
195-
border-bottom: 1px solid #bbb;
196-
padding: 10px;
197-
background-color: var(--leftbar-bg);
198-
color: var(--leftbar-fg);
199-
}
200-
201-
#scaladoc-searchbar-input:focus {
202-
outline: none;
203-
}
204-
205-
#scaladoc-searchbar-results {
206-
display: flex;
207-
flex-direction: column;
208-
max-height: 500px;
209-
overflow: auto;
210-
}
211-
212-
.scaladoc-searchbar-row {
213-
display: flex;
214-
background-color: var(--leftbar-bg);
215-
color: var(--leftbar-fg);
216-
line-height: 24px;
217-
padding: 4px 10px 4px 10px;
218-
}
219-
22066
.scaladoc-searchbar-row.hidden {
22167
display: none;
22268
}
22369

224-
.scaladoc-searchbar-row[divider] {
225-
border-top: solid 1px var(--leftbar-border);
226-
}
227-
228-
.scaladoc-searchbar-row .micon {
229-
height: 16px;
230-
width: 16px;
231-
margin: 4px 8px 0px 0px;
232-
}
233-
234-
.scaladoc-searchbar-row[selected] {
235-
background-color: var(--leftbar-hover-bg);
236-
color: var(--leftbar-hover-fg);
237-
}
238-
23970
.scaladoc-searchbar-row[result] {
24071
flex-direction: column;
24172
}
@@ -261,22 +92,6 @@ div[selected] > .scaladoc-searchbar-inkuire-package {
26192
margin-right: 4px;
26293
}
26394

264-
.searchbar-hints {
265-
padding-top: 5vh;
266-
padding-bottom: 5vh;
267-
padding-left: 5vw;
268-
padding-right: 5vw;
269-
display: flex;
270-
flex-direction: column;
271-
align-items: center;
272-
justify-content: center;
273-
}
274-
275-
.searchbar-hints-list {
276-
font-size: medium;
277-
line-height: 2em;
278-
}
279-
28095
#searchBar {
28196
display: inline-flex;
28297
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package dotty.tools.scaladoc
2+
3+
import scala.scalajs.js
4+
import scala.scalajs.js._
5+
import org.scalajs.dom._
6+
import org.scalajs.dom.ext._
7+
import scala.util.chaining._
8+
9+
class SafeLocalStorage[T <: js.Any](key: String, defaultValue: T) {
10+
11+
val isLocalStorageSupported: Boolean = try {
12+
val testKey = "__TEST__KEY__"
13+
window.localStorage.setItem(testKey, "")
14+
window.localStorage.removeItem(testKey)
15+
true
16+
} catch {
17+
case _ => false
18+
}
19+
20+
def checkSupport[U](defaultValue: U)(callback: () => U): U =
21+
if isLocalStorageSupported then callback() else defaultValue
22+
23+
def parseData(data: String): T =
24+
try {
25+
Option(JSON.parse(data).asInstanceOf[T]).getOrElse(defaultValue)
26+
} catch {
27+
case _ => defaultValue
28+
}
29+
30+
def getData: T =
31+
checkSupport(defaultValue) { () =>
32+
window.localStorage
33+
.getItem(key)
34+
.pipe(parseData)
35+
}
36+
37+
def setData(data: T): Unit =
38+
checkSupport(()) { () =>
39+
JSON.stringify(data)
40+
.pipe(window.localStorage.setItem(key, _))
41+
}
42+
43+
def isEmpty: Boolean = getData == defaultValue
44+
}

0 commit comments

Comments
 (0)