@docusaurus/theme-classic 2.0.1 → 2.2.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 (56) hide show
  1. package/lib/getSwizzleConfig.js +14 -0
  2. package/lib/theme/AnnouncementBar/CloseButton/index.d.ts +9 -0
  3. package/lib/theme/AnnouncementBar/CloseButton/index.js +26 -0
  4. package/lib/theme/AnnouncementBar/CloseButton/styles.module.css +11 -0
  5. package/lib/theme/AnnouncementBar/Content/index.d.ts +9 -0
  6. package/lib/theme/AnnouncementBar/Content/index.js +23 -0
  7. package/lib/theme/AnnouncementBar/Content/styles.module.css +17 -0
  8. package/lib/theme/AnnouncementBar/index.js +10 -23
  9. package/lib/theme/AnnouncementBar/styles.module.css +9 -10
  10. package/lib/theme/CodeBlock/Line/index.js +2 -4
  11. package/lib/theme/CodeBlock/Line/styles.module.css +1 -0
  12. package/lib/theme/ColorModeToggle/index.js +2 -1
  13. package/lib/theme/DocCardList/index.d.ts +1 -1
  14. package/lib/theme/DocCardList/index.js +14 -11
  15. package/lib/theme/DocPage/index.js +24 -7
  16. package/lib/theme/DocSidebarItem/Category/index.js +1 -1
  17. package/lib/theme/DocSidebarItem/Link/index.js +2 -1
  18. package/lib/theme/Layout/index.js +6 -1
  19. package/lib/theme/MDXComponents/Code.js +24 -4
  20. package/lib/theme/MDXComponents/index.js +2 -0
  21. package/lib/theme/Mermaid.d.ts +7 -0
  22. package/lib/theme/Mermaid.js +13 -0
  23. package/lib/theme/Navbar/MobileSidebar/Header/index.js +6 -0
  24. package/lib/theme/Navbar/MobileSidebar/Toggle/index.js +11 -6
  25. package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +4 -1
  26. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +6 -1
  27. package/lib/theme/SkipToContent/index.js +2 -15
  28. package/lib/theme/Tabs/index.js +4 -1
  29. package/lib/theme/Tag/styles.module.css +2 -2
  30. package/package.json +14 -16
  31. package/src/getSwizzleConfig.ts +16 -0
  32. package/src/theme/AnnouncementBar/CloseButton/index.tsx +31 -0
  33. package/src/theme/AnnouncementBar/CloseButton/styles.module.css +11 -0
  34. package/src/theme/AnnouncementBar/Content/index.tsx +28 -0
  35. package/src/theme/AnnouncementBar/Content/styles.module.css +17 -0
  36. package/src/theme/AnnouncementBar/index.tsx +10 -26
  37. package/src/theme/AnnouncementBar/styles.module.css +9 -10
  38. package/src/theme/CodeBlock/Line/index.tsx +2 -4
  39. package/src/theme/CodeBlock/Line/styles.module.css +1 -0
  40. package/src/theme/ColorModeToggle/index.tsx +2 -1
  41. package/src/theme/DocCardList/index.tsx +14 -12
  42. package/src/theme/DocPage/index.tsx +25 -7
  43. package/src/theme/DocSidebarItem/Category/index.tsx +1 -1
  44. package/src/theme/DocSidebarItem/Link/index.tsx +2 -1
  45. package/src/theme/Layout/index.tsx +6 -1
  46. package/src/theme/MDXComponents/Code.tsx +24 -4
  47. package/src/theme/MDXComponents/index.tsx +2 -0
  48. package/src/theme/Mermaid.tsx +16 -0
  49. package/src/theme/Navbar/MobileSidebar/Header/index.tsx +6 -0
  50. package/src/theme/Navbar/MobileSidebar/Toggle/index.tsx +11 -6
  51. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +4 -1
  52. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +6 -1
  53. package/src/theme/SkipToContent/index.tsx +2 -15
  54. package/src/theme/Tabs/index.tsx +8 -2
  55. package/src/theme/Tag/styles.module.css +2 -2
  56. package/src/theme-classic.d.ts +27 -1
@@ -24,6 +24,13 @@ function getSwizzleConfig() {
24
24
  },
25
25
  description: 'The color mode toggle to switch between light and dark mode.',
26
26
  },
27
+ DocCardList: {
28
+ actions: {
29
+ eject: 'safe',
30
+ wrap: 'safe',
31
+ },
32
+ description: 'The component responsible for rendering a list of sidebar items cards.\nNotable used on the category generated-index pages.',
33
+ },
27
34
  DocSidebar: {
28
35
  actions: {
29
36
  eject: 'unsafe',
@@ -215,6 +222,13 @@ function getSwizzleConfig() {
215
222
  // By default it's an empty placeholder for the user to fill
216
223
  description: 'The search bar component of your site, appearing in the navbar.',
217
224
  },
225
+ SkipToContent: {
226
+ actions: {
227
+ eject: 'safe',
228
+ wrap: 'safe',
229
+ },
230
+ description: 'The component responsible for implementing the accessibility "skip to content" link (https://www.w3.org/TR/WCAG20-TECHS/G1.html)',
231
+ },
218
232
  'prism-include-languages': {
219
233
  actions: {
220
234
  eject: 'safe',
@@ -0,0 +1,9 @@
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
+ import type { Props } from '@theme/AnnouncementBar/CloseButton';
9
+ export default function AnnouncementBarCloseButton(props: Props): JSX.Element | null;
@@ -0,0 +1,26 @@
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 clsx from 'clsx';
9
+ import {translate} from '@docusaurus/Translate';
10
+ import IconClose from '@theme/Icon/Close';
11
+ import styles from './styles.module.css';
12
+ export default function AnnouncementBarCloseButton(props) {
13
+ return (
14
+ <button
15
+ type="button"
16
+ aria-label={translate({
17
+ id: 'theme.AnnouncementBar.closeButtonAriaLabel',
18
+ message: 'Close',
19
+ description: 'The ARIA label for close button of announcement bar',
20
+ })}
21
+ {...props}
22
+ className={clsx('clean-btn close', styles.closeButton, props.className)}>
23
+ <IconClose width={14} height={14} strokeWidth={3.1} />
24
+ </button>
25
+ );
26
+ }
@@ -0,0 +1,11 @@
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
+ .closeButton {
9
+ padding: 0;
10
+ line-height: 0;
11
+ }
@@ -0,0 +1,9 @@
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
+ import type { Props } from '@theme/AnnouncementBar/Content';
9
+ export default function AnnouncementBarContent(props: Props): JSX.Element | null;
@@ -0,0 +1,23 @@
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 clsx from 'clsx';
9
+ import {useThemeConfig} from '@docusaurus/theme-common';
10
+ import styles from './styles.module.css';
11
+ export default function AnnouncementBarContent(props) {
12
+ const {announcementBar} = useThemeConfig();
13
+ const {content} = announcementBar;
14
+ return (
15
+ <div
16
+ {...props}
17
+ className={clsx(styles.content, props.className)}
18
+ // Developer provided the HTML, so assume it's safe.
19
+ // eslint-disable-next-line react/no-danger
20
+ dangerouslySetInnerHTML={{__html: content}}
21
+ />
22
+ );
23
+ }
@@ -0,0 +1,17 @@
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
+ .content {
9
+ font-size: 85%;
10
+ text-align: center;
11
+ padding: 5px 0;
12
+ }
13
+
14
+ .content a {
15
+ color: inherit;
16
+ text-decoration: underline;
17
+ }
@@ -5,44 +5,31 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- import clsx from 'clsx';
9
8
  import {useThemeConfig} from '@docusaurus/theme-common';
10
9
  import {useAnnouncementBar} from '@docusaurus/theme-common/internal';
11
- import {translate} from '@docusaurus/Translate';
12
- import IconClose from '@theme/Icon/Close';
10
+ import AnnouncementBarCloseButton from '@theme/AnnouncementBar/CloseButton';
11
+ import AnnouncementBarContent from '@theme/AnnouncementBar/Content';
13
12
  import styles from './styles.module.css';
14
13
  export default function AnnouncementBar() {
15
- const {isActive, close} = useAnnouncementBar();
16
14
  const {announcementBar} = useThemeConfig();
15
+ const {isActive, close} = useAnnouncementBar();
17
16
  if (!isActive) {
18
17
  return null;
19
18
  }
20
- const {content, backgroundColor, textColor, isCloseable} = announcementBar;
19
+ const {backgroundColor, textColor, isCloseable} = announcementBar;
21
20
  return (
22
21
  <div
23
22
  className={styles.announcementBar}
24
23
  style={{backgroundColor, color: textColor}}
25
24
  role="banner">
26
25
  {isCloseable && <div className={styles.announcementBarPlaceholder} />}
27
- <div
28
- className={styles.announcementBarContent}
29
- // Developer provided the HTML, so assume it's safe.
30
- // eslint-disable-next-line react/no-danger
31
- dangerouslySetInnerHTML={{__html: content}}
32
- />
33
- {isCloseable ? (
34
- <button
35
- type="button"
36
- className={clsx('clean-btn close', styles.announcementBarClose)}
26
+ <AnnouncementBarContent className={styles.announcementBarContent} />
27
+ {isCloseable && (
28
+ <AnnouncementBarCloseButton
37
29
  onClick={close}
38
- aria-label={translate({
39
- id: 'theme.AnnouncementBar.closeButtonAriaLabel',
40
- message: 'Close',
41
- description: 'The ARIA label for close button of announcement bar',
42
- })}>
43
- <IconClose width={14} height={14} strokeWidth={3.1} />
44
- </button>
45
- ) : null}
30
+ className={styles.announcementBarClose}
31
+ />
32
+ )}
46
33
  </div>
47
34
  );
48
35
  }
@@ -15,6 +15,15 @@
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
+
24
+ box-shadow: var(--ifm-global-shadow-lw);
25
+ z-index: calc(var(--ifm-z-index-fixed) + 1);
26
+ */
18
27
  border-bottom: 1px solid var(--ifm-color-emphasis-100);
19
28
  }
20
29
 
@@ -29,15 +38,10 @@ html[data-announcement-bar-initially-dismissed='true'] .announcementBar {
29
38
  .announcementBarClose {
30
39
  flex: 0 0 30px;
31
40
  align-self: stretch;
32
- padding: 0;
33
- line-height: 0;
34
41
  }
35
42
 
36
43
  .announcementBarContent {
37
44
  flex: 1 1 auto;
38
- font-size: 85%;
39
- text-align: center;
40
- padding: 5px 0;
41
45
  }
42
46
 
43
47
  @media print {
@@ -46,11 +50,6 @@ html[data-announcement-bar-initially-dismissed='true'] .announcementBar {
46
50
  }
47
51
  }
48
52
 
49
- .announcementBarContent a {
50
- color: inherit;
51
- text-decoration: underline;
52
- }
53
-
54
53
  @media (min-width: 997px) {
55
54
  :root {
56
55
  --docusaurus-announcement-bar-height: 30px;
@@ -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
  }
@@ -35,6 +35,7 @@ the background in custom CSS file due bug https://github.com/facebook/docusaurus
35
35
  left: 0;
36
36
  padding: 0 var(--ifm-pre-padding);
37
37
  background: var(--ifm-pre-background);
38
+ overflow-wrap: normal;
38
39
  }
39
40
 
40
41
  .codeLineNumber::before {
@@ -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
  />
@@ -6,4 +6,4 @@
6
6
  */
7
7
  /// <reference types="react" />
8
8
  import type { Props } from '@theme/DocCardList';
9
- export default function DocCardList({ items, className }: Props): JSX.Element;
9
+ export default function DocCardList(props: Props): JSX.Element;
@@ -6,21 +6,24 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
- import {findFirstCategoryLink} from '@docusaurus/theme-common/internal';
9
+ import {
10
+ useCurrentSidebarCategory,
11
+ filterDocCardListItems,
12
+ } from '@docusaurus/theme-common';
10
13
  import DocCard from '@theme/DocCard';
11
- // Filter categories that don't have a link.
12
- function filterItems(items) {
13
- return items.filter((item) => {
14
- if (item.type === 'category') {
15
- return !!findFirstCategoryLink(item);
16
- }
17
- return true;
18
- });
14
+ function DocCardListForCurrentSidebarCategory({className}) {
15
+ const category = useCurrentSidebarCategory();
16
+ return <DocCardList items={category.items} className={className} />;
19
17
  }
20
- export default function DocCardList({items, className}) {
18
+ export default function DocCardList(props) {
19
+ const {items, className} = props;
20
+ if (!items) {
21
+ return <DocCardListForCurrentSidebarCategory {...props} />;
22
+ }
23
+ const filteredItems = filterDocCardListItems(items);
21
24
  return (
22
25
  <section className={clsx('row', className)}>
23
- {filterItems(items).map((item, index) => (
26
+ {filteredItems.map((item, index) => (
24
27
  <article key={index} className="col col--6 margin-bottom--lg">
25
28
  <DocCard item={item} />
26
29
  </article>
@@ -6,7 +6,11 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
- import {HtmlClassNameProvider, ThemeClassNames} from '@docusaurus/theme-common';
9
+ import {
10
+ HtmlClassNameProvider,
11
+ ThemeClassNames,
12
+ PageMetadata,
13
+ } from '@docusaurus/theme-common';
10
14
  import {
11
15
  docVersionSearchTag,
12
16
  DocsSidebarProvider,
@@ -16,13 +20,8 @@ import {
16
20
  import DocPageLayout from '@theme/DocPage/Layout';
17
21
  import NotFound from '@theme/NotFound';
18
22
  import SearchMetadata from '@theme/SearchMetadata';
19
- export default function DocPage(props) {
23
+ function DocPageMetadata(props) {
20
24
  const {versionMetadata} = props;
21
- const currentDocRouteMetadata = useDocRouteMetadata(props);
22
- if (!currentDocRouteMetadata) {
23
- return <NotFound />;
24
- }
25
- const {docElement, sidebarName, sidebarItems} = currentDocRouteMetadata;
26
25
  return (
27
26
  <>
28
27
  <SearchMetadata
@@ -32,6 +31,24 @@ export default function DocPage(props) {
32
31
  versionMetadata.version,
33
32
  )}
34
33
  />
34
+ <PageMetadata>
35
+ {versionMetadata.noIndex && (
36
+ <meta name="robots" content="noindex, nofollow" />
37
+ )}
38
+ </PageMetadata>
39
+ </>
40
+ );
41
+ }
42
+ export default function DocPage(props) {
43
+ const {versionMetadata} = props;
44
+ const currentDocRouteMetadata = useDocRouteMetadata(props);
45
+ if (!currentDocRouteMetadata) {
46
+ return <NotFound />;
47
+ }
48
+ const {docElement, sidebarName, sidebarItems} = currentDocRouteMetadata;
49
+ return (
50
+ <>
51
+ <DocPageMetadata {...props} />
35
52
  <HtmlClassNameProvider
36
53
  className={clsx(
37
54
  // TODO: it should be removed from here
@@ -111,7 +111,7 @@ export default function DocSidebarItemCategory({
111
111
  useEffect(() => {
112
112
  if (
113
113
  collapsible &&
114
- expandedItem &&
114
+ expandedItem != null &&
115
115
  expandedItem !== index &&
116
116
  autoCollapseCategories
117
117
  ) {
@@ -20,7 +20,7 @@ export default function DocSidebarItemLink({
20
20
  index,
21
21
  ...props
22
22
  }) {
23
- const {href, label, className} = item;
23
+ const {href, label, className, autoAddBaseUrl} = item;
24
24
  const isActive = isActiveSidebarItem(item, activePath);
25
25
  const isInternalLink = isInternalUrl(href);
26
26
  return (
@@ -40,6 +40,7 @@ export default function DocSidebarItemLink({
40
40
  'menu__link--active': isActive,
41
41
  },
42
42
  )}
43
+ autoAddBaseUrl={autoAddBaseUrl}
43
44
  aria-current={isActive ? 'page' : undefined}
44
45
  to={href}
45
46
  {...(isInternalLink && {
@@ -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,
@@ -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';
@@ -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,13 +22,17 @@ 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,
35
+ lang: localeConfigs[locale].htmlLang,
31
36
  to,
32
37
  target: '_self',
33
38
  autoAddBaseUrl: false,
@@ -5,21 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- import Translate from '@docusaurus/Translate';
9
- import {useSkipToContent} from '@docusaurus/theme-common/internal';
8
+ import {SkipToContentLink} from '@docusaurus/theme-common';
10
9
  import styles from './styles.module.css';
11
10
  export default function SkipToContent() {
12
- const {containerRef, handleSkip} = useSkipToContent();
13
- return (
14
- <div ref={containerRef} role="region">
15
- {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
16
- <a href="#" className={styles.skipToContent} onClick={handleSkip}>
17
- <Translate
18
- id="theme.common.skipToMainContent"
19
- description="The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation">
20
- Skip to main content
21
- </Translate>
22
- </a>
23
- </div>
24
- );
11
+ return <SkipToContentLink className={styles.skipToContent} />;
25
12
  }
@@ -102,6 +102,10 @@ function TabsComponent(props) {
102
102
  const handleKeydown = (event) => {
103
103
  let focusElement = null;
104
104
  switch (event.key) {
105
+ case 'Enter': {
106
+ handleTabChange(event);
107
+ break;
108
+ }
105
109
  case 'ArrowRight': {
106
110
  const nextTab = tabRefs.indexOf(event.currentTarget) + 1;
107
111
  focusElement = tabRefs[nextTab] ?? tabRefs[0];
@@ -137,7 +141,6 @@ function TabsComponent(props) {
137
141
  key={value}
138
142
  ref={(tabControl) => tabRefs.push(tabControl)}
139
143
  onKeyDown={handleKeydown}
140
- onFocus={handleTabChange}
141
144
  onClick={handleTabChange}
142
145
  {...attributes}
143
146
  className={clsx(
@@ -20,8 +20,8 @@
20
20
  }
21
21
 
22
22
  .tagRegular {
23
- border-radius: 0.5rem;
24
- padding: 0.3rem 0.5rem;
23
+ border-radius: var(--ifm-global-radius);
24
+ padding: 0.2rem 0.5rem 0.3rem;
25
25
  font-size: 90%;
26
26
  }
27
27