Skip to content

Commit 5e53589

Browse files
authored
Fix landmarks (#1454)
* add header * fix nav landmarks * only one main * label indices nav * few landmarks * unique id todos * fix test fixtures * fix translations * translations? * make version warning a landmark * revert translation changes * revert changes to noxfile.py * update tests to reflect translation reversal * add TODO comment to make string translatable
1 parent 2714005 commit 5e53589

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,9 @@ function showVersionWarningBanner(data) {
468468
return;
469469
}
470470
// now construct the warning banner
471-
var outer = document.createElement("div");
471+
var outer = document.createElement("aside");
472+
// TODO: add to translatable strings
473+
outer.setAttribute("aria-label", "Version warning");
472474
const middle = document.createElement("div");
473475
const inner = document.createElement("div");
474476
const bold = document.createElement("strong");
@@ -504,7 +506,8 @@ function showVersionWarningBanner(data) {
504506
inner.appendChild(bold);
505507
inner.appendChild(document.createTextNode("."));
506508
inner.appendChild(button);
507-
document.body.prepend(outer);
509+
const skipLink = document.getElementById("pst-skip-link");
510+
skipLink.after(outer);
508511
}
509512

510513
/*******************************************************************************

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/indices.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{# Displays links to the Sphinx-generated indices (genindex, modindex, py-modindex). #}
2-
<nav class="sidebar-indices-items">
3-
<p class="sidebar-indices-items__title" role="heading" aria-level="1">{{ _("Indices") }}</p>
2+
{%- set indices_navigation_heading_id = unique_html_id("pst-indices-navigation-heading") -%}
3+
<nav class="sidebar-indices-items" aria-labelledby="{{ indices_navigation_heading_id }}">
4+
<p id="{{ indices_navigation_heading_id }}" class="sidebar-indices-items__title" role="heading" aria-level="1">{{ _("Indices") }}</p>
45
<ul class="indices-link">
56
{%- for rellink in rellinks %}
67
{%- if rellink[0] == 'genindex' %}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{# Displays the current page's Table of Contents. #}
22
{% set page_toc = generate_toc_html() %}
33
{%- if page_toc | length >= 1 %}
4-
<div class="page-toc tocsection onthispage">
4+
{%- set page_navigation_heading_id = unique_html_id("pst-page-navigation-heading") -%}
5+
<div
6+
id="{{ page_navigation_heading_id }}"
7+
class="page-toc tocsection onthispage">
58
<i class="fa-solid fa-list"></i> {{ _("On this page") }}
69
</div>
7-
<nav class="bd-toc-nav page-toc">
10+
<nav class="bd-toc-nav page-toc" aria-labelledby="{{ page_navigation_heading_id }}">
811
{{ page_toc }}
912
</nav>
1013
{%- endif %}

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html

+8-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
{# A button hidden by default to help assistive devices quickly jump to main content #}
5252
{# ref: https://www.youtube.com/watch?v=VUR0I5mqq7I #}
53-
<a class="skip-link" href="#main-content">{{ _("Skip to main content") }}</a>
53+
<a id="pst-skip-link" class="skip-link" href="#main-content">{{ _("Skip to main content") }}</a>
5454

5555
{%- endblock %}
5656

@@ -81,14 +81,18 @@
8181
<div class="search-button__overlay"></div>
8282
<div class="search-button__search-container">{% include "../components/search-field.html" %}</div>
8383
</div>
84+
85+
<header>
8486
{%- if theme_announcement -%}
8587
{% include "sections/announcement.html" %}
8688
{%- endif %}
8789
{% block docs_navbar %}
88-
<nav class="bd-header navbar navbar-expand-lg bd-navbar">
90+
<div class="bd-header navbar navbar-expand-lg bd-navbar">
8991
{%- include "sections/header.html" %}
90-
</nav>
92+
</div>
9193
{% endblock docs_navbar %}
94+
</header>
95+
9296
<div class="bd-container">
9397
<div class="bd-container__inner bd-page-width">
9498
{# Primary sidebar #}
@@ -107,7 +111,7 @@
107111
{% block docs_body %}
108112
{# This is empty and only shows up if text has been highlighted by the URL #}
109113
{% include "components/searchbox.html" %}
110-
<article class="bd-article" role="main">
114+
<article class="bd-article">
111115
{% block body %}{% endblock %}
112116
</article>
113117
{% endblock docs_body %}

0 commit comments

Comments
 (0)