From 6da5715958b04f4d549db6a2e07e5e5d4ad78ef1 Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Wed, 11 Sep 2024 03:20:45 -0700 Subject: [PATCH] A11Y: Add title attribute to theme switcher (#1924) Co-authored-by: Tania Allard --- .../pydata_sphinx_theme/components/theme-switcher.html | 8 ++++---- tests/test_build.py | 10 +++++++++- tests/test_build/navbar_theme.html | 8 ++++---- tests/test_build/sidebar_subpage.html | 8 ++++---- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/theme-switcher.html b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/theme-switcher.html index 0dc060df3..5b25d800d 100644 --- a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/theme-switcher.html +++ b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/theme-switcher.html @@ -1,7 +1,7 @@ {# Displays an icon to switch between light mode, dark mode, and auto (use browser's setting). #} {# As the theme switcher will only work when JavaScript is enabled, we hide it with `pst-js-only`. #} - diff --git a/tests/test_build.py b/tests/test_build.py index f782e4751..47045c617 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -997,7 +997,15 @@ def test_translations(sphinx_build_factory) -> None: assert "Modifier sur GitHub" in str(sidebar_secondary) header = index.select(".bd-header")[0] - assert "clair/sombre" in str(header) + ## TODO: update once translataion up to date + # assert "clair/sombre" in str(header) + # Text of theme switcher button have been changed, + # "light/dark" has been updated to "Color mode" and does not have a translation yet. + if "Color mode" not in str(header): + pytest.xfail( + "Please update test_build.py::test_translations now that new translation are available." + ) + # End TODO footer = index.select(".bd-footer")[0] assert "Copyright" in str(footer) diff --git a/tests/test_build/navbar_theme.html b/tests/test_build/navbar_theme.html index bd61854c8..b17a4297d 100644 --- a/tests/test_build/navbar_theme.html +++ b/tests/test_build/navbar_theme.html @@ -1,8 +1,8 @@ - diff --git a/tests/test_build/sidebar_subpage.html b/tests/test_build/sidebar_subpage.html index 320f487f3..54a4a2e49 100644 --- a/tests/test_build/sidebar_subpage.html +++ b/tests/test_build/sidebar_subpage.html @@ -33,12 +33,12 @@