Skip to content

Commit bcb78b6

Browse files
authored
Merge pull request #44 from septatrix/dark-theme
2 parents 93cb464 + 84f34ae commit bcb78b6

File tree

6 files changed

+308
-164
lines changed

6 files changed

+308
-164
lines changed

python_docs_theme/layout.html

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ <h3>{{ _('Navigation') }}</h3>
3737
{{ reldelim2 }}
3838
</li>
3939
{%- endif %}
40+
<li class="right">{{ themeselector() }}{{ reldelim2 }}</li>
4041
{% endblock %}
4142
</ul>
4243
</div>
@@ -47,25 +48,35 @@ <h3>{{ _('Navigation') }}</h3>
4748
{%- if builder != "htmlhelp" %}
4849
<div class="inline-search" role="search">
4950
<form class="inline-search" action="{{ pathto('search') }}" method="get">
50-
<input placeholder="{{ _('Quick search') }}" aria-label="{{ _('Quick search') }}" type="text" name="q" />
51+
<input placeholder="{{ _('Quick search') }}" aria-label="{{ _('Quick search') }}" type="search" name="q" />
5152
<input type="submit" value="{{ _('Go') }}" />
52-
<input type="hidden" name="check_keywords" value="yes" />
53-
<input type="hidden" name="area" value="default" />
5453
</form>
5554
</div>
5655
{%- endif %}
5756
{%- endmacro %}
5857

58+
{%- macro themeselector() %}
59+
<label class="theme-selector-label">
60+
{{ _('Theme') }}
61+
<select class="theme-selector" oninput="activateTheme(this.value)">
62+
<option value="auto" selected>{{ _('Auto') }}</option>
63+
<option value="light">{{ _('Light') }}</option>
64+
<option value="dark">{{ _('Dark') }}</option>
65+
</select>
66+
</label>
67+
{%- endmacro %}
68+
5969
{% block relbar1 %} {% if builder != 'qthelp' %} {{ relbar() }} {% endif %} {% endblock %}
6070
{% block relbar2 %} {% if builder != 'qthelp' %} {{ relbar() }} {% endif %} {% endblock %}
6171

62-
6372
{%- block extrahead -%}
73+
<link rel="stylesheet" href="{{ pathto('_static/pydoctheme_dark.css', 1) }}" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
6474
<link rel="shortcut icon" type="image/png" href="{{ pathto('_static/' + theme_root_icon, 1) }}" />
6575
{%- if builder != "htmlhelp" %}
6676
{%- if not embedded %}
6777
<script type="text/javascript" src="{{ pathto('_static/copybutton.js', 1) }}"></script>
6878
<script type="text/javascript" src="{{ pathto('_static/menu.js', 1) }}"></script>
79+
<script type="text/javascript" src="{{ pathto('_static/themetoggle.js', 1) }}"></script>
6980
{%- endif -%}
7081
{%- endif -%}
7182
{{ super() }}
@@ -82,28 +93,30 @@ <h3>{{ _('Navigation') }}</h3>
8293
<div class="mobile-nav">
8394
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
8495
aria-pressed="false" aria-expanded="false" role="button" aria-label="{{ _('Menu')}}" />
85-
<label for="menuToggler" class="toggler__label">
86-
<span></span>
87-
</label>
8896
<nav class="nav-content" role="navigation">
89-
<a href="{{ theme_root_url }}" class="nav-logo">
90-
<img src="{{ pathto('_static/py.svg', 1) }}" alt="Logo"/>
91-
</a>
92-
<div class="version_switcher_placeholder"></div>
93-
{%- if pagename != "search" and builder != "singlehtml" %}
94-
<form role="search" class="search" action="{{ pathto('search') }}" method="get">
95-
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
96-
<path fill-rule="nonzero"
97-
d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" fill="#444"></path>
98-
</svg>
99-
<input type="text" name="q" aria-label="{{ _('Quick search') }}"/>
100-
<input type="submit" value="{{ _('Go') }}"/>
101-
</form>
102-
{%- endif %}
97+
<label for="menuToggler" class="toggler__label">
98+
<span></span>
99+
</label>
100+
<span class="nav-items-wrapper">
101+
<a href="{{ theme_root_url }}" class="nav-logo">
102+
<img src="{{ pathto('_static/py.svg', 1) }}" alt="Logo"/>
103+
</a>
104+
<span class="version_switcher_placeholder"></span>
105+
{%- if pagename != "search" and builder != "singlehtml" %}
106+
<form id="searchbox" role="search" class="search" action="{{ pathto('search') }}" method="get">
107+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
108+
<path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
109+
</svg>
110+
<input placeholder="{{ _('Quick search') }}" aria-label="{{ _('Quick search') }}" type="search" name="q" />
111+
<input type="submit" value="{{ _('Go') }}"/>
112+
</form>
113+
{%- endif %}
114+
</span>
103115
</nav>
104116
<div class="menu-wrapper">
105117
<nav class="menu" role="navigation" aria-label="main navigation">
106118
<div class="language_switcher_placeholder"></div>
119+
{{ themeselector() }}
107120
{%- if logo %}
108121
<p class="logo">
109122
<a href="{{ pathto('index') }}">

python_docs_theme/static/caret-down.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy