Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken search bar in docs site #1135

Merged
merged 2 commits into from
Jan 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
env:
site_url: http://127.0.0.1:8000
run: |
select="{urls: [\"${site_url}/\", .urlset.url[].loc]}"
select="{urls: [\"${site_url}/\", \"${site_url}/search.html?q=jrnl\", .urlset.url[].loc]}"
curl -s "$site_url/sitemap.xml" | poetry run xq "$select" > list.json

- name: Accessibility testing (Pa11y)
Expand Down
1 change: 1 addition & 0 deletions docs_theme/assets/colors.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
--yellow: #e2b93d;

/* For light bg */
--black: #404040;
--teal: #2a8068;
--dark-blue: #356eb7;
--mid-purple: #846392;
Expand Down
56 changes: 47 additions & 9 deletions docs_theme/assets/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
body.wy-body-for-nav,
section.wy-nav-content-wrap {
background-color: var(--white);
color: var(--black);
}

.rst-content pre {
Expand Down Expand Up @@ -102,7 +103,7 @@ a.icon-home:before {
.wy-menu-vertical a,
.wy-menu-vertical li ul li a {
font-size: 16px;
color: var(--off-white);
color: var(--white);
line-height: 2em;
}

Expand Down Expand Up @@ -167,7 +168,7 @@ a.icon-home:before {
}

.wy-menu-vertical li a {
color: var(--off-white) !important;
color: var(--white) !important;
font-weight: 300;
}

Expand All @@ -185,18 +186,20 @@ footer {
}

.wy-side-nav-search input[type=text],
.mkdocs-search input[type=text],
form .search-query {
background-color: var(--black-shadow) !important;
background-color: var(--off-white);
border: none;
box-shadow: none;
margin-bottom: 1em;
color: var(--white);
color: var(--black);
font-weight: 500;
box-shadow: none;
}

.wy-side-nav-search input[type=text]::placeholder,
.mkdocs-search input[type=text]::placeholder,
form .search-query::placeholder {
color: var(--off-white);
color: var(--dark-purple);
}

.wy-side-nav-search > a:hover {
Expand Down Expand Up @@ -298,19 +301,54 @@ ol>li:before {
margin-top: 20px;
}

.wy-side-nav-search input[type="text"] {
.wy-side-nav-search input[type="text"],
.mkdocs-search input[type=text] {
border-radius: 50px 0 0 50px;
height: 32px;
border-right: none;
margin: 0;
}

.mkdocs-search button {
background-color: var(--black-shadow);
background-color: var(--off-white);
border: none;
box-shadow: none;
color: var(--white);
color: var(--mid-purple);
border-radius: 0 50px 50px 0;
height: 32px;
width: 2.5em;
overflow: hidden;
}

.mkdocs-search {
border-radius: 50px;
}

.mkdocs-search:focus-within {
box-shadow: 0 2px 25px 0 var(--blacker-shadow);
transition: all .5s ease;
}

.rst-content div[role="main"] .mkdocs-search input[type="text"] {
border-right: none;
font-size: 100%;
height: 48px;
margin: 0;
}

.rst-content div[role="main"] .mkdocs-search button {
border-left: none;
font-size: 100%;
height: 48px;
}

.rst-content div[role="main"] .mkdocs-search button:before {
font-size: 140%;
position: relative;
left: -7px;
top: -1px;
}

.search-results {
margin-top: 0;
}
16 changes: 10 additions & 6 deletions docs_theme/main.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{% extends "base.html" %}

{% block search_button %}
<form class="mkdocs-search" action="{{ base_url }}/search.html">
<input type="text" name="q" placeholder="Search docs" title="Type search term here">
<button class="icon icon-search" aria-label="submit"></button>
</form>
{% endblock %}
{%- block search_button %}
{% if 'search' in config['plugins'] %}
<div role="search">
<form id ="rtd-search-form" class="wy-form mkdocs-search" action="{{ base_url }}/search.html" method="get">
<input type="text" name="q" placeholder="Search docs" title="Type search term here" />
<button class="icon icon-search" aria-label="submit"></button>
</form>
</div>
{% endif %}
{%- endblock %}
29 changes: 29 additions & 0 deletions docs_theme/search.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% extends "main.html" %}

{% block content %}

<div role="search">
<form id ="content_search" class="wy-form mkdocs-search" action="{{ base_url }}/search.html" method="get">

<span role="status" aria-live="polite" class="ui-helper-hidden-accessible"></span>
<input
name="q"
id="mkdocs-search-query"
type="text"
class="search_input search-query ui-autocomplete-input"
placeholder="Search the Docs"
autocomplete="off"
autofocus
title="Type search term here"
>
<button class="icon icon-search" aria-label="submit"></button>
</form>
</div>

<h1 id="search">Results</h1>

<div id="mkdocs-search-results" class="search-results">
Searching...
</div>

{% endblock %}