Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork66
Make the theme responsive#46
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
24 commits Select commitHold shift + click to select a range
7aba474
Make theme responsive
obulat203b40a
Address code review issues
obulat10f4349
Use css for opening/closing menu
obulatff61d60
Adjust font and selects
obulat7640739
Add language and version switcher placeholders
obulatecf73cf
Remove duplicate rootrellink declaration
obulat43da2b4
Remove dublicate relbaritems block
obulat51a0c7a
Update select styles
obulatefd1ec2
Add missing select styles
obulat7953f1b
Change the search icon color
obulat6daa876
Change caret color
obulat250dbf6
Change hamburger color
obulat5ffa114
Add an svg icon
obulate1ee8bd
Add svg logo to layout
obulat1e182f3
Merge remote-tracking branch 'upstream/master'
obulat611a1dc
Add switchers to desktop view
obulat783b19a
Fix toggler accessibility and select paddings
obulatd31371e
Fix html formatting
obulat190931b
Add link to homepage in mobile version
obulatb6fc448
Add smaller padding to toctree
obulatcd92c8c
Add a different link to the logo
obulated7b948
Make logo in mobile version link to 'http://0.0.0.0:8000/3.9/'
obulatd96713e
Make logo in mobile version link to 'http://0.0.0.0:8000/3.9/'
obulatbd1d802
Make logo in mobile version link to theme root
obulatFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
121 changes: 98 additions & 23 deletionspython_docs_theme/layout.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,121 @@ | ||
{% extends "classic/layout.html" %} | ||
{%- macro relbar() %} | ||
{# modified from sphinx/themes/basic/layout.html #} | ||
<div class="related" role="navigation" aria-label="related navigation"> | ||
<h3>{{ _('Navigation') }}</h3> | ||
<ul> | ||
{%- for rellink in rellinks %} | ||
<li class="right" {% if loop.first %}style="margin-right: 10px"{% endif %}> | ||
<a href="{{ pathto(rellink[0])|e }}" title="{{ rellink[1]|striptags|e }}" | ||
{{ accesskey(rellink[2]) }}>{{ rellink[3] }} | ||
</a> | ||
{%- if not loop.first %}{{ reldelim2 }}{% endif %} | ||
</li> | ||
{%- endfor %} | ||
{%- block rootrellink %} | ||
<li><img src="{{ pathto('_static/py.svg', 1) }}" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li> | ||
<li><a href="{{theme_root_url}}">{{theme_root_name}}</a>{{ reldelim1 }}</li> | ||
<li class="switchers"> | ||
<div class="language_switcher_placeholder"></div> | ||
<div class="version_switcher_placeholder"></div> | ||
</li> | ||
<li> | ||
{% if theme_root_include_title %} | ||
<a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }} | ||
{% endif %} | ||
</li> | ||
{%- endblock %} | ||
{%- for parent in parents %} | ||
<li class="nav-item nav-item-{{ loop.index }}"><a href="{{ parent.link|e }}" {% if loop.last %}{{ accesskey("U") }}{% endif %}>{{ parent.title }}</a>{{ reldelim1 }}</li> | ||
{%- endfor %} | ||
<li class="nav-item nav-item-this"><a href="{{ link|e }}">{{ title }}</a></li> | ||
{% block relbaritems %} | ||
{%- if pagename != "search" and builder != "singlehtml" and builder != "htmlhelp" %} | ||
<li class="right"> | ||
{{ searchbox() }} | ||
{{ reldelim2 }} | ||
</li> | ||
{%- endif %} | ||
{% endblock %} | ||
</ul> | ||
</div> | ||
{%- endmacro %} | ||
{%- macro searchbox() %} | ||
{# modified from sphinx/themes/basic/searchbox.html #} | ||
{%- if builder != "htmlhelp" %} | ||
<div class="inline-search" role="search"> | ||
<form class="inline-search" action="{{ pathto('search') }}" method="get"> | ||
<input placeholder="{{ _('Quick search') }}"aria-label="{{ _('Quick search') }}"type="text" name="q" /> | ||
<input type="submit" value="{{ _('Go') }}" /> | ||
<input type="hidden" name="check_keywords" value="yes" /> | ||
<input type="hidden" name="area" value="default" /> | ||
</form> | ||
</div> | ||
{%- endif %} | ||
{%- endmacro %} | ||
{% block relbar1 %} {% if builder != 'qthelp' %} {{ relbar() }} {% endif %} {% endblock %} | ||
{% block relbar2 %} {% if builder != 'qthelp' %} {{ relbar() }} {% endif %} {% endblock %} | ||
{%- block extrahead -%} | ||
<link rel="shortcut icon" type="image/png" href="{{ pathto('_static/' + theme_root_icon, 1) }}" /> | ||
{%- if builder != "htmlhelp" %} | ||
{%- if not embedded %} | ||
<script type="text/javascript" src="{{ pathto('_static/copybutton.js', 1) }}"></script> | ||
<script type="text/javascript" src="{{ pathto('_static/menu.js', 1) }}"></script> | ||
{%- endif -%} | ||
{%- endif -%} | ||
{{ super() }} | ||
{%- endblock -%} | ||
{%- block css -%} | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
obulat marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
{{ super() }} | ||
{%- endblock -%} | ||
{%- block body_tag %} | ||
{{ super() }} | ||
<div class="mobile-nav"> | ||
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation" | ||
aria-pressed="false" aria-expanded="false" role="button" aria-label="{{ _('Menu')}}" /> | ||
<label for="menuToggler" class="toggler__label"> | ||
<span></span> | ||
</label> | ||
<nav class="nav-content" role="navigation"> | ||
<a href="{{ theme_root_url }}" class="nav-logo"> | ||
<img src="{{ pathto('_static/py.svg', 1) }}" alt="Logo"/> | ||
</a> | ||
<div class="version_switcher_placeholder"></div> | ||
{%- if pagename != "search" and builder != "singlehtml" %} | ||
<form id="searchbox" role="search" class="search" action="{{ pathto('search') }}" method="get"> | ||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon"> | ||
<path fill-rule="nonzero" | ||
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> | ||
</svg> | ||
<input type="text" name="q" aria-label="{{ _('Quick search') }}"/> | ||
<input type="submit" value="{{ _('Go') }}"/> | ||
</form> | ||
{%- endif %} | ||
</nav> | ||
<div class="menu-wrapper"> | ||
<nav class="menu" role="navigation" aria-label="main navigation"> | ||
<div class="language_switcher_placeholder"></div> | ||
{%- if logo %} | ||
<p class="logo"> | ||
<a href="{{ pathto('index') }}"> | ||
<img class="logo" src="{{ pathto('_static/' + logo, 1)|e }}" alt="Logo"/> | ||
</a> | ||
</p> | ||
{%- endif %} | ||
{%- for sidebartemplate in sidebars %} | ||
{%- include sidebartemplate %} | ||
{%- endfor %} | ||
</nav> | ||
</div> | ||
</div> | ||
{% endblock %} | ||
{% block footer %} | ||
1 change: 1 addition & 0 deletionspython_docs_theme/static/caret-down.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletionspython_docs_theme/static/menu.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
// Make tables responsive by wrapping them in a div and making them scrollable | ||
const tables = document.querySelectorAll('table.docutils'); | ||
tables.forEach(function(table){ | ||
table.outerHTML = '<div class="responsive-table__container">' + table.outerHTML + '</div>' | ||
}); | ||
const togglerInput = document.querySelector('.toggler__input'); | ||
const togglerLabel = document.querySelector('.toggler__label'); | ||
const sideMenu = document.querySelector('.menu-wrapper'); | ||
const menuItems = document.querySelectorAll('.menu') | ||
const doc = document.querySelector('.document'); | ||
const body = document.querySelector('body'); | ||
function closeMenu() { | ||
togglerInput.checked = false; | ||
sideMenu.setAttribute("aria-expanded", 'false'); | ||
sideMenu.setAttribute('aria-hidden', 'true'); | ||
togglerLabel.setAttribute('aria-pressed', 'false'); | ||
body.style.overflow = 'visible'; | ||
} | ||
function openMenu() { | ||
togglerInput.checked = true; | ||
sideMenu.setAttribute("aria-expanded", 'true'); | ||
sideMenu.setAttribute('aria-hidden', 'false'); | ||
togglerLabel.setAttribute('aria-pressed', 'true'); | ||
body.style.overflow = 'hidden'; | ||
} | ||
// Close menu when link on the sideMenu is clicked | ||
sideMenu.addEventListener('click', function (event) { | ||
let target = event.target; | ||
if (target.tagName.toLowerCase() !== 'a') return; | ||
closeMenu(); | ||
}) | ||
// Add accessibility data when sideMenu is opened/closed | ||
togglerInput.addEventListener('change', function (e) { | ||
togglerInput.checked ? openMenu() : closeMenu(); | ||
}); | ||
// Make sideMenu links tabbable only when visible | ||
for(let menuItem of menuItems) { | ||
if(togglerInput.checked) { | ||
menuItem.setAttribute('tabindex', '0'); | ||
} else { | ||
menuItem.setAttribute('tabindex', '-1'); | ||
} | ||
} | ||
// Close sideMenu when document body is clicked | ||
doc.addEventListener('click', function () { | ||
if (togglerInput.checked) { | ||
closeMenu(); | ||
} | ||
}) | ||
}) |
14 changes: 14 additions & 0 deletionspython_docs_theme/static/py.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.