Skip to content

Commit 079489b

Browse files
committed
implement suggestions from plone#1421
1 parent d2ad668 commit 079489b

File tree

5 files changed

+82
-55
lines changed

5 files changed

+82
-55
lines changed

docs/_static/custom.css

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,25 +177,23 @@ div.admonition.admonition-todo>.admonition-title::before {
177177

178178
/* Search */
179179

180-
#search-shortcut-page {
181-
position: absolute;
182-
right: 156px;
183-
top: 0.375rem;
184-
border-radius: 0.25em;
185-
background: #d9eef9;
186-
padding: 0.1787rem 0.2813rem;
187-
color: #4a4a4a;
188-
font-weight: 600;
189-
line-height: 1.25rem;
190-
}
191-
192180
/* Show search form. It is hidden by default. */
193181
#search-documentation,
194182
#search-documentation~form,
195183
#search-documentation~p {
196184
display: block;
197185
}
198186

187+
#shortcut.input-group-text {
188+
padding-top: 0;
189+
padding-bottom: 0;
190+
}
191+
192+
.form-control:focus {
193+
box-shadow: none;
194+
border-width: 2px;
195+
}
196+
199197
ul.search {
200198
margin-left: 0;
201199
}
@@ -246,6 +244,27 @@ ul.search li p.context {
246244
margin-left: 0;
247245
}
248246

247+
/* Search form sidebar */
248+
249+
.bd-search .input-group {
250+
flex-direction: row-reverse;
251+
}
252+
253+
.bd-search {
254+
font-size: .8rem;
255+
}
256+
257+
.bd-search input,
258+
.bd-search .input-group-text {
259+
font-size: .8rem;
260+
padding-left: .5em;
261+
}
262+
263+
.input-group-text kbd {
264+
padding: 0rem 0.4rem;
265+
font-size: 135%;
266+
}
267+
249268
.pathseparator {
250269
padding: 0 0.7rem;
251270
}
@@ -317,6 +336,7 @@ div.sidebar:not(.margin) .admonition {
317336
margin-right: .5em;
318337
background-color: #ffffff;
319338
}
339+
320340
#search-shortcut-sidebar {
321341
position: absolute;
322342
right: 1.25rem;

docs/_static/search_shortcut.js

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,27 @@
22
* Add shortcut `ctrl+k` to focus on search field
33
*/
44

5-
$(document).ready(() => {
6-
$(document).keydown(function(event) {
7-
if ((event.ctrlKey || event.metaKey) && event.key == "k") {
8-
event.preventDefault();
9-
$('#search-input').focus();
10-
}
11-
});
12-
if (navigator.platform.indexOf('Mac') === -1) {
13-
$('#search-shortcut-sidebar').html("^K"); // if OS isn't Mac change Visual indication of search field
14-
}
15-
16-
// Show & hide seach input when focusin & focusout
17-
$('#search-input').focus(() => {
18-
$('#search-shortcut-sidebar').hide();
19-
});
20-
$('#search-input').focusout(() => {
21-
$('#search-shortcut-sidebar').show();
22-
});
23-
24-
// For Search page
25-
5+
$(document).ready(() => {
266
if (window.location.pathname === '/search.html') {
277
$('form.bd-search').css('visibility','hidden'); // Hide Sidebar Search field
8+
9+
$(document).keydown(function(event) {
10+
if ((event.ctrlKey || event.metaKey) && event.key == "k") {
11+
event.preventDefault();
12+
$('#q').focus();
13+
}
14+
});
15+
} else {
16+
$(document).keydown(function(event) {
17+
if ((event.ctrlKey || event.metaKey) && event.key == "k") {
18+
event.preventDefault();
19+
$('#search-input').focus();
20+
}
21+
});
2822
}
23+
2924
if (navigator.platform.indexOf('Mac') === -1) {
30-
$('#search-shortcut-page').html("^K"); // if OS isn't Mac change Visual indication of search field
25+
$('#search-shortcut').html("^"); // if OS isn't Mac change visual indication of search field
3126
}
32-
$(document).keydown(function(event) {
33-
if ((event.ctrlKey || event.metaKey) && event.key == "k") {
34-
event.preventDefault();
35-
$('#q').focus();
36-
}
37-
});
27+
3828
});

docs/_templates/search-field.html

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
<form class="bd-search d-flex align-items-center" action="{{ pathto('search') }}" method="get">
2-
<i class="icon fas fa-search"></i>
3-
<input type="search" class="form-control" name="q" id="search-input" placeholder="{{ _(theme_search_bar_text) }}" aria-label="{{ theme_search_bar_text }}" autocomplete="off" >
4-
<span id="search-shortcut-sidebar">⌘K</span>
5-
</form>
2+
<div class="input-group">
3+
<label for="q" class="sr-only">Search string
4+
</label>
5+
<div class="input-group-prepend">
6+
<span class="input-group-text" id="shortcut">
7+
<kbd id="search-shortcut"></kbd>&nbsp;<kbd>K</kbd>
8+
</span>
9+
</div>
10+
<input
11+
type="search" name="q" id="search-input"
12+
class="form-control"
13+
placeholder="{{ _(theme_search_bar_text) }}"
14+
aria-labelledby="{{ _(theme_search_bar_text) }}"
15+
value="" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
16+
/>
17+
</div>
18+
</form>

docs/_templates/search.html

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,29 @@ <h1 id="search-documentation">{{ _('Search') }}</h1>
4848
>
4949
<div class="row">
5050
<div class="input-group col-xl-8 mb-2">
51+
<label for="q" class="sr-only">Search string
52+
</label>
53+
<div class="input-group-prepend">
54+
<span class="input-group-text" id="shortcut">
55+
<kbd id="search-shortcut"></kbd>&nbsp;<kbd>K</kbd>
56+
</span>
57+
</div>
5158
<input
5259
type="search" name="q" id="q"
5360
class="form-control"
54-
placeholder="Search the docs…"
55-
aria-labelledby="search-documentation" value="" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
56-
<span id="search-shortcut-page">⌘K</span>
57-
<label for="q" class="sr-only">Search string</label>
61+
placeholder="{{ _(theme_search_bar_text) }}"
62+
aria-labelledby="{{ _(theme_search_bar_text) }}"
63+
value="" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
64+
/>
5865
<div class="input-group-append">
5966
<button type="submit" class="btn btn-primary">{{ _('search') }}</button>
6067
</div>
61-
<div class="input-group-append">
68+
<!-- <div class="input-group-append">
6269
<button
6370
type="button"
6471
class="clear_search btn btn-secondary"
6572
>{{ _('reset') }}</button>
66-
</div>
73+
</div> -->
6774
</div>
6875
</div>
6976

docs/conf.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,7 @@
129129
"volto/developer-guidelines/branch-policy.md",
130130
]
131131

132-
html_js_files = [
133-
"patch_scrollToActive.js",
134-
"search_shortcut.js"
135-
]
132+
html_js_files = ["patch_scrollToActive.js", "search_shortcut.js"]
136133

137134
html_extra_path = [
138135
"robots.txt",
@@ -250,7 +247,7 @@
250247
"use_repository_button": True,
251248
"use_issues_button": True,
252249
"use_edit_page_button": True,
253-
"search_bar_text": "Search the docs…",
250+
"search_bar_text": "Search",
254251
"switcher": {
255252
"json_url": "/_static/switcher.json",
256253
"version_match": version,

0 commit comments

Comments
 (0)