@docusaurus/theme-classic 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/lib/getSwizzleConfig.js +42 -1
  2. package/lib/theme/AnnouncementBar/styles.module.css +9 -1
  3. package/lib/theme/CodeBlock/Line/index.js +2 -4
  4. package/lib/theme/ColorModeToggle/index.js +2 -1
  5. package/lib/theme/DocBreadcrumbs/Items/Home/index.d.ts +8 -0
  6. package/lib/theme/DocBreadcrumbs/Items/Home/index.js +29 -0
  7. package/lib/theme/DocBreadcrumbs/Items/Home/styles.module.css +14 -0
  8. package/lib/theme/DocBreadcrumbs/index.js +1 -19
  9. package/lib/theme/DocBreadcrumbs/styles.module.css +0 -8
  10. package/lib/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +3 -2
  11. package/lib/theme/DocPage/Layout/Sidebar/index.js +13 -8
  12. package/lib/theme/DocPage/Layout/Sidebar/styles.module.css +7 -0
  13. package/lib/theme/DocPage/Layout/styles.module.css +1 -0
  14. package/lib/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +1 -0
  15. package/lib/theme/DocSidebar/Desktop/Content/index.js +6 -0
  16. package/lib/theme/DocSidebar/Desktop/styles.module.css +0 -6
  17. package/lib/theme/Heading/index.js +17 -8
  18. package/lib/theme/Layout/Provider/index.js +0 -2
  19. package/lib/theme/Layout/index.js +6 -1
  20. package/lib/theme/Layout/styles.module.css +2 -0
  21. package/lib/theme/MDXComponents/Code.js +24 -4
  22. package/lib/theme/MDXComponents/index.js +2 -0
  23. package/lib/theme/Mermaid.d.ts +7 -0
  24. package/lib/theme/Mermaid.js +13 -0
  25. package/lib/theme/Navbar/Layout/index.js +6 -0
  26. package/lib/theme/Navbar/MobileSidebar/Header/index.js +6 -0
  27. package/lib/theme/Navbar/MobileSidebar/Toggle/index.js +11 -6
  28. package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +4 -1
  29. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +5 -1
  30. package/lib/theme/SkipToContent/index.js +2 -18
  31. package/lib/theme/Tabs/index.js +67 -131
  32. package/lib/theme/Tag/styles.module.css +1 -1
  33. package/package.json +14 -14
  34. package/src/getSwizzleConfig.ts +47 -1
  35. package/src/theme/AnnouncementBar/styles.module.css +9 -1
  36. package/src/theme/CodeBlock/Line/index.tsx +2 -4
  37. package/src/theme/ColorModeToggle/index.tsx +2 -1
  38. package/src/theme/DocBreadcrumbs/Items/Home/index.tsx +33 -0
  39. package/src/theme/DocBreadcrumbs/Items/Home/styles.module.css +14 -0
  40. package/src/theme/DocBreadcrumbs/index.tsx +1 -20
  41. package/src/theme/DocBreadcrumbs/styles.module.css +0 -8
  42. package/src/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +3 -2
  43. package/src/theme/DocPage/Layout/Sidebar/index.tsx +13 -8
  44. package/src/theme/DocPage/Layout/Sidebar/styles.module.css +7 -0
  45. package/src/theme/DocPage/Layout/styles.module.css +1 -0
  46. package/src/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +1 -0
  47. package/src/theme/DocSidebar/Desktop/Content/index.tsx +6 -0
  48. package/src/theme/DocSidebar/Desktop/styles.module.css +0 -6
  49. package/src/theme/Heading/index.tsx +18 -8
  50. package/src/theme/Layout/Provider/index.tsx +0 -2
  51. package/src/theme/Layout/index.tsx +6 -1
  52. package/src/theme/Layout/styles.module.css +2 -0
  53. package/src/theme/MDXComponents/Code.tsx +24 -4
  54. package/src/theme/MDXComponents/index.tsx +2 -0
  55. package/src/theme/Mermaid.tsx +16 -0
  56. package/src/theme/Navbar/Layout/index.tsx +6 -0
  57. package/src/theme/Navbar/MobileSidebar/Header/index.tsx +6 -0
  58. package/src/theme/Navbar/MobileSidebar/Toggle/index.tsx +11 -6
  59. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +4 -1
  60. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +5 -1
  61. package/src/theme/SkipToContent/index.tsx +2 -18
  62. package/src/theme/Tabs/index.tsx +87 -144
  63. package/src/theme/Tag/styles.module.css +1 -1
  64. package/src/theme-classic.d.ts +18 -25
@@ -17,6 +17,13 @@ function getSwizzleConfig() {
17
17
  },
18
18
  description: 'The component used to render multi-line code blocks, generally used in Markdown files.',
19
19
  },
20
+ 'CodeBlock/Content': {
21
+ actions: {
22
+ eject: 'unsafe',
23
+ wrap: 'forbidden',
24
+ },
25
+ description: 'The folder containing components responsible for rendering different types of CodeBlock content.',
26
+ },
20
27
  ColorModeToggle: {
21
28
  actions: {
22
29
  eject: 'safe',
@@ -24,6 +31,13 @@ function getSwizzleConfig() {
24
31
  },
25
32
  description: 'The color mode toggle to switch between light and dark mode.',
26
33
  },
34
+ 'DocBreadcrumbs/Items': {
35
+ actions: {
36
+ eject: 'unsafe',
37
+ wrap: 'forbidden', // Can't wrap a folder
38
+ },
39
+ description: 'The components responsible for rendering the breadcrumb items',
40
+ },
27
41
  DocCardList: {
28
42
  actions: {
29
43
  eject: 'safe',
@@ -31,6 +45,16 @@ function getSwizzleConfig() {
31
45
  },
32
46
  description: 'The component responsible for rendering a list of sidebar items cards.\nNotable used on the category generated-index pages.',
33
47
  },
48
+ 'DocItem/TOC': {
49
+ actions: {
50
+ // Forbidden because it's a parent folder, makes the CLI crash atm
51
+ // TODO the CLI should rather support --eject
52
+ // Subfolders can be swizzled
53
+ eject: 'forbidden',
54
+ wrap: 'forbidden',
55
+ },
56
+ description: 'The DocItem TOC is not directly swizzle-able, but you can swizzle its sub-components.',
57
+ },
34
58
  DocSidebar: {
35
59
  actions: {
36
60
  eject: 'unsafe',
@@ -94,6 +118,16 @@ function getSwizzleConfig() {
94
118
  },
95
119
  description: 'The footer logo',
96
120
  },
121
+ Icon: {
122
+ actions: {
123
+ // Forbidden because it's a parent folder, makes the CLI crash atm
124
+ // TODO the CLI should rather support --eject
125
+ // Subfolders can be swizzled
126
+ eject: 'forbidden',
127
+ wrap: 'forbidden',
128
+ },
129
+ description: 'The Icon folder is not directly swizzle-able, but you can swizzle its sub-components.',
130
+ },
97
131
  'Icon/Arrow': {
98
132
  actions: {
99
133
  eject: 'safe',
@@ -204,7 +238,7 @@ function getSwizzleConfig() {
204
238
  eject: 'safe',
205
239
  wrap: 'forbidden',
206
240
  },
207
- description: 'The Navbar item components mapping. Can be ejected to add custom navbar item types. See https://github.com/facebook/docusaurus/issues/7227.',
241
+ description: 'The Navbar item components mapping. Can be ejected to add custom navbar item types.\nSee https://github.com/facebook/docusaurus/issues/7227.',
208
242
  },
209
243
  NotFound: {
210
244
  actions: {
@@ -222,6 +256,13 @@ function getSwizzleConfig() {
222
256
  // By default it's an empty placeholder for the user to fill
223
257
  description: 'The search bar component of your site, appearing in the navbar.',
224
258
  },
259
+ SkipToContent: {
260
+ actions: {
261
+ eject: 'safe',
262
+ wrap: 'safe',
263
+ },
264
+ description: 'The component responsible for implementing the accessibility "skip to content" link (https://www.w3.org/TR/WCAG20-TECHS/G1.html)',
265
+ },
225
266
  'prism-include-languages': {
226
267
  actions: {
227
268
  eject: 'safe',
@@ -15,8 +15,16 @@
15
15
  height: var(--docusaurus-announcement-bar-height);
16
16
  background-color: var(--ifm-color-white);
17
17
  color: var(--ifm-color-black);
18
+
19
+ /*
20
+ Unfortunately we can't make announcement bar render above the navbar
21
+ IE need to use border-bottom instead of shadow
22
+ See https://github.com/facebookincubator/infima/issues/275
23
+
18
24
  box-shadow: var(--ifm-global-shadow-lw);
19
- z-index: calc(var(--ifm-z-index-fixed) + 1); /* just above the navbar */
25
+ z-index: calc(var(--ifm-z-index-fixed) + 1);
26
+ */
27
+ border-bottom: 1px solid var(--ifm-color-emphasis-100);
20
28
  }
21
29
 
22
30
  html[data-announcement-bar-initially-dismissed='true'] .announcementBar {
@@ -32,11 +32,9 @@ export default function CodeBlockLine({
32
32
  <span className={styles.codeLineContent}>{lineTokens}</span>
33
33
  </>
34
34
  ) : (
35
- <>
36
- {lineTokens}
37
- <br />
38
- </>
35
+ lineTokens
39
36
  )}
37
+ <br />
40
38
  </span>
41
39
  );
42
40
  }
@@ -46,7 +46,8 @@ function ColorModeToggle({className, value, onChange}) {
46
46
  onClick={() => onChange(value === 'dark' ? 'light' : 'dark')}
47
47
  disabled={!isBrowser}
48
48
  title={title}
49
- aria-label={title}>
49
+ aria-label={title}
50
+ aria-live="polite">
50
51
  <IconLightMode
51
52
  className={clsx(styles.toggleIcon, styles.lightToggleIcon)}
52
53
  />
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ /// <reference types="react" />
8
+ export default function HomeBreadcrumbItem(): JSX.Element;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ import Link from '@docusaurus/Link';
9
+ import useBaseUrl from '@docusaurus/useBaseUrl';
10
+ import {translate} from '@docusaurus/Translate';
11
+ import IconHome from '@theme/Icon/Home';
12
+ import styles from './styles.module.css';
13
+ export default function HomeBreadcrumbItem() {
14
+ const homeHref = useBaseUrl('/');
15
+ return (
16
+ <li className="breadcrumbs__item">
17
+ <Link
18
+ aria-label={translate({
19
+ id: 'theme.docs.breadcrumbs.home',
20
+ message: 'Home page',
21
+ description: 'The ARIA label for the home page in the breadcrumbs',
22
+ })}
23
+ className="breadcrumbs__link"
24
+ href={homeHref}>
25
+ <IconHome className={styles.breadcrumbHomeIcon} />
26
+ </Link>
27
+ </li>
28
+ );
29
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ .breadcrumbHomeIcon {
9
+ position: relative;
10
+ top: 1px;
11
+ vertical-align: top;
12
+ height: 1.1rem;
13
+ width: 1.1rem;
14
+ }
@@ -12,9 +12,8 @@ import {
12
12
  useHomePageRoute,
13
13
  } from '@docusaurus/theme-common/internal';
14
14
  import Link from '@docusaurus/Link';
15
- import useBaseUrl from '@docusaurus/useBaseUrl';
16
15
  import {translate} from '@docusaurus/Translate';
17
- import IconHome from '@theme/Icon/Home';
16
+ import HomeBreadcrumbItem from '@theme/DocBreadcrumbs/Items/Home';
18
17
  import styles from './styles.module.css';
19
18
  // TODO move to design system folder
20
19
  function BreadcrumbsItemLink({children, href, isLast}) {
@@ -56,23 +55,6 @@ function BreadcrumbsItem({children, active, index, addMicrodata}) {
56
55
  </li>
57
56
  );
58
57
  }
59
- function HomeBreadcrumbItem() {
60
- const homeHref = useBaseUrl('/');
61
- return (
62
- <li className="breadcrumbs__item">
63
- <Link
64
- aria-label={translate({
65
- id: 'theme.docs.breadcrumbs.home',
66
- message: 'Home page',
67
- description: 'The ARIA label for the home page in the breadcrumbs',
68
- })}
69
- className={clsx('breadcrumbs__link', styles.breadcrumbsItemLink)}
70
- href={homeHref}>
71
- <IconHome className={styles.breadcrumbHomeIcon} />
72
- </Link>
73
- </li>
74
- );
75
- }
76
58
  export default function DocBreadcrumbs() {
77
59
  const breadcrumbs = useSidebarBreadcrumbs();
78
60
  const homePageRoute = useHomePageRoute();
@@ -9,11 +9,3 @@
9
9
  --ifm-breadcrumb-size-multiplier: 0.8;
10
10
  margin-bottom: 0.8rem;
11
11
  }
12
-
13
- .breadcrumbHomeIcon {
14
- position: relative;
15
- top: 1px;
16
- vertical-align: top;
17
- height: 1.1rem;
18
- width: 1.1rem;
19
- }
@@ -7,10 +7,11 @@
7
7
 
8
8
  @media (min-width: 997px) {
9
9
  .expandButton {
10
- position: sticky;
10
+ position: absolute;
11
11
  top: 0;
12
+ right: 0;
13
+ width: 100%;
12
14
  height: 100%;
13
- max-height: 100vh;
14
15
  display: flex;
15
16
  align-items: center;
16
17
  justify-content: center;
@@ -52,15 +52,20 @@ export default function DocPageLayoutSidebar({
52
52
  }
53
53
  }}>
54
54
  <ResetOnSidebarChange>
55
- <DocSidebar
56
- sidebar={sidebar}
57
- path={pathname}
58
- onCollapse={toggleSidebar}
59
- isHidden={hiddenSidebar}
60
- />
55
+ <div
56
+ className={clsx(
57
+ styles.sidebarViewport,
58
+ hiddenSidebar && styles.sidebarViewportHidden,
59
+ )}>
60
+ <DocSidebar
61
+ sidebar={sidebar}
62
+ path={pathname}
63
+ onCollapse={toggleSidebar}
64
+ isHidden={hiddenSidebar}
65
+ />
66
+ {hiddenSidebar && <ExpandButton toggleSidebar={toggleSidebar} />}
67
+ </div>
61
68
  </ResetOnSidebarChange>
62
-
63
- {hiddenSidebar && <ExpandButton toggleSidebar={toggleSidebar} />}
64
69
  </aside>
65
70
  );
66
71
  }
@@ -29,4 +29,11 @@
29
29
  width: var(--doc-sidebar-hidden-width);
30
30
  cursor: pointer;
31
31
  }
32
+
33
+ .sidebarViewport {
34
+ top: 0;
35
+ position: sticky;
36
+ height: 100%;
37
+ max-height: 100vh;
38
+ }
32
39
  }
@@ -12,4 +12,5 @@
12
12
 
13
13
  .docsWrapper {
14
14
  display: flex;
15
+ flex: 1 0 auto;
15
16
  }
@@ -43,4 +43,5 @@
43
43
 
44
44
  .collapseSidebarButton {
45
45
  display: none;
46
+ margin: 0;
46
47
  }
@@ -11,6 +11,7 @@ import {
11
11
  useAnnouncementBar,
12
12
  useScrollPosition,
13
13
  } from '@docusaurus/theme-common/internal';
14
+ import {translate} from '@docusaurus/Translate';
14
15
  import DocSidebarItems from '@theme/DocSidebarItems';
15
16
  import styles from './styles.module.css';
16
17
  function useShowAnnouncementBar() {
@@ -30,6 +31,11 @@ export default function DocSidebarDesktopContent({path, sidebar, className}) {
30
31
  const showAnnouncementBar = useShowAnnouncementBar();
31
32
  return (
32
33
  <nav
34
+ aria-label={translate({
35
+ id: 'theme.docs.sidebar.navAriaLabel',
36
+ message: 'Docs sidebar',
37
+ description: 'The ARIA label for the sidebar navigation',
38
+ })}
33
39
  className={clsx(
34
40
  'menu thin-scrollbar',
35
41
  styles.menu,
@@ -9,13 +9,9 @@
9
9
  .sidebar {
10
10
  display: flex;
11
11
  flex-direction: column;
12
- max-height: 100vh;
13
12
  height: 100%;
14
- position: sticky;
15
- top: 0;
16
13
  padding-top: var(--ifm-navbar-height);
17
14
  width: var(--doc-sidebar-width);
18
- transition: opacity 50ms ease;
19
15
  }
20
16
 
21
17
  .sidebarWithHideableNavbar {
@@ -24,8 +20,6 @@
24
20
 
25
21
  .sidebarHidden {
26
22
  opacity: 0;
27
- height: 0;
28
- overflow: hidden;
29
23
  visibility: hidden;
30
24
  }
31
25
 
@@ -8,6 +8,7 @@ import React from 'react';
8
8
  import clsx from 'clsx';
9
9
  import {translate} from '@docusaurus/Translate';
10
10
  import {useThemeConfig} from '@docusaurus/theme-common';
11
+ import Link from '@docusaurus/Link';
11
12
  import styles from './styles.module.css';
12
13
  export default function Heading({as: As, id, ...props}) {
13
14
  const {
@@ -17,6 +18,16 @@ export default function Heading({as: As, id, ...props}) {
17
18
  if (As === 'h1' || !id) {
18
19
  return <As {...props} id={undefined} />;
19
20
  }
21
+ const anchorTitle = translate(
22
+ {
23
+ id: 'theme.common.headingLinkTitle',
24
+ message: 'Direct link to {heading}',
25
+ description: 'Title for link to heading',
26
+ },
27
+ {
28
+ heading: typeof props.children === 'string' ? props.children : id,
29
+ },
30
+ );
20
31
  return (
21
32
  <As
22
33
  {...props}
@@ -25,19 +36,17 @@ export default function Heading({as: As, id, ...props}) {
25
36
  hideOnScroll
26
37
  ? styles.anchorWithHideOnScrollNavbar
27
38
  : styles.anchorWithStickyNavbar,
39
+ props.className,
28
40
  )}
29
41
  id={id}>
30
42
  {props.children}
31
- <a
43
+ <Link
32
44
  className="hash-link"
33
- href={`#${id}`}
34
- title={translate({
35
- id: 'theme.common.headingLinkTitle',
36
- message: 'Direct link to heading',
37
- description: 'Title for link to heading',
38
- })}>
45
+ to={`#${id}`}
46
+ aria-label={anchorTitle}
47
+ title={anchorTitle}>
39
48
  &#8203;
40
- </a>
49
+ </Link>
41
50
  </As>
42
51
  );
43
52
  }
@@ -8,7 +8,6 @@ import React from 'react';
8
8
  import {composeProviders} from '@docusaurus/theme-common';
9
9
  import {
10
10
  ColorModeProvider,
11
- TabGroupChoiceProvider,
12
11
  AnnouncementBarProvider,
13
12
  DocsPreferredVersionContextProvider,
14
13
  ScrollControllerProvider,
@@ -18,7 +17,6 @@ import {
18
17
  const Provider = composeProviders([
19
18
  ColorModeProvider,
20
19
  AnnouncementBarProvider,
21
- TabGroupChoiceProvider,
22
20
  ScrollControllerProvider,
23
21
  DocsPreferredVersionContextProvider,
24
22
  PluginHtmlClassNameProvider,
@@ -7,7 +7,11 @@
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
9
  import ErrorBoundary from '@docusaurus/ErrorBoundary';
10
- import {PageMetadata, ThemeClassNames} from '@docusaurus/theme-common';
10
+ import {
11
+ PageMetadata,
12
+ SkipToContentFallbackId,
13
+ ThemeClassNames,
14
+ } from '@docusaurus/theme-common';
11
15
  import {useKeyboardNavigation} from '@docusaurus/theme-common/internal';
12
16
  import SkipToContent from '@theme/SkipToContent';
13
17
  import AnnouncementBar from '@theme/AnnouncementBar';
@@ -37,6 +41,7 @@ export default function Layout(props) {
37
41
  <Navbar />
38
42
 
39
43
  <div
44
+ id={SkipToContentFallbackId}
40
45
  className={clsx(
41
46
  ThemeClassNames.wrapper.main,
42
47
  styles.mainWrapper,
@@ -12,6 +12,8 @@ body {
12
12
 
13
13
  .mainWrapper {
14
14
  flex: 1 0 auto;
15
+ display: flex;
16
+ flex-direction: column;
15
17
  }
16
18
 
17
19
  /* Docusaurus-specific utility class */
@@ -9,15 +9,35 @@ import CodeBlock from '@theme/CodeBlock';
9
9
  export default function MDXCode(props) {
10
10
  const inlineElements = [
11
11
  'a',
12
+ 'abbr',
12
13
  'b',
13
- 'big',
14
+ 'br',
15
+ 'button',
16
+ 'cite',
17
+ 'code',
18
+ 'del',
19
+ 'dfn',
20
+ 'em',
14
21
  'i',
22
+ 'img',
23
+ 'input',
24
+ 'ins',
25
+ 'kbd',
26
+ 'label',
27
+ 'object',
28
+ 'output',
29
+ 'q',
30
+ 'ruby',
31
+ 's',
32
+ 'small',
15
33
  'span',
16
- 'em',
17
34
  'strong',
18
- 'sup',
19
35
  'sub',
20
- 'small',
36
+ 'sup',
37
+ 'time',
38
+ 'u',
39
+ 'var',
40
+ 'wbr',
21
41
  ];
22
42
  const shouldBeInline = React.Children.toArray(props.children).every(
23
43
  (el) =>
@@ -14,6 +14,7 @@ import MDXHeading from '@theme/MDXComponents/Heading';
14
14
  import MDXUl from '@theme/MDXComponents/Ul';
15
15
  import MDXImg from '@theme/MDXComponents/Img';
16
16
  import Admonition from '@theme/Admonition';
17
+ import Mermaid from '@theme/Mermaid';
17
18
  const MDXComponents = {
18
19
  head: MDXHead,
19
20
  code: MDXCode,
@@ -29,5 +30,6 @@ const MDXComponents = {
29
30
  h5: (props) => <MDXHeading as="h5" {...props} />,
30
31
  h6: (props) => <MDXHeading as="h6" {...props} />,
31
32
  admonition: Admonition,
33
+ mermaid: Mermaid,
32
34
  };
33
35
  export default MDXComponents;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ export { default } from '@docusaurus/Noop';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ // This component is meant to be implemented by a Mermaid renderer theme
8
+ // It is notable created to be overridden by docusaurus-theme-mermaid
9
+ // By default, the classic theme does not provide any Mermaid implementation
10
+ // Yet we declare it there so that we can register it in MDX
11
+ // TODO later the mermaid theme should be able to register its MDX component
12
+ // see https://github.com/facebook/docusaurus/pull/7490#issuecomment-1279117288
13
+ export {default} from '@docusaurus/Noop';
@@ -11,6 +11,7 @@ import {
11
11
  useHideableNavbar,
12
12
  useNavbarMobileSidebar,
13
13
  } from '@docusaurus/theme-common/internal';
14
+ import {translate} from '@docusaurus/Translate';
14
15
  import NavbarMobileSidebar from '@theme/Navbar/MobileSidebar';
15
16
  import styles from './styles.module.css';
16
17
  function NavbarBackdrop(props) {
@@ -31,6 +32,11 @@ export default function NavbarLayout({children}) {
31
32
  return (
32
33
  <nav
33
34
  ref={navbarRef}
35
+ aria-label={translate({
36
+ id: 'theme.NavBar.navAriaLabel',
37
+ message: 'Main',
38
+ description: 'The ARIA label for the main navigation',
39
+ })}
34
40
  className={clsx(
35
41
  'navbar',
36
42
  'navbar--fixed-top',
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import {useNavbarMobileSidebar} from '@docusaurus/theme-common/internal';
9
+ import {translate} from '@docusaurus/Translate';
9
10
  import NavbarColorModeToggle from '@theme/Navbar/ColorModeToggle';
10
11
  import IconClose from '@theme/Icon/Close';
11
12
  import NavbarLogo from '@theme/Navbar/Logo';
@@ -14,6 +15,11 @@ function CloseButton() {
14
15
  return (
15
16
  <button
16
17
  type="button"
18
+ aria-label={translate({
19
+ id: 'theme.docs.sidebar.closeSidebarButtonAriaLabel',
20
+ message: 'Close navigation bar',
21
+ description: 'The ARIA label for close button of mobile sidebar',
22
+ })}
17
23
  className="clean-btn navbar-sidebar__close"
18
24
  onClick={() => mobileSidebar.toggle()}>
19
25
  <IconClose color="var(--ifm-color-emphasis-600)" />
@@ -6,17 +6,22 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import {useNavbarMobileSidebar} from '@docusaurus/theme-common/internal';
9
+ import {translate} from '@docusaurus/Translate';
9
10
  import IconMenu from '@theme/Icon/Menu';
10
11
  export default function MobileSidebarToggle() {
11
- const mobileSidebar = useNavbarMobileSidebar();
12
+ const {toggle, shown} = useNavbarMobileSidebar();
12
13
  return (
13
14
  <button
14
- onClick={mobileSidebar.toggle}
15
- onKeyDown={mobileSidebar.toggle}
16
- aria-label="Navigation bar toggle"
15
+ onClick={toggle}
16
+ aria-label={translate({
17
+ id: 'theme.docs.sidebar.toggleSidebarButtonAriaLabel',
18
+ message: 'Toggle navigation bar',
19
+ description:
20
+ 'The ARIA label for hamburger menu button of mobile navigation',
21
+ })}
22
+ aria-expanded={shown}
17
23
  className="navbar__toggle clean-btn"
18
- type="button"
19
- tabIndex={0}>
24
+ type="button">
20
25
  <IconMenu />
21
26
  </button>
22
27
  );
@@ -12,6 +12,7 @@ import {
12
12
  import {useDocsPreferredVersion} from '@docusaurus/theme-common';
13
13
  import {useDocsVersionCandidates} from '@docusaurus/theme-common/internal';
14
14
  import {translate} from '@docusaurus/Translate';
15
+ import {useLocation} from '@docusaurus/router';
15
16
  import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
16
17
  import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
17
18
  const getVersionMainDoc = (version) =>
@@ -24,6 +25,7 @@ export default function DocsVersionDropdownNavbarItem({
24
25
  dropdownItemsAfter,
25
26
  ...props
26
27
  }) {
28
+ const {search, hash} = useLocation();
27
29
  const activeDocContext = useActiveDocContext(docsPluginId);
28
30
  const versions = useVersions(docsPluginId);
29
31
  const {savePreferredVersionName} = useDocsPreferredVersion(docsPluginId);
@@ -35,7 +37,8 @@ export default function DocsVersionDropdownNavbarItem({
35
37
  getVersionMainDoc(version);
36
38
  return {
37
39
  label: version.label,
38
- to: versionDoc.path,
40
+ // preserve ?search#hash suffix on version switches
41
+ to: `${versionDoc.path}${search}${hash}`,
39
42
  isActive: () => version === activeDocContext.activeVersion,
40
43
  onClick: () => savePreferredVersionName(version.name),
41
44
  };
@@ -8,6 +8,7 @@ import React from 'react';
8
8
  import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
9
9
  import {useAlternatePageUtils} from '@docusaurus/theme-common/internal';
10
10
  import {translate} from '@docusaurus/Translate';
11
+ import {useLocation} from '@docusaurus/router';
11
12
  import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
12
13
  import IconLanguage from '@theme/Icon/Language';
13
14
  import styles from './styles.module.css';
@@ -21,11 +22,14 @@ export default function LocaleDropdownNavbarItem({
21
22
  i18n: {currentLocale, locales, localeConfigs},
22
23
  } = useDocusaurusContext();
23
24
  const alternatePageUtils = useAlternatePageUtils();
25
+ const {search, hash} = useLocation();
24
26
  const localeItems = locales.map((locale) => {
25
- const to = `pathname://${alternatePageUtils.createUrl({
27
+ const baseTo = `pathname://${alternatePageUtils.createUrl({
26
28
  locale,
27
29
  fullyQualified: false,
28
30
  })}`;
31
+ // preserve ?search#hash suffix on locale switches
32
+ const to = `${baseTo}${search}${hash}`;
29
33
  return {
30
34
  label: localeConfigs[locale].label,
31
35
  lang: localeConfigs[locale].htmlLang,