Skip to content

Commit

Permalink
fix(theme-classic): hamburger menu control navigation by keyboard (#8207
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jeferson-sb authored and slorber committed Oct 28, 2022
1 parent e5fb257 commit a9b622b
Show file tree
Hide file tree
Showing 30 changed files with 96 additions and 6 deletions.
Expand Up @@ -7,6 +7,7 @@

import React from 'react';
import {useNavbarMobileSidebar} from '@docusaurus/theme-common/internal';
import {translate} from '@docusaurus/Translate';
import NavbarColorModeToggle from '@theme/Navbar/ColorModeToggle';
import IconClose from '@theme/Icon/Close';
import NavbarLogo from '@theme/Navbar/Logo';
Expand All @@ -16,6 +17,11 @@ function CloseButton() {
return (
<button
type="button"
aria-label={translate({
id: 'theme.docs.sidebar.closeSidebarButtonAriaLabel',
message: 'Close navigation bar',
description: 'The ARIA label for close button of mobile sidebar',
})}
className="clean-btn navbar-sidebar__close"
onClick={() => mobileSidebar.toggle()}>
<IconClose color="var(--ifm-color-emphasis-600)" />
Expand Down
Expand Up @@ -7,18 +7,23 @@

import React from 'react';
import {useNavbarMobileSidebar} from '@docusaurus/theme-common/internal';
import {translate} from '@docusaurus/Translate';
import IconMenu from '@theme/Icon/Menu';

export default function MobileSidebarToggle(): JSX.Element {
const mobileSidebar = useNavbarMobileSidebar();
const {toggle, shown} = useNavbarMobileSidebar();
return (
<button
onClick={mobileSidebar.toggle}
onKeyDown={mobileSidebar.toggle}
aria-label="Navigation bar toggle"
onClick={toggle}
aria-label={translate({
id: 'theme.docs.sidebar.toggleSidebarButtonAriaLabel',
message: 'Toggle navigation bar',
description:
'The ARIA label for hamburger menu button of mobile navigation',
})}
aria-expanded={shown}
className="navbar__toggle clean-btn"
type="button"
tabIndex={0}>
type="button">
<IconMenu />
</button>
);
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "التنقل بين صفحات الددات",
"theme.docs.paginator.next": "التالى",
"theme.docs.paginator.previous": "السابق",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "طي الشريط الجانبي",
"theme.docs.sidebar.collapseButtonTitle": "طي الشريط الجانبي",
"theme.docs.sidebar.expandButtonAriaLabel": "توسيع الشريط الجانبي",
"theme.docs.sidebar.expandButtonTitle": "توسيع الشريط الجانبي",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} مستند موسوم بـ \"{tagName}\"",
"theme.docs.tagDocListPageTitle.nDocsTagged": "مستند موسوم واحد|{count} مستندات موسومة",
"theme.docs.versionBadge.label": "الأصدار: {versionLabel}",
Expand Down
Expand Up @@ -87,6 +87,8 @@
"theme.docs.paginator.next___DESCRIPTION": "The label used to navigate to the next doc",
"theme.docs.paginator.previous": "Previous",
"theme.docs.paginator.previous___DESCRIPTION": "The label used to navigate to the previous doc",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.closeSidebarButtonAriaLabel___DESCRIPTION": "The ARIA label for close button of mobile sidebar",
"theme.docs.sidebar.collapseButtonAriaLabel": "Collapse sidebar",
"theme.docs.sidebar.collapseButtonAriaLabel___DESCRIPTION": "The title attribute for collapse button of doc sidebar",
"theme.docs.sidebar.collapseButtonTitle": "Collapse sidebar",
Expand All @@ -95,6 +97,8 @@
"theme.docs.sidebar.expandButtonAriaLabel___DESCRIPTION": "The ARIA label and title attribute for expand button of doc sidebar",
"theme.docs.sidebar.expandButtonTitle": "Expand sidebar",
"theme.docs.sidebar.expandButtonTitle___DESCRIPTION": "The ARIA label and title attribute for expand button of doc sidebar",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel___DESCRIPTION": "The ARIA label for hamburger menu button of mobile navigation",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} with \"{tagName}\"",
"theme.docs.tagDocListPageTitle___DESCRIPTION": "The title of the page for a docs tag",
"theme.docs.tagDocListPageTitle.nDocsTagged": "One doc tagged|{count} docs tagged",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "ডক্স পৃষ্টাগুলির নেভিগেশন",
"theme.docs.paginator.next": "পরবর্তী",
"theme.docs.paginator.previous": "পূর্ববর্তী",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "সাইডবারটি সঙ্কুচিত করুন",
"theme.docs.sidebar.collapseButtonTitle": "সাইডবারটি সঙ্কুচিত করুন",
"theme.docs.sidebar.expandButtonAriaLabel": "সাইডবারটি প্রসারিত করুন",
"theme.docs.sidebar.expandButtonTitle": "সাইডবারটি প্রসারিত করুন",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} with \"{tagName}\"",
"theme.docs.tagDocListPageTitle.nDocsTagged": "One doc tagged|{count} docs tagged",
"theme.docs.versionBadge.label": "Version: {versionLabel}",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "Stránkování dokumentace",
"theme.docs.paginator.next": "Další",
"theme.docs.paginator.previous": "Předchozí",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "Zavřít postranní lištu",
"theme.docs.sidebar.collapseButtonTitle": "Zavřít postranní lištu",
"theme.docs.sidebar.expandButtonAriaLabel": "Otevřít postranní lištu",
"theme.docs.sidebar.expandButtonTitle": "Otevřít postranní lištu",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} with \"{tagName}\"",
"theme.docs.tagDocListPageTitle.nDocsTagged": "One doc tagged|{count} docs tagged",
"theme.docs.versionBadge.label": "Version: {versionLabel}",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "Dokumentside navigation",
"theme.docs.paginator.next": "Næste",
"theme.docs.paginator.previous": "Tidligere",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "Sammenlæg sidenavigation",
"theme.docs.sidebar.collapseButtonTitle": "Sammenlæg sidenavigation",
"theme.docs.sidebar.expandButtonAriaLabel": "Udvid sidenavigation",
"theme.docs.sidebar.expandButtonTitle": "Udvid sidenavigation",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} with \"{tagName}\"",
"theme.docs.tagDocListPageTitle.nDocsTagged": "One doc tagged|{count} docs tagged",
"theme.docs.versionBadge.label": "Version: {versionLabel}",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "Dokumentation Seiten Navigation",
"theme.docs.paginator.next": "Weiter",
"theme.docs.paginator.previous": "Zurück",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "Seitenleiste einklappen",
"theme.docs.sidebar.collapseButtonTitle": "Seitenleiste einklappen",
"theme.docs.sidebar.expandButtonAriaLabel": "Seitenleiste ausklappen",
"theme.docs.sidebar.expandButtonTitle": "Seitenleiste ausklappen",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} mit \"{tagName}\"",
"theme.docs.tagDocListPageTitle.nDocsTagged": "Ein doc getaggt|{count} docs getaggt",
"theme.docs.versionBadge.label": "Version: {versionLabel}",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "Navegación de páginas de documentos",
"theme.docs.paginator.next": "Siguiente",
"theme.docs.paginator.previous": "Anterior",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "Colapsar barra lateral",
"theme.docs.sidebar.collapseButtonTitle": "Colapsar barra lateral",
"theme.docs.sidebar.expandButtonAriaLabel": "Expandir barra lateral",
"theme.docs.sidebar.expandButtonTitle": "Expandir barra lateral",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} con \"{tagName}\"",
"theme.docs.tagDocListPageTitle.nDocsTagged": "Un documento etiquetado|{count} documentos etiquetados",
"theme.docs.versionBadge.label": "Version: {versionLabel}",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "کنترل صفحات مطالب",
"theme.docs.paginator.next": "بعدی",
"theme.docs.paginator.previous": "قبلی",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "بستن نوار کناری",
"theme.docs.sidebar.collapseButtonTitle": "بستن نوار کناری",
"theme.docs.sidebar.expandButtonAriaLabel": "باز کردن نوار کناری",
"theme.docs.sidebar.expandButtonTitle": "باز کردن نوار کناری",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} با \"{tagName}\"",
"theme.docs.tagDocListPageTitle.nDocsTagged": "یک مطلب برچسب شده|{count} مطلب برچسب شده",
"theme.docs.versionBadge.label": "نسخه: {versionLabel}",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "Nabegasyón para sa mga pahinang docs.",
"theme.docs.paginator.next": "Sumunod",
"theme.docs.paginator.previous": "Naraaan",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "Itupî ang sidebar",
"theme.docs.sidebar.collapseButtonTitle": "Itupî ang sidebar",
"theme.docs.sidebar.expandButtonAriaLabel": "Palakihin ang sidebar",
"theme.docs.sidebar.expandButtonTitle": "Palakihin ang sidebar",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} with \"{tagName}\"",
"theme.docs.tagDocListPageTitle.nDocsTagged": "One doc tagged|{count} docs tagged",
"theme.docs.versionBadge.label": "Version: {versionLabel}",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "Pagination des documents",
"theme.docs.paginator.next": "Suivant",
"theme.docs.paginator.previous": "Précédent",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "Réduire le menu latéral",
"theme.docs.sidebar.collapseButtonTitle": "Réduire le menu latéral",
"theme.docs.sidebar.expandButtonAriaLabel": "Déplier le menu latéral",
"theme.docs.sidebar.expandButtonTitle": "Déplier le menu latéral",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} avec \"{tagName}\"",
"theme.docs.tagDocListPageTitle.nDocsTagged": "Un document tagué|{count} documents tagués",
"theme.docs.versionBadge.label": "Version: {versionLabel}",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "רשימת דוקומנטאציה",
"theme.docs.paginator.next": "הבא",
"theme.docs.paginator.previous": "הקודם",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "סגור",
"theme.docs.sidebar.collapseButtonTitle": "סגור",
"theme.docs.sidebar.expandButtonAriaLabel": "פתח",
"theme.docs.sidebar.expandButtonTitle": "פתח",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} with \"{tagName}\"",
"theme.docs.tagDocListPageTitle.nDocsTagged": "One doc tagged|{count} docs tagged",
"theme.docs.versionBadge.label": "Version: {versionLabel}",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "डॉक्स पेज नेविगेशन",
"theme.docs.paginator.next": "अगला",
"theme.docs.paginator.previous": "पिछ्ला",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "साइडबार बंद करें",
"theme.docs.sidebar.collapseButtonTitle": "साइडबार बंद करें",
"theme.docs.sidebar.expandButtonAriaLabel": "साइडबार खोलें",
"theme.docs.sidebar.expandButtonTitle": "साइडबार खोलें",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} with \"{tagName}\"",
"theme.docs.tagDocListPageTitle.nDocsTagged": "One doc tagged|{count} docs tagged",
"theme.docs.versionBadge.label": "Version: {versionLabel}",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "Navigazione delle pagine dei documenti",
"theme.docs.paginator.next": "Successivo",
"theme.docs.paginator.previous": "Precedente",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "Collassa la barra laterale",
"theme.docs.sidebar.collapseButtonTitle": "Collassa la barra laterale",
"theme.docs.sidebar.expandButtonAriaLabel": "Espandi la barra laterale",
"theme.docs.sidebar.expandButtonTitle": "Espandi la barra laterale",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} con \"{tagName}\"",
"theme.docs.tagDocListPageTitle.nDocsTagged": "Un documento etichettato|{count} documenti etichettati",
"theme.docs.versionBadge.label": "Version: {versionLabel}",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "ドキュメントのナビゲーション",
"theme.docs.paginator.next": "次へ",
"theme.docs.paginator.previous": "前へ",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "サイドバーを隠す",
"theme.docs.sidebar.collapseButtonTitle": "サイドバーを隠す",
"theme.docs.sidebar.expandButtonAriaLabel": "サイドバーを開く",
"theme.docs.sidebar.expandButtonTitle": "サイドバーを開く",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "「{tagName}」タグのついた{nDocsTagged}",
"theme.docs.tagDocListPageTitle.nDocsTagged": "{count}記事",
"theme.docs.versionBadge.label": "バージョン: {versionLabel}",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "문서 탐색",
"theme.docs.paginator.next": "다음",
"theme.docs.paginator.previous": "이전",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "사이드바 숨기기",
"theme.docs.sidebar.collapseButtonTitle": "사이드바 숨기기",
"theme.docs.sidebar.expandButtonAriaLabel": "사이드바 열기",
"theme.docs.sidebar.expandButtonTitle": "사이드바 열기",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} \"{tagName}\" 태그에 분류되었습니다",
"theme.docs.tagDocListPageTitle.nDocsTagged": "{count}개 문서가",
"theme.docs.versionBadge.label": "버전: {versionLabel}",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "Paginanavigatie documentatie",
"theme.docs.paginator.next": "Volgende",
"theme.docs.paginator.previous": "Vorige",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "Zijbalk inklappen",
"theme.docs.sidebar.collapseButtonTitle": "Zijbalk inklappen",
"theme.docs.sidebar.expandButtonAriaLabel": "Zijbalk uitklappen",
"theme.docs.sidebar.expandButtonTitle": "Zijbalk uitklappen",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} met \"{tagName}\"",
"theme.docs.tagDocListPageTitle.nDocsTagged": "Een artikel getagd|{count} artikelen getagd",
"theme.docs.versionBadge.label": "Versie: {versionLabel}",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "Nawigacja na stronie dokumentacji",
"theme.docs.paginator.next": "Następna strona",
"theme.docs.paginator.previous": "Poprzednia strona",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "Zwiń boczny panel",
"theme.docs.sidebar.collapseButtonTitle": "Zwiń boczny panel",
"theme.docs.sidebar.expandButtonAriaLabel": "Rozszerz boczny panel",
"theme.docs.sidebar.expandButtonTitle": "Rozszerz boczny panel",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} with \"{tagName}\"",
"theme.docs.tagDocListPageTitle.nDocsTagged": "Jedna strona dokumentacji otagowana|{count} strony dokumentacji otagowane|{count} stron dokumentacji otagowanych",
"theme.docs.versionBadge.label": "Wersja: {versionLabel}",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "Navigação das páginas de documentação",
"theme.docs.paginator.next": "Próxima",
"theme.docs.paginator.previous": "Anterior",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "Fechar painel lateral",
"theme.docs.sidebar.collapseButtonTitle": "Fechar painel lateral",
"theme.docs.sidebar.expandButtonAriaLabel": "Expandir painel lateral",
"theme.docs.sidebar.expandButtonTitle": "Expandir painel lateral",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} com \"{tagName}\"",
"theme.docs.tagDocListPageTitle.nDocsTagged": "Um documento selecionado|{count} documentos selecionados",
"theme.docs.versionBadge.label": "Version: {versionLabel}",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "Navigação das páginas de documentação",
"theme.docs.paginator.next": "Próxima",
"theme.docs.paginator.previous": "Anterior",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "Colapsar barra lateral",
"theme.docs.sidebar.collapseButtonTitle": "Colapsar barra lateral",
"theme.docs.sidebar.expandButtonAriaLabel": "Expandir barra lateral",
"theme.docs.sidebar.expandButtonTitle": "Expandir barra lateral",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} with \"{tagName}\"",
"theme.docs.tagDocListPageTitle.nDocsTagged": "One doc tagged|{count} docs tagged",
"theme.docs.versionBadge.label": "Version: {versionLabel}",
Expand Down
Expand Up @@ -43,10 +43,12 @@
"theme.docs.paginator.navAriaLabel": "Навигация по странице документации",
"theme.docs.paginator.next": "Следующая страница",
"theme.docs.paginator.previous": "Предыдущая страница",
"theme.docs.sidebar.closeSidebarButtonAriaLabel": "Close navigation bar",
"theme.docs.sidebar.collapseButtonAriaLabel": "Свернуть сайдбар",
"theme.docs.sidebar.collapseButtonTitle": "Свернуть сайдбар",
"theme.docs.sidebar.expandButtonAriaLabel": "Развернуть сайдбар",
"theme.docs.sidebar.expandButtonTitle": "Развернуть сайдбар",
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
"theme.docs.tagDocListPageTitle": "{nDocsTagged} с тегом \"{tagName}\"",
"theme.docs.tagDocListPageTitle.nDocsTagged": "Одна страница|{count} страницы|{count} страниц",
"theme.docs.versionBadge.label": "Версия: {versionLabel}",
Expand Down

0 comments on commit a9b622b

Please sign in to comment.