@docusaurus/theme-classic 2.1.0 → 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.
- package/lib/getSwizzleConfig.js +7 -0
- package/lib/theme/AnnouncementBar/styles.module.css +9 -1
- package/lib/theme/CodeBlock/Line/index.js +2 -4
- package/lib/theme/ColorModeToggle/index.js +2 -1
- package/lib/theme/Layout/index.js +6 -1
- package/lib/theme/MDXComponents/Code.js +24 -4
- package/lib/theme/MDXComponents/index.js +2 -0
- package/lib/theme/Mermaid.d.ts +7 -0
- package/lib/theme/Mermaid.js +13 -0
- package/lib/theme/Navbar/MobileSidebar/Header/index.js +6 -0
- package/lib/theme/Navbar/MobileSidebar/Toggle/index.js +11 -6
- package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +4 -1
- package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +5 -1
- package/lib/theme/SkipToContent/index.js +2 -18
- package/lib/theme/Tabs/index.js +4 -1
- package/lib/theme/Tag/styles.module.css +1 -1
- package/package.json +14 -14
- package/src/getSwizzleConfig.ts +8 -0
- package/src/theme/AnnouncementBar/styles.module.css +9 -1
- package/src/theme/CodeBlock/Line/index.tsx +2 -4
- package/src/theme/ColorModeToggle/index.tsx +2 -1
- package/src/theme/Layout/index.tsx +6 -1
- package/src/theme/MDXComponents/Code.tsx +24 -4
- package/src/theme/MDXComponents/index.tsx +2 -0
- package/src/theme/Mermaid.tsx +16 -0
- package/src/theme/Navbar/MobileSidebar/Header/index.tsx +6 -0
- package/src/theme/Navbar/MobileSidebar/Toggle/index.tsx +11 -6
- package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +4 -1
- package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +5 -1
- package/src/theme/SkipToContent/index.tsx +2 -18
- package/src/theme/Tabs/index.tsx +8 -2
- package/src/theme/Tag/styles.module.css +1 -1
- package/src/theme-classic.d.ts +10 -0
package/lib/getSwizzleConfig.js
CHANGED
|
@@ -222,6 +222,13 @@ function getSwizzleConfig() {
|
|
|
222
222
|
// By default it's an empty placeholder for the user to fill
|
|
223
223
|
description: 'The search bar component of your site, appearing in the navbar.',
|
|
224
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
|
+
},
|
|
225
232
|
'prism-include-languages': {
|
|
226
233
|
actions: {
|
|
227
234
|
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);
|
|
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 {
|
|
@@ -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
|
/>
|
|
@@ -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 {
|
|
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
|
-
'
|
|
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
|
-
'
|
|
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,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
|
|
12
|
+
const {toggle, shown} = useNavbarMobileSidebar();
|
|
12
13
|
return (
|
|
13
14
|
<button
|
|
14
|
-
onClick={
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
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
|
|
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,
|
|
@@ -5,24 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import
|
|
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
|
-
|
|
13
|
-
return (
|
|
14
|
-
<div
|
|
15
|
-
ref={containerRef}
|
|
16
|
-
role="region"
|
|
17
|
-
aria-label={translate({id: 'theme.common.skipToMainContent'})}>
|
|
18
|
-
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
19
|
-
<a href="#" className={styles.skipToContent} onClick={handleSkip}>
|
|
20
|
-
<Translate
|
|
21
|
-
id="theme.common.skipToMainContent"
|
|
22
|
-
description="The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation">
|
|
23
|
-
Skip to main content
|
|
24
|
-
</Translate>
|
|
25
|
-
</a>
|
|
26
|
-
</div>
|
|
27
|
-
);
|
|
11
|
+
return <SkipToContentLink className={styles.skipToContent} />;
|
|
28
12
|
}
|
package/lib/theme/Tabs/index.js
CHANGED
|
@@ -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(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@docusaurus/core": "2.
|
|
24
|
-
"@docusaurus/mdx-loader": "2.
|
|
25
|
-
"@docusaurus/module-type-aliases": "2.
|
|
26
|
-
"@docusaurus/plugin-content-blog": "2.
|
|
27
|
-
"@docusaurus/plugin-content-docs": "2.
|
|
28
|
-
"@docusaurus/plugin-content-pages": "2.
|
|
29
|
-
"@docusaurus/theme-common": "2.
|
|
30
|
-
"@docusaurus/theme-translations": "2.
|
|
31
|
-
"@docusaurus/types": "2.
|
|
32
|
-
"@docusaurus/utils": "2.
|
|
33
|
-
"@docusaurus/utils-common": "2.
|
|
34
|
-
"@docusaurus/utils-validation": "2.
|
|
23
|
+
"@docusaurus/core": "2.2.0",
|
|
24
|
+
"@docusaurus/mdx-loader": "2.2.0",
|
|
25
|
+
"@docusaurus/module-type-aliases": "2.2.0",
|
|
26
|
+
"@docusaurus/plugin-content-blog": "2.2.0",
|
|
27
|
+
"@docusaurus/plugin-content-docs": "2.2.0",
|
|
28
|
+
"@docusaurus/plugin-content-pages": "2.2.0",
|
|
29
|
+
"@docusaurus/theme-common": "2.2.0",
|
|
30
|
+
"@docusaurus/theme-translations": "2.2.0",
|
|
31
|
+
"@docusaurus/types": "2.2.0",
|
|
32
|
+
"@docusaurus/utils": "2.2.0",
|
|
33
|
+
"@docusaurus/utils-common": "2.2.0",
|
|
34
|
+
"@docusaurus/utils-validation": "2.2.0",
|
|
35
35
|
"@mdx-js/react": "^1.6.22",
|
|
36
36
|
"clsx": "^1.2.1",
|
|
37
37
|
"copy-text-to-clipboard": "^3.0.1",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=16.14"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "a308fb7c81832cca354192fe2984f52749441249"
|
|
66
66
|
}
|
package/src/getSwizzleConfig.ts
CHANGED
|
@@ -240,6 +240,14 @@ export default function getSwizzleConfig(): SwizzleConfig {
|
|
|
240
240
|
description:
|
|
241
241
|
'The search bar component of your site, appearing in the navbar.',
|
|
242
242
|
},
|
|
243
|
+
SkipToContent: {
|
|
244
|
+
actions: {
|
|
245
|
+
eject: 'safe',
|
|
246
|
+
wrap: 'safe',
|
|
247
|
+
},
|
|
248
|
+
description:
|
|
249
|
+
'The component responsible for implementing the accessibility "skip to content" link (https://www.w3.org/TR/WCAG20-TECHS/G1.html)',
|
|
250
|
+
},
|
|
243
251
|
'prism-include-languages': {
|
|
244
252
|
actions: {
|
|
245
253
|
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);
|
|
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 {
|
|
@@ -52,7 +52,8 @@ function ColorModeToggle({className, value, onChange}: Props): JSX.Element {
|
|
|
52
52
|
onClick={() => onChange(value === 'dark' ? 'light' : 'dark')}
|
|
53
53
|
disabled={!isBrowser}
|
|
54
54
|
title={title}
|
|
55
|
-
aria-label={title}
|
|
55
|
+
aria-label={title}
|
|
56
|
+
aria-live="polite">
|
|
56
57
|
<IconLightMode
|
|
57
58
|
className={clsx(styles.toggleIcon, styles.lightToggleIcon)}
|
|
58
59
|
/>
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
10
|
import ErrorBoundary from '@docusaurus/ErrorBoundary';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
PageMetadata,
|
|
13
|
+
SkipToContentFallbackId,
|
|
14
|
+
ThemeClassNames,
|
|
15
|
+
} from '@docusaurus/theme-common';
|
|
12
16
|
import {useKeyboardNavigation} from '@docusaurus/theme-common/internal';
|
|
13
17
|
import SkipToContent from '@theme/SkipToContent';
|
|
14
18
|
import AnnouncementBar from '@theme/AnnouncementBar';
|
|
@@ -42,6 +46,7 @@ export default function Layout(props: Props): JSX.Element {
|
|
|
42
46
|
<Navbar />
|
|
43
47
|
|
|
44
48
|
<div
|
|
49
|
+
id={SkipToContentFallbackId}
|
|
45
50
|
className={clsx(
|
|
46
51
|
ThemeClassNames.wrapper.main,
|
|
47
52
|
styles.mainWrapper,
|
|
@@ -13,15 +13,35 @@ import type {Props} from '@theme/MDXComponents/Code';
|
|
|
13
13
|
export default function MDXCode(props: Props): JSX.Element {
|
|
14
14
|
const inlineElements: (string | undefined)[] = [
|
|
15
15
|
'a',
|
|
16
|
+
'abbr',
|
|
16
17
|
'b',
|
|
17
|
-
'
|
|
18
|
+
'br',
|
|
19
|
+
'button',
|
|
20
|
+
'cite',
|
|
21
|
+
'code',
|
|
22
|
+
'del',
|
|
23
|
+
'dfn',
|
|
24
|
+
'em',
|
|
18
25
|
'i',
|
|
26
|
+
'img',
|
|
27
|
+
'input',
|
|
28
|
+
'ins',
|
|
29
|
+
'kbd',
|
|
30
|
+
'label',
|
|
31
|
+
'object',
|
|
32
|
+
'output',
|
|
33
|
+
'q',
|
|
34
|
+
'ruby',
|
|
35
|
+
's',
|
|
36
|
+
'small',
|
|
19
37
|
'span',
|
|
20
|
-
'em',
|
|
21
38
|
'strong',
|
|
22
|
-
'sup',
|
|
23
39
|
'sub',
|
|
24
|
-
'
|
|
40
|
+
'sup',
|
|
41
|
+
'time',
|
|
42
|
+
'u',
|
|
43
|
+
'var',
|
|
44
|
+
'wbr',
|
|
25
45
|
];
|
|
26
46
|
const shouldBeInline = React.Children.toArray(props.children).every(
|
|
27
47
|
(el) =>
|
|
@@ -15,6 +15,7 @@ import MDXHeading from '@theme/MDXComponents/Heading';
|
|
|
15
15
|
import MDXUl from '@theme/MDXComponents/Ul';
|
|
16
16
|
import MDXImg from '@theme/MDXComponents/Img';
|
|
17
17
|
import Admonition from '@theme/Admonition';
|
|
18
|
+
import Mermaid from '@theme/Mermaid';
|
|
18
19
|
|
|
19
20
|
import type {MDXComponentsObject} from '@theme/MDXComponents';
|
|
20
21
|
|
|
@@ -33,6 +34,7 @@ const MDXComponents: MDXComponentsObject = {
|
|
|
33
34
|
h5: (props) => <MDXHeading as="h5" {...props} />,
|
|
34
35
|
h6: (props) => <MDXHeading as="h6" {...props} />,
|
|
35
36
|
admonition: Admonition,
|
|
37
|
+
mermaid: Mermaid,
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
export default MDXComponents;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
// This component is meant to be implemented by a Mermaid renderer theme
|
|
9
|
+
// It is notable created to be overridden by docusaurus-theme-mermaid
|
|
10
|
+
|
|
11
|
+
// By default, the classic theme does not provide any Mermaid implementation
|
|
12
|
+
// Yet we declare it there so that we can register it in MDX
|
|
13
|
+
// TODO later the mermaid theme should be able to register its MDX component
|
|
14
|
+
// see https://github.com/facebook/docusaurus/pull/7490#issuecomment-1279117288
|
|
15
|
+
|
|
16
|
+
export {default} from '@docusaurus/Noop';
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import {useNavbarMobileSidebar} from '@docusaurus/theme-common/internal';
|
|
10
|
+
import {translate} from '@docusaurus/Translate';
|
|
10
11
|
import NavbarColorModeToggle from '@theme/Navbar/ColorModeToggle';
|
|
11
12
|
import IconClose from '@theme/Icon/Close';
|
|
12
13
|
import NavbarLogo from '@theme/Navbar/Logo';
|
|
@@ -16,6 +17,11 @@ function CloseButton() {
|
|
|
16
17
|
return (
|
|
17
18
|
<button
|
|
18
19
|
type="button"
|
|
20
|
+
aria-label={translate({
|
|
21
|
+
id: 'theme.docs.sidebar.closeSidebarButtonAriaLabel',
|
|
22
|
+
message: 'Close navigation bar',
|
|
23
|
+
description: 'The ARIA label for close button of mobile sidebar',
|
|
24
|
+
})}
|
|
19
25
|
className="clean-btn navbar-sidebar__close"
|
|
20
26
|
onClick={() => mobileSidebar.toggle()}>
|
|
21
27
|
<IconClose color="var(--ifm-color-emphasis-600)" />
|
|
@@ -7,18 +7,23 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import {useNavbarMobileSidebar} from '@docusaurus/theme-common/internal';
|
|
10
|
+
import {translate} from '@docusaurus/Translate';
|
|
10
11
|
import IconMenu from '@theme/Icon/Menu';
|
|
11
12
|
|
|
12
13
|
export default function MobileSidebarToggle(): JSX.Element {
|
|
13
|
-
const
|
|
14
|
+
const {toggle, shown} = useNavbarMobileSidebar();
|
|
14
15
|
return (
|
|
15
16
|
<button
|
|
16
|
-
onClick={
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
onClick={toggle}
|
|
18
|
+
aria-label={translate({
|
|
19
|
+
id: 'theme.docs.sidebar.toggleSidebarButtonAriaLabel',
|
|
20
|
+
message: 'Toggle navigation bar',
|
|
21
|
+
description:
|
|
22
|
+
'The ARIA label for hamburger menu button of mobile navigation',
|
|
23
|
+
})}
|
|
24
|
+
aria-expanded={shown}
|
|
19
25
|
className="navbar__toggle clean-btn"
|
|
20
|
-
type="button"
|
|
21
|
-
tabIndex={0}>
|
|
26
|
+
type="button">
|
|
22
27
|
<IconMenu />
|
|
23
28
|
</button>
|
|
24
29
|
);
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import {useDocsPreferredVersion} from '@docusaurus/theme-common';
|
|
14
14
|
import {useDocsVersionCandidates} from '@docusaurus/theme-common/internal';
|
|
15
15
|
import {translate} from '@docusaurus/Translate';
|
|
16
|
+
import {useLocation} from '@docusaurus/router';
|
|
16
17
|
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
17
18
|
import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
|
|
18
19
|
import type {Props} from '@theme/NavbarItem/DocsVersionDropdownNavbarItem';
|
|
@@ -29,6 +30,7 @@ export default function DocsVersionDropdownNavbarItem({
|
|
|
29
30
|
dropdownItemsAfter,
|
|
30
31
|
...props
|
|
31
32
|
}: Props): JSX.Element {
|
|
33
|
+
const {search, hash} = useLocation();
|
|
32
34
|
const activeDocContext = useActiveDocContext(docsPluginId);
|
|
33
35
|
const versions = useVersions(docsPluginId);
|
|
34
36
|
const {savePreferredVersionName} = useDocsPreferredVersion(docsPluginId);
|
|
@@ -40,7 +42,8 @@ export default function DocsVersionDropdownNavbarItem({
|
|
|
40
42
|
getVersionMainDoc(version);
|
|
41
43
|
return {
|
|
42
44
|
label: version.label,
|
|
43
|
-
|
|
45
|
+
// preserve ?search#hash suffix on version switches
|
|
46
|
+
to: `${versionDoc.path}${search}${hash}`,
|
|
44
47
|
isActive: () => version === activeDocContext.activeVersion,
|
|
45
48
|
onClick: () => savePreferredVersionName(version.name),
|
|
46
49
|
};
|
|
@@ -9,6 +9,7 @@ import React from 'react';
|
|
|
9
9
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
10
10
|
import {useAlternatePageUtils} from '@docusaurus/theme-common/internal';
|
|
11
11
|
import {translate} from '@docusaurus/Translate';
|
|
12
|
+
import {useLocation} from '@docusaurus/router';
|
|
12
13
|
import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
|
|
13
14
|
import IconLanguage from '@theme/Icon/Language';
|
|
14
15
|
import type {LinkLikeNavbarItemProps} from '@theme/NavbarItem';
|
|
@@ -26,12 +27,15 @@ export default function LocaleDropdownNavbarItem({
|
|
|
26
27
|
i18n: {currentLocale, locales, localeConfigs},
|
|
27
28
|
} = useDocusaurusContext();
|
|
28
29
|
const alternatePageUtils = useAlternatePageUtils();
|
|
30
|
+
const {search, hash} = useLocation();
|
|
29
31
|
|
|
30
32
|
const localeItems = locales.map((locale): LinkLikeNavbarItemProps => {
|
|
31
|
-
const
|
|
33
|
+
const baseTo = `pathname://${alternatePageUtils.createUrl({
|
|
32
34
|
locale,
|
|
33
35
|
fullyQualified: false,
|
|
34
36
|
})}`;
|
|
37
|
+
// preserve ?search#hash suffix on locale switches
|
|
38
|
+
const to = `${baseTo}${search}${hash}`;
|
|
35
39
|
return {
|
|
36
40
|
label: localeConfigs[locale]!.label,
|
|
37
41
|
lang: localeConfigs[locale]!.htmlLang,
|
|
@@ -6,26 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import
|
|
10
|
-
import {useSkipToContent} from '@docusaurus/theme-common/internal';
|
|
9
|
+
import {SkipToContentLink} from '@docusaurus/theme-common';
|
|
11
10
|
|
|
12
11
|
import styles from './styles.module.css';
|
|
13
12
|
|
|
14
13
|
export default function SkipToContent(): JSX.Element {
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<div
|
|
18
|
-
ref={containerRef}
|
|
19
|
-
role="region"
|
|
20
|
-
aria-label={translate({id: 'theme.common.skipToMainContent'})}>
|
|
21
|
-
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
22
|
-
<a href="#" className={styles.skipToContent} onClick={handleSkip}>
|
|
23
|
-
<Translate
|
|
24
|
-
id="theme.common.skipToMainContent"
|
|
25
|
-
description="The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation">
|
|
26
|
-
Skip to main content
|
|
27
|
-
</Translate>
|
|
28
|
-
</a>
|
|
29
|
-
</div>
|
|
30
|
-
);
|
|
14
|
+
return <SkipToContentLink className={styles.skipToContent} />;
|
|
31
15
|
}
|
package/src/theme/Tabs/index.tsx
CHANGED
|
@@ -104,7 +104,10 @@ function TabsComponent(props: Props): JSX.Element {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
const handleTabChange = (
|
|
107
|
-
event:
|
|
107
|
+
event:
|
|
108
|
+
| React.FocusEvent<HTMLLIElement>
|
|
109
|
+
| React.MouseEvent<HTMLLIElement>
|
|
110
|
+
| React.KeyboardEvent<HTMLLIElement>,
|
|
108
111
|
) => {
|
|
109
112
|
const newTab = event.currentTarget;
|
|
110
113
|
const newTabIndex = tabRefs.indexOf(newTab);
|
|
@@ -124,6 +127,10 @@ function TabsComponent(props: Props): JSX.Element {
|
|
|
124
127
|
let focusElement: HTMLLIElement | null = null;
|
|
125
128
|
|
|
126
129
|
switch (event.key) {
|
|
130
|
+
case 'Enter': {
|
|
131
|
+
handleTabChange(event);
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
127
134
|
case 'ArrowRight': {
|
|
128
135
|
const nextTab = tabRefs.indexOf(event.currentTarget) + 1;
|
|
129
136
|
focusElement = tabRefs[nextTab] ?? tabRefs[0]!;
|
|
@@ -161,7 +168,6 @@ function TabsComponent(props: Props): JSX.Element {
|
|
|
161
168
|
key={value}
|
|
162
169
|
ref={(tabControl) => tabRefs.push(tabControl)}
|
|
163
170
|
onKeyDown={handleKeydown}
|
|
164
|
-
onFocus={handleTabChange}
|
|
165
171
|
onClick={handleTabChange}
|
|
166
172
|
{...attributes}
|
|
167
173
|
className={clsx(
|
package/src/theme-classic.d.ts
CHANGED
|
@@ -788,6 +788,7 @@ declare module '@theme/MDXComponents' {
|
|
|
788
788
|
import type MDXUl from '@theme/MDXComponents/Ul';
|
|
789
789
|
import type MDXImg from '@theme/MDXComponents/Img';
|
|
790
790
|
import type Admonition from '@theme/Admonition';
|
|
791
|
+
import type Mermaid from '@theme/Mermaid';
|
|
791
792
|
|
|
792
793
|
export type MDXComponentsObject = {
|
|
793
794
|
readonly head: typeof MDXHead;
|
|
@@ -804,6 +805,7 @@ declare module '@theme/MDXComponents' {
|
|
|
804
805
|
readonly h5: (props: ComponentProps<'h5'>) => JSX.Element;
|
|
805
806
|
readonly h6: (props: ComponentProps<'h6'>) => JSX.Element;
|
|
806
807
|
readonly admonition: typeof Admonition;
|
|
808
|
+
readonly mermaid: typeof Mermaid;
|
|
807
809
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
808
810
|
[tagName: string]: ComponentType<any>;
|
|
809
811
|
};
|
|
@@ -1112,6 +1114,14 @@ declare module '@theme/SearchBar' {
|
|
|
1112
1114
|
export default function SearchBar(): JSX.Element;
|
|
1113
1115
|
}
|
|
1114
1116
|
|
|
1117
|
+
declare module '@theme/Mermaid' {
|
|
1118
|
+
export interface Props {
|
|
1119
|
+
value: string;
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
export default function Mermaid(props: Props): JSX.Element;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1115
1125
|
declare module '@theme/TabItem' {
|
|
1116
1126
|
import type {ReactNode} from 'react';
|
|
1117
1127
|
|