Skip to content

Create a 'search field' component for themes #11045

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

Merged
merged 1 commit into from
Apr 21, 2023
Merged
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 doc/_themes/sphinx13/layout.html
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ <h3>{{ _('Navigation') }}</h3>
{%- block content %}
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
{%- include "searchbox.html" %}
{%- include "searchfield.html" %}
<div class="sphinxsidebar-navigation__contents">
<h3>{{ _('On this page') }}</h3>
{{ toc }}
5 changes: 5 additions & 0 deletions doc/_themes/sphinx13/static/sphinx13.css
Original file line number Diff line number Diff line change
@@ -68,6 +68,7 @@ div.sphinxsidebar {
overflow-wrap: break-word;
margin: 0;
padding-right: 15px;
padding-top: 0.5em;
font-size: 1em;
}

@@ -127,6 +128,10 @@ div.sphinxsidebar li.current > a {
display: none;
}

div.sphinxsidebar #searchbox {
margin: 12px 0 20px 0;
}

div.footer {
background-color: var(--colour-sphinx-blue);
color: #ccc;
23 changes: 23 additions & 0 deletions sphinx/themes/basic/searchfield.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{#
basic/searchfield.html
~~~~~~~~~~~~~~~~~~~~~~

Sphinx sidebar template: search field.
This component is similar to searchbox.html but does not include an
extra heading ("Quick search"). Instead, it uses a placeholder text
in the search field.

:copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
#}
{%- if pagename != "search" and builder != "singlehtml" %}
<div id="searchbox" style="display: none" role="search">
<div class="searchformwrapper">
<form class="search" action="{{ pathto('search') }}" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" placeholder="Search"/>
<input type="submit" value="{{ _('Go') }}" />
</form>
</div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>
{%- endif %}