@docusaurus/theme-classic 0.0.0-4928 → 0.0.0-4932

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 (26) hide show
  1. package/lib/theme-classic.d.ts +12 -2
  2. package/lib-next/theme/DocPage/Layout/{Main.js → Main/index.js} +0 -0
  3. package/lib-next/theme/DocPage/Layout/Main/styles.module.css +28 -0
  4. package/lib-next/theme/DocPage/Layout/Sidebar/ExpandButton/index.js +34 -0
  5. package/lib-next/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +37 -0
  6. package/lib-next/theme/DocPage/Layout/{Aside.js → Sidebar/index.js} +5 -31
  7. package/lib-next/theme/DocPage/Layout/Sidebar/index.module.css +32 -0
  8. package/lib-next/theme/DocPage/Layout/index.js +3 -3
  9. package/lib-next/theme/DocPage/Layout/index.module.css +15 -0
  10. package/lib-next/theme/DocPage/index.js +2 -32
  11. package/lib-next/theme/TOCItems/Tree.js +1 -2
  12. package/package.json +13 -13
  13. package/src/theme/DocPage/Layout/{Main.tsx → Main/index.tsx} +0 -0
  14. package/src/theme/DocPage/Layout/Main/styles.module.css +28 -0
  15. package/src/theme/DocPage/Layout/Sidebar/ExpandButton/index.tsx +40 -0
  16. package/src/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +37 -0
  17. package/src/theme/DocPage/Layout/Sidebar/index.module.css +32 -0
  18. package/src/theme/DocPage/Layout/{Aside.tsx → Sidebar/index.tsx} +5 -31
  19. package/src/theme/DocPage/Layout/index.module.css +15 -0
  20. package/src/theme/DocPage/Layout/index.tsx +3 -3
  21. package/src/theme/DocPage/index.tsx +2 -39
  22. package/src/theme/MDXComponents/Details.tsx +2 -3
  23. package/src/theme/TOCItems/Tree.tsx +1 -1
  24. package/src/theme-classic.d.ts +12 -2
  25. package/lib-next/theme/DocPage/Layout/styles.module.css +0 -87
  26. package/src/theme/DocPage/Layout/styles.module.css +0 -87
@@ -268,7 +268,7 @@ declare module '@theme/DocPage/Layout' {
268
268
  export default function DocPageLayout(props: Props): JSX.Element;
269
269
  }
270
270
 
271
- declare module '@theme/DocPage/Layout/Aside' {
271
+ declare module '@theme/DocPage/Layout/Sidebar' {
272
272
  import type {Dispatch, SetStateAction} from 'react';
273
273
  import type {PropSidebar} from '@docusaurus/plugin-content-docs';
274
274
 
@@ -278,7 +278,17 @@ declare module '@theme/DocPage/Layout/Aside' {
278
278
  readonly setHiddenSidebarContainer: Dispatch<SetStateAction<boolean>>;
279
279
  }
280
280
 
281
- export default function DocPageLayoutAside(props: Props): JSX.Element;
281
+ export default function DocPageLayoutSidebar(props: Props): JSX.Element;
282
+ }
283
+
284
+ declare module '@theme/DocPage/Layout/Sidebar/ExpandButton' {
285
+ export interface Props {
286
+ toggleSidebar: () => void;
287
+ }
288
+
289
+ export default function DocPageLayoutSidebarExpandButton(
290
+ props: Props,
291
+ ): JSX.Element;
282
292
  }
283
293
 
284
294
  declare module '@theme/DocPage/Layout/Main' {
@@ -0,0 +1,28 @@
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
+ .docMainContainer {
9
+ display: flex;
10
+ width: 100%;
11
+ }
12
+
13
+ @media (min-width: 997px) {
14
+ .docMainContainer {
15
+ flex-grow: 1;
16
+ max-width: calc(100% - var(--doc-sidebar-width));
17
+ }
18
+
19
+ .docMainContainerEnhanced {
20
+ max-width: calc(100% - var(--doc-sidebar-hidden-width));
21
+ }
22
+
23
+ .docItemWrapperEnhanced {
24
+ max-width: calc(
25
+ var(--ifm-container-width) + var(--doc-sidebar-width)
26
+ ) !important;
27
+ }
28
+ }
@@ -0,0 +1,34 @@
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 IconArrow from '@theme/IconArrow';
9
+ import {translate} from '@docusaurus/Translate';
10
+ import styles from './styles.module.css';
11
+ export default function DocPageLayoutSidebarExpandButton({toggleSidebar}) {
12
+ return (
13
+ <div
14
+ className={styles.expandButton}
15
+ title={translate({
16
+ id: 'theme.docs.sidebar.expandButtonTitle',
17
+ message: 'Expand sidebar',
18
+ description:
19
+ 'The ARIA label and title attribute for expand button of doc sidebar',
20
+ })}
21
+ aria-label={translate({
22
+ id: 'theme.docs.sidebar.expandButtonAriaLabel',
23
+ message: 'Expand sidebar',
24
+ description:
25
+ 'The ARIA label and title attribute for expand button of doc sidebar',
26
+ })}
27
+ tabIndex={0}
28
+ role="button"
29
+ onKeyDown={toggleSidebar}
30
+ onClick={toggleSidebar}>
31
+ <IconArrow className={styles.expandButtonIcon} />
32
+ </div>
33
+ );
34
+ }
@@ -0,0 +1,37 @@
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
+ @media (min-width: 997px) {
9
+ .expandButton {
10
+ position: sticky;
11
+ top: 0;
12
+ height: 100%;
13
+ max-height: 100vh;
14
+ display: flex;
15
+ align-items: center;
16
+ justify-content: center;
17
+ transition: background-color var(--ifm-transition-fast) ease;
18
+ }
19
+
20
+ .expandButton:hover,
21
+ .expandButton:focus {
22
+ background-color: var(--ifm-color-emphasis-200);
23
+ }
24
+
25
+ .expandButtonIcon {
26
+ transform: rotate(0);
27
+ }
28
+
29
+ [dir='rtl'] .expandButtonIcon {
30
+ transform: rotate(180deg);
31
+ }
32
+
33
+ [data-theme='dark'] .expandButton:hover,
34
+ [data-theme='dark'] .expandButton:focus {
35
+ background-color: var(--collapse-button-bg-color-dark);
36
+ }
37
+ }
@@ -6,37 +6,11 @@
6
6
  */
7
7
  import React, {useState, useCallback} from 'react';
8
8
  import DocSidebar from '@theme/DocSidebar';
9
- import IconArrow from '@theme/IconArrow';
10
- import {translate} from '@docusaurus/Translate';
11
9
  import {useLocation} from '@docusaurus/router';
10
+ import ExpandButton from '@theme/DocPage/Layout/Sidebar/ExpandButton';
12
11
  import clsx from 'clsx';
13
- import styles from './styles.module.css';
14
- import {ThemeClassNames, useDocsSidebar} from '@docusaurus/theme-common';
15
-
16
- function SidebarExpandButton({toggleSidebar}) {
17
- return (
18
- <div
19
- className={styles.collapsedDocSidebar}
20
- title={translate({
21
- id: 'theme.docs.sidebar.expandButtonTitle',
22
- message: 'Expand sidebar',
23
- description:
24
- 'The ARIA label and title attribute for expand button of doc sidebar',
25
- })}
26
- aria-label={translate({
27
- id: 'theme.docs.sidebar.expandButtonAriaLabel',
28
- message: 'Expand sidebar',
29
- description:
30
- 'The ARIA label and title attribute for expand button of doc sidebar',
31
- })}
32
- tabIndex={0}
33
- role="button"
34
- onKeyDown={toggleSidebar}
35
- onClick={toggleSidebar}>
36
- <IconArrow className={styles.expandSidebarButtonIcon} />
37
- </div>
38
- );
39
- } // Reset sidebar state when sidebar changes
12
+ import styles from './index.module.css';
13
+ import {ThemeClassNames, useDocsSidebar} from '@docusaurus/theme-common'; // Reset sidebar state when sidebar changes
40
14
  // Use React key to unmount/remount the children
41
15
  // See https://github.com/facebook/docusaurus/issues/3414
42
16
 
@@ -49,7 +23,7 @@ function ResetOnSidebarChange({children}) {
49
23
  );
50
24
  }
51
25
 
52
- export default function DocPageLayoutAside({
26
+ export default function DocPageLayoutSidebar({
53
27
  sidebar,
54
28
  hiddenSidebarContainer,
55
29
  setHiddenSidebarContainer,
@@ -88,7 +62,7 @@ export default function DocPageLayoutAside({
88
62
  />
89
63
  </ResetOnSidebarChange>
90
64
 
91
- {hiddenSidebar && <SidebarExpandButton toggleSidebar={toggleSidebar} />}
65
+ {hiddenSidebar && <ExpandButton toggleSidebar={toggleSidebar} />}
92
66
  </aside>
93
67
  );
94
68
  }
@@ -0,0 +1,32 @@
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
+ :root {
9
+ --doc-sidebar-width: 300px;
10
+ --doc-sidebar-hidden-width: 30px;
11
+ }
12
+
13
+ .docSidebarContainer {
14
+ display: none;
15
+ }
16
+
17
+ @media (min-width: 997px) {
18
+ .docSidebarContainer {
19
+ display: block;
20
+ width: var(--doc-sidebar-width);
21
+ margin-top: calc(-1 * var(--ifm-navbar-height));
22
+ border-right: 1px solid var(--ifm-toc-border-color);
23
+ will-change: width;
24
+ transition: width var(--ifm-transition-fast) ease;
25
+ clip-path: inset(0);
26
+ }
27
+
28
+ .docSidebarContainerHidden {
29
+ width: var(--doc-sidebar-hidden-width);
30
+ cursor: pointer;
31
+ }
32
+ }
@@ -7,9 +7,9 @@
7
7
  import React, {useState} from 'react';
8
8
  import Layout from '@theme/Layout';
9
9
  import BackToTopButton from '@theme/BackToTopButton';
10
- import DocPageLayoutAside from '@theme/DocPage/Layout/Aside';
10
+ import DocPageLayoutSidebar from '@theme/DocPage/Layout/Sidebar';
11
11
  import DocPageLayoutMain from '@theme/DocPage/Layout/Main';
12
- import styles from './styles.module.css';
12
+ import styles from './index.module.css';
13
13
  import {useDocsSidebar} from '@docusaurus/theme-common';
14
14
  export default function DocPageLayout({children}) {
15
15
  const sidebar = useDocsSidebar();
@@ -19,7 +19,7 @@ export default function DocPageLayout({children}) {
19
19
  <BackToTopButton />
20
20
  <div className={styles.docPage}>
21
21
  {sidebar && (
22
- <DocPageLayoutAside
22
+ <DocPageLayoutSidebar
23
23
  sidebar={sidebar.items}
24
24
  hiddenSidebarContainer={hiddenSidebarContainer}
25
25
  setHiddenSidebarContainer={setHiddenSidebarContainer}
@@ -0,0 +1,15 @@
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
+ .docPage {
9
+ display: flex;
10
+ width: 100%;
11
+ }
12
+
13
+ .docsWrapper {
14
+ display: flex;
15
+ }
@@ -5,10 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- import renderRoutes from '@docusaurus/renderRoutes';
9
8
  import NotFound from '@theme/NotFound';
10
9
  import DocPageLayout from '@theme/DocPage/Layout';
11
- import {matchPath} from '@docusaurus/router';
12
10
  import clsx from 'clsx';
13
11
  import {
14
12
  HtmlClassNameProvider,
@@ -16,40 +14,12 @@ import {
16
14
  docVersionSearchTag,
17
15
  DocsSidebarProvider,
18
16
  DocsVersionProvider,
17
+ useDocRouteMetadata,
19
18
  } from '@docusaurus/theme-common';
20
19
  import SearchMetadata from '@theme/SearchMetadata';
21
-
22
- function extractDocRouteMetadata(props) {
23
- const {
24
- route: {routes: docRoutes},
25
- versionMetadata,
26
- location,
27
- } = props;
28
- const currentDocRoute = docRoutes.find((docRoute) =>
29
- matchPath(location.pathname, docRoute),
30
- );
31
-
32
- if (!currentDocRoute) {
33
- return null;
34
- } // For now, the sidebarName is added as route config: not ideal!
35
-
36
- const sidebarName = currentDocRoute.sidebar;
37
- const sidebarItems = sidebarName
38
- ? versionMetadata.docsSidebars[sidebarName]
39
- : undefined;
40
- const docElement = renderRoutes(props.route.routes, {
41
- versionMetadata,
42
- });
43
- return {
44
- docElement,
45
- sidebarName,
46
- sidebarItems,
47
- };
48
- }
49
-
50
20
  export default function DocPage(props) {
51
21
  const {versionMetadata} = props;
52
- const currentDocRouteMetadata = extractDocRouteMetadata(props);
22
+ const currentDocRouteMetadata = useDocRouteMetadata(props);
53
23
 
54
24
  if (!currentDocRouteMetadata) {
55
25
  return <NotFound />;
@@ -7,8 +7,6 @@
7
7
  import React from 'react';
8
8
 
9
9
  // Recursive component rendering the toc tree
10
-
11
- /* eslint-disable jsx-a11y/control-has-associated-label */
12
10
  function TOCItemTree({toc, className, linkClassName, isChild}) {
13
11
  if (!toc.length) {
14
12
  return null;
@@ -18,6 +16,7 @@ function TOCItemTree({toc, className, linkClassName, isChild}) {
18
16
  <ul className={isChild ? undefined : className}>
19
17
  {toc.map((heading) => (
20
18
  <li key={heading.id}>
19
+ {/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}
21
20
  <a
22
21
  href={`#${heading.id}`}
23
22
  className={linkClassName ?? undefined} // Developer provided the HTML, so assume it's safe.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-4928",
3
+ "version": "0.0.0-4932",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -21,15 +21,15 @@
21
21
  "format:lib-next": "prettier --config ../../.prettierrc --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
22
22
  },
23
23
  "dependencies": {
24
- "@docusaurus/core": "0.0.0-4928",
25
- "@docusaurus/plugin-content-blog": "0.0.0-4928",
26
- "@docusaurus/plugin-content-docs": "0.0.0-4928",
27
- "@docusaurus/plugin-content-pages": "0.0.0-4928",
28
- "@docusaurus/theme-common": "0.0.0-4928",
29
- "@docusaurus/theme-translations": "0.0.0-4928",
30
- "@docusaurus/utils": "0.0.0-4928",
31
- "@docusaurus/utils-common": "0.0.0-4928",
32
- "@docusaurus/utils-validation": "0.0.0-4928",
24
+ "@docusaurus/core": "0.0.0-4932",
25
+ "@docusaurus/plugin-content-blog": "0.0.0-4932",
26
+ "@docusaurus/plugin-content-docs": "0.0.0-4932",
27
+ "@docusaurus/plugin-content-pages": "0.0.0-4932",
28
+ "@docusaurus/theme-common": "0.0.0-4932",
29
+ "@docusaurus/theme-translations": "0.0.0-4932",
30
+ "@docusaurus/utils": "0.0.0-4932",
31
+ "@docusaurus/utils-common": "0.0.0-4932",
32
+ "@docusaurus/utils-validation": "0.0.0-4932",
33
33
  "@mdx-js/react": "^1.6.22",
34
34
  "clsx": "^1.1.1",
35
35
  "copy-text-to-clipboard": "^3.0.1",
@@ -46,8 +46,8 @@
46
46
  "@babel/cli": "^7.17.6",
47
47
  "@babel/core": "^7.17.9",
48
48
  "@babel/preset-typescript": "^7.16.7",
49
- "@docusaurus/module-type-aliases": "0.0.0-4928",
50
- "@docusaurus/types": "0.0.0-4928",
49
+ "@docusaurus/module-type-aliases": "0.0.0-4932",
50
+ "@docusaurus/types": "0.0.0-4932",
51
51
  "@types/mdx-js__react": "^1.5.5",
52
52
  "@types/nprogress": "^0.2.0",
53
53
  "@types/prismjs": "^1.26.0",
@@ -64,5 +64,5 @@
64
64
  "engines": {
65
65
  "node": ">=14"
66
66
  },
67
- "gitHead": "fc6b6a5b2caee19226c279ad3ec7098ee567a123"
67
+ "gitHead": "3881e34a127c27aa691bcdf281463d7b20c257aa"
68
68
  }
@@ -0,0 +1,28 @@
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
+ .docMainContainer {
9
+ display: flex;
10
+ width: 100%;
11
+ }
12
+
13
+ @media (min-width: 997px) {
14
+ .docMainContainer {
15
+ flex-grow: 1;
16
+ max-width: calc(100% - var(--doc-sidebar-width));
17
+ }
18
+
19
+ .docMainContainerEnhanced {
20
+ max-width: calc(100% - var(--doc-sidebar-hidden-width));
21
+ }
22
+
23
+ .docItemWrapperEnhanced {
24
+ max-width: calc(
25
+ var(--ifm-container-width) + var(--doc-sidebar-width)
26
+ ) !important;
27
+ }
28
+ }
@@ -0,0 +1,40 @@
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
+ import React from 'react';
9
+ import IconArrow from '@theme/IconArrow';
10
+ import {translate} from '@docusaurus/Translate';
11
+ import type {Props} from '@theme/DocPage/Layout/Sidebar/ExpandButton';
12
+
13
+ import styles from './styles.module.css';
14
+
15
+ export default function DocPageLayoutSidebarExpandButton({
16
+ toggleSidebar,
17
+ }: Props): JSX.Element {
18
+ return (
19
+ <div
20
+ className={styles.expandButton}
21
+ title={translate({
22
+ id: 'theme.docs.sidebar.expandButtonTitle',
23
+ message: 'Expand sidebar',
24
+ description:
25
+ 'The ARIA label and title attribute for expand button of doc sidebar',
26
+ })}
27
+ aria-label={translate({
28
+ id: 'theme.docs.sidebar.expandButtonAriaLabel',
29
+ message: 'Expand sidebar',
30
+ description:
31
+ 'The ARIA label and title attribute for expand button of doc sidebar',
32
+ })}
33
+ tabIndex={0}
34
+ role="button"
35
+ onKeyDown={toggleSidebar}
36
+ onClick={toggleSidebar}>
37
+ <IconArrow className={styles.expandButtonIcon} />
38
+ </div>
39
+ );
40
+ }
@@ -0,0 +1,37 @@
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
+ @media (min-width: 997px) {
9
+ .expandButton {
10
+ position: sticky;
11
+ top: 0;
12
+ height: 100%;
13
+ max-height: 100vh;
14
+ display: flex;
15
+ align-items: center;
16
+ justify-content: center;
17
+ transition: background-color var(--ifm-transition-fast) ease;
18
+ }
19
+
20
+ .expandButton:hover,
21
+ .expandButton:focus {
22
+ background-color: var(--ifm-color-emphasis-200);
23
+ }
24
+
25
+ .expandButtonIcon {
26
+ transform: rotate(0);
27
+ }
28
+
29
+ [dir='rtl'] .expandButtonIcon {
30
+ transform: rotate(180deg);
31
+ }
32
+
33
+ [data-theme='dark'] .expandButton:hover,
34
+ [data-theme='dark'] .expandButton:focus {
35
+ background-color: var(--collapse-button-bg-color-dark);
36
+ }
37
+ }
@@ -0,0 +1,32 @@
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
+ :root {
9
+ --doc-sidebar-width: 300px;
10
+ --doc-sidebar-hidden-width: 30px;
11
+ }
12
+
13
+ .docSidebarContainer {
14
+ display: none;
15
+ }
16
+
17
+ @media (min-width: 997px) {
18
+ .docSidebarContainer {
19
+ display: block;
20
+ width: var(--doc-sidebar-width);
21
+ margin-top: calc(-1 * var(--ifm-navbar-height));
22
+ border-right: 1px solid var(--ifm-toc-border-color);
23
+ will-change: width;
24
+ transition: width var(--ifm-transition-fast) ease;
25
+ clip-path: inset(0);
26
+ }
27
+
28
+ .docSidebarContainerHidden {
29
+ width: var(--doc-sidebar-hidden-width);
30
+ cursor: pointer;
31
+ }
32
+ }
@@ -7,41 +7,15 @@
7
7
 
8
8
  import React, {type ReactNode, useState, useCallback} from 'react';
9
9
  import DocSidebar from '@theme/DocSidebar';
10
- import IconArrow from '@theme/IconArrow';
11
- import {translate} from '@docusaurus/Translate';
12
10
  import {useLocation} from '@docusaurus/router';
13
- import type {Props} from '@theme/DocPage/Layout/Aside';
11
+ import type {Props} from '@theme/DocPage/Layout/Sidebar';
12
+ import ExpandButton from '@theme/DocPage/Layout/Sidebar/ExpandButton';
14
13
 
15
14
  import clsx from 'clsx';
16
- import styles from './styles.module.css';
15
+ import styles from './index.module.css';
17
16
 
18
17
  import {ThemeClassNames, useDocsSidebar} from '@docusaurus/theme-common';
19
18
 
20
- function SidebarExpandButton({toggleSidebar}: {toggleSidebar: () => void}) {
21
- return (
22
- <div
23
- className={styles.collapsedDocSidebar}
24
- title={translate({
25
- id: 'theme.docs.sidebar.expandButtonTitle',
26
- message: 'Expand sidebar',
27
- description:
28
- 'The ARIA label and title attribute for expand button of doc sidebar',
29
- })}
30
- aria-label={translate({
31
- id: 'theme.docs.sidebar.expandButtonAriaLabel',
32
- message: 'Expand sidebar',
33
- description:
34
- 'The ARIA label and title attribute for expand button of doc sidebar',
35
- })}
36
- tabIndex={0}
37
- role="button"
38
- onKeyDown={toggleSidebar}
39
- onClick={toggleSidebar}>
40
- <IconArrow className={styles.expandSidebarButtonIcon} />
41
- </div>
42
- );
43
- }
44
-
45
19
  // Reset sidebar state when sidebar changes
46
20
  // Use React key to unmount/remount the children
47
21
  // See https://github.com/facebook/docusaurus/issues/3414
@@ -54,7 +28,7 @@ function ResetOnSidebarChange({children}: {children: ReactNode}) {
54
28
  );
55
29
  }
56
30
 
57
- export default function DocPageLayoutAside({
31
+ export default function DocPageLayoutSidebar({
58
32
  sidebar,
59
33
  hiddenSidebarContainer,
60
34
  setHiddenSidebarContainer,
@@ -94,7 +68,7 @@ export default function DocPageLayoutAside({
94
68
  />
95
69
  </ResetOnSidebarChange>
96
70
 
97
- {hiddenSidebar && <SidebarExpandButton toggleSidebar={toggleSidebar} />}
71
+ {hiddenSidebar && <ExpandButton toggleSidebar={toggleSidebar} />}
98
72
  </aside>
99
73
  );
100
74
  }
@@ -0,0 +1,15 @@
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
+ .docPage {
9
+ display: flex;
10
+ width: 100%;
11
+ }
12
+
13
+ .docsWrapper {
14
+ display: flex;
15
+ }
@@ -9,10 +9,10 @@ import React, {useState} from 'react';
9
9
  import Layout from '@theme/Layout';
10
10
  import BackToTopButton from '@theme/BackToTopButton';
11
11
  import type {Props} from '@theme/DocPage/Layout';
12
- import DocPageLayoutAside from '@theme/DocPage/Layout/Aside';
12
+ import DocPageLayoutSidebar from '@theme/DocPage/Layout/Sidebar';
13
13
  import DocPageLayoutMain from '@theme/DocPage/Layout/Main';
14
14
 
15
- import styles from './styles.module.css';
15
+ import styles from './index.module.css';
16
16
 
17
17
  import {useDocsSidebar} from '@docusaurus/theme-common';
18
18
 
@@ -24,7 +24,7 @@ export default function DocPageLayout({children}: Props): JSX.Element {
24
24
  <BackToTopButton />
25
25
  <div className={styles.docPage}>
26
26
  {sidebar && (
27
- <DocPageLayoutAside
27
+ <DocPageLayoutSidebar
28
28
  sidebar={sidebar.items}
29
29
  hiddenSidebarContainer={hiddenSidebarContainer}
30
30
  setHiddenSidebarContainer={setHiddenSidebarContainer}
@@ -6,12 +6,9 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import renderRoutes from '@docusaurus/renderRoutes';
10
- import type {PropSidebar} from '@docusaurus/plugin-content-docs';
11
9
  import NotFound from '@theme/NotFound';
12
10
  import type {Props} from '@theme/DocPage';
13
11
  import DocPageLayout from '@theme/DocPage/Layout';
14
- import {matchPath} from '@docusaurus/router';
15
12
 
16
13
  import clsx from 'clsx';
17
14
 
@@ -21,47 +18,13 @@ import {
21
18
  docVersionSearchTag,
22
19
  DocsSidebarProvider,
23
20
  DocsVersionProvider,
21
+ useDocRouteMetadata,
24
22
  } from '@docusaurus/theme-common';
25
23
  import SearchMetadata from '@theme/SearchMetadata';
26
24
 
27
- function extractDocRouteMetadata(props: Props): null | {
28
- docElement: JSX.Element;
29
- sidebarName: string | undefined;
30
- sidebarItems: PropSidebar | undefined;
31
- } {
32
- const {
33
- route: {routes: docRoutes},
34
- versionMetadata,
35
- location,
36
- } = props;
37
- const currentDocRoute = docRoutes!.find((docRoute) =>
38
- matchPath(location.pathname, docRoute),
39
- );
40
- if (!currentDocRoute) {
41
- return null;
42
- }
43
-
44
- // For now, the sidebarName is added as route config: not ideal!
45
- const sidebarName = currentDocRoute.sidebar;
46
-
47
- const sidebarItems = sidebarName
48
- ? versionMetadata.docsSidebars[sidebarName]
49
- : undefined;
50
-
51
- const docElement = renderRoutes(props.route.routes, {
52
- versionMetadata,
53
- });
54
-
55
- return {
56
- docElement,
57
- sidebarName,
58
- sidebarItems,
59
- };
60
- }
61
-
62
25
  export default function DocPage(props: Props): JSX.Element {
63
26
  const {versionMetadata} = props;
64
- const currentDocRouteMetadata = extractDocRouteMetadata(props);
27
+ const currentDocRouteMetadata = useDocRouteMetadata(props);
65
28
  if (!currentDocRouteMetadata) {
66
29
  return <NotFound />;
67
30
  }
@@ -13,9 +13,8 @@ export default function MDXDetails(props: Props): JSX.Element {
13
13
  const items = React.Children.toArray(props.children) as ReactElement[];
14
14
  // Split summary item from the rest to pass it as a separate prop to the
15
15
  // Details theme component
16
- const summary: ReactElement<ComponentProps<'summary'>> = items.find(
17
- (item) => item?.props?.mdxType === 'summary',
18
- )!;
16
+ const summary: ReactElement<ComponentProps<'summary'>> | undefined =
17
+ items.find((item) => item?.props?.mdxType === 'summary');
19
18
  const children = <>{items.filter((item) => item !== summary)}</>;
20
19
 
21
20
  return (
@@ -9,7 +9,6 @@ import React from 'react';
9
9
  import type {Props} from '@theme/TOCItems/Tree';
10
10
 
11
11
  // Recursive component rendering the toc tree
12
- /* eslint-disable jsx-a11y/control-has-associated-label */
13
12
  function TOCItemTree({
14
13
  toc,
15
14
  className,
@@ -23,6 +22,7 @@ function TOCItemTree({
23
22
  <ul className={isChild ? undefined : className}>
24
23
  {toc.map((heading) => (
25
24
  <li key={heading.id}>
25
+ {/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}
26
26
  <a
27
27
  href={`#${heading.id}`}
28
28
  className={linkClassName ?? undefined}
@@ -268,7 +268,7 @@ declare module '@theme/DocPage/Layout' {
268
268
  export default function DocPageLayout(props: Props): JSX.Element;
269
269
  }
270
270
 
271
- declare module '@theme/DocPage/Layout/Aside' {
271
+ declare module '@theme/DocPage/Layout/Sidebar' {
272
272
  import type {Dispatch, SetStateAction} from 'react';
273
273
  import type {PropSidebar} from '@docusaurus/plugin-content-docs';
274
274
 
@@ -278,7 +278,17 @@ declare module '@theme/DocPage/Layout/Aside' {
278
278
  readonly setHiddenSidebarContainer: Dispatch<SetStateAction<boolean>>;
279
279
  }
280
280
 
281
- export default function DocPageLayoutAside(props: Props): JSX.Element;
281
+ export default function DocPageLayoutSidebar(props: Props): JSX.Element;
282
+ }
283
+
284
+ declare module '@theme/DocPage/Layout/Sidebar/ExpandButton' {
285
+ export interface Props {
286
+ toggleSidebar: () => void;
287
+ }
288
+
289
+ export default function DocPageLayoutSidebarExpandButton(
290
+ props: Props,
291
+ ): JSX.Element;
282
292
  }
283
293
 
284
294
  declare module '@theme/DocPage/Layout/Main' {
@@ -1,87 +0,0 @@
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
- :root {
9
- --doc-sidebar-width: 300px;
10
- --doc-sidebar-hidden-width: 30px;
11
- }
12
-
13
- .docPage,
14
- .docMainContainer {
15
- width: 100%;
16
- }
17
-
18
- .docsWrapper,
19
- .docPage,
20
- .docMainContainer {
21
- display: flex;
22
- }
23
-
24
- .docSidebarContainer {
25
- display: none;
26
- }
27
-
28
- @media (min-width: 997px) {
29
- .docMainContainer {
30
- flex-grow: 1;
31
- max-width: calc(100% - var(--doc-sidebar-width));
32
- }
33
-
34
- .docMainContainerEnhanced {
35
- max-width: calc(100% - var(--doc-sidebar-hidden-width));
36
- }
37
-
38
- .docSidebarContainer {
39
- display: block;
40
- width: var(--doc-sidebar-width);
41
- margin-top: calc(-1 * var(--ifm-navbar-height));
42
- border-right: 1px solid var(--ifm-toc-border-color);
43
- will-change: width;
44
- transition: width var(--ifm-transition-fast) ease;
45
- clip-path: inset(0);
46
- }
47
-
48
- .docSidebarContainerHidden {
49
- width: var(--doc-sidebar-hidden-width);
50
- cursor: pointer;
51
- }
52
-
53
- .collapsedDocSidebar {
54
- position: sticky;
55
- top: 0;
56
- height: 100%;
57
- max-height: 100vh;
58
- display: flex;
59
- align-items: center;
60
- justify-content: center;
61
- transition: background-color var(--ifm-transition-fast) ease;
62
- }
63
-
64
- .collapsedDocSidebar:hover,
65
- .collapsedDocSidebar:focus {
66
- background-color: var(--ifm-color-emphasis-200);
67
- }
68
-
69
- .expandSidebarButtonIcon {
70
- transform: rotate(0);
71
- }
72
-
73
- [dir='rtl'] .expandSidebarButtonIcon {
74
- transform: rotate(180deg);
75
- }
76
-
77
- [data-theme='dark'] .collapsedDocSidebar:hover,
78
- [data-theme='dark'] .collapsedDocSidebar:focus {
79
- background-color: var(--collapse-button-bg-color-dark);
80
- }
81
-
82
- .docItemWrapperEnhanced {
83
- max-width: calc(
84
- var(--ifm-container-width) + var(--doc-sidebar-width)
85
- ) !important;
86
- }
87
- }
@@ -1,87 +0,0 @@
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
- :root {
9
- --doc-sidebar-width: 300px;
10
- --doc-sidebar-hidden-width: 30px;
11
- }
12
-
13
- .docPage,
14
- .docMainContainer {
15
- width: 100%;
16
- }
17
-
18
- .docsWrapper,
19
- .docPage,
20
- .docMainContainer {
21
- display: flex;
22
- }
23
-
24
- .docSidebarContainer {
25
- display: none;
26
- }
27
-
28
- @media (min-width: 997px) {
29
- .docMainContainer {
30
- flex-grow: 1;
31
- max-width: calc(100% - var(--doc-sidebar-width));
32
- }
33
-
34
- .docMainContainerEnhanced {
35
- max-width: calc(100% - var(--doc-sidebar-hidden-width));
36
- }
37
-
38
- .docSidebarContainer {
39
- display: block;
40
- width: var(--doc-sidebar-width);
41
- margin-top: calc(-1 * var(--ifm-navbar-height));
42
- border-right: 1px solid var(--ifm-toc-border-color);
43
- will-change: width;
44
- transition: width var(--ifm-transition-fast) ease;
45
- clip-path: inset(0);
46
- }
47
-
48
- .docSidebarContainerHidden {
49
- width: var(--doc-sidebar-hidden-width);
50
- cursor: pointer;
51
- }
52
-
53
- .collapsedDocSidebar {
54
- position: sticky;
55
- top: 0;
56
- height: 100%;
57
- max-height: 100vh;
58
- display: flex;
59
- align-items: center;
60
- justify-content: center;
61
- transition: background-color var(--ifm-transition-fast) ease;
62
- }
63
-
64
- .collapsedDocSidebar:hover,
65
- .collapsedDocSidebar:focus {
66
- background-color: var(--ifm-color-emphasis-200);
67
- }
68
-
69
- .expandSidebarButtonIcon {
70
- transform: rotate(0);
71
- }
72
-
73
- [dir='rtl'] .expandSidebarButtonIcon {
74
- transform: rotate(180deg);
75
- }
76
-
77
- [data-theme='dark'] .collapsedDocSidebar:hover,
78
- [data-theme='dark'] .collapsedDocSidebar:focus {
79
- background-color: var(--collapse-button-bg-color-dark);
80
- }
81
-
82
- .docItemWrapperEnhanced {
83
- max-width: calc(
84
- var(--ifm-container-width) + var(--doc-sidebar-width)
85
- ) !important;
86
- }
87
- }