Skip to content

Commit f88da28

Browse files
authored
Merge pull request #26 from tayloraswift/frontend-improvements
Frontend improvements
2 parents adfb7fb + 45f9169 commit f88da28

File tree

5 files changed

+47
-9
lines changed

5 files changed

+47
-9
lines changed

Assets/js/Main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/js/Main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div align="center">
22

3-
<strong><em><code>unidoc</code></em></strong><br><small><code>0.2.7</code></small>
3+
<strong><em><code>unidoc</code></em></strong><br><small><code>0.2.8</code></small>
44

55
[![ci build status](https://github.com/kelvin13/swift-unidoc/actions/workflows/build.yml/badge.svg)](https://github.com/kelvin13/swift-unidoc/actions/workflows/build.yml)
66

Sources/UnidocPages/Templates/Site.Docs.MultipleFound.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ extension Site.Docs.MultipleFound:ApplicationPage
7373
$0[.div, { $0.class = "eyebrows" }]
7474
{
7575
$0[.span, { $0.class = "phylum" }] = "Disambiguation Page"
76+
$0[.span, { $0.class = "domain" }]
77+
{
78+
$0[.span, { $0.class = "package" }]
79+
{
80+
$0[.a]
81+
{
82+
$0.href = "\(Site.Docs[self.names])"
83+
} = "\(self.names.package)"
84+
}
85+
86+
$0[.span] { $0.class = "version" } = self.names.version
87+
}
7688
}
7789

7890
var path:URI.Path = []

TypeScript/Sources/Main.ts

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,38 @@ if (list !== null) {
1818
const input: HTMLElement | null = document.getElementById('search-input');
1919

2020
if (input !== null) {
21-
input.addEventListener('focus',
22-
(event: Event) => searchbar.focus());
23-
input.addEventListener('input',
24-
(event: Event) => searchbar.suggest(event));
25-
input.addEventListener('keydown',
26-
(event: KeyboardEvent) => searchbar.navigate(event));
21+
input.addEventListener('focus', (event: Event) => searchbar.focus());
22+
23+
// We don’t want to suggest a keyboard shortcut if the user focused the input
24+
// via touch, or if they were already using the keyboard shortcut.
25+
input.addEventListener('mousedown', function (event: Event) {
26+
input.setAttribute('placeholder', 'search shortcut: /');
27+
});
28+
29+
input.addEventListener('blur', function (event: Event) {
30+
input.setAttribute('placeholder', 'search symbols');
31+
});
32+
33+
input.addEventListener('input', (event: Event) => searchbar.suggest(event));
34+
input.addEventListener('keydown', (event: KeyboardEvent) => searchbar.navigate(event));
35+
36+
document.addEventListener('keydown', function (event: KeyboardEvent) {
37+
switch (event.key) {
38+
case 'Escape': {
39+
if (document.activeElement === input) {
40+
input.blur();
41+
}
42+
break;
43+
}
44+
case '/': {
45+
if (document.activeElement !== input) {
46+
input.focus();
47+
event.preventDefault();
48+
}
49+
break;
50+
}
51+
}
52+
});
2753
}
2854

2955
const form: HTMLElement | null = document.getElementById('search');

0 commit comments

Comments
 (0)