@docusaurus/theme-classic 0.0.0-4735 → 0.0.0-4738

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 (65) hide show
  1. package/lib/theme-classic.d.ts +63 -33
  2. package/lib-next/theme/BlogArchivePage/index.js +13 -9
  3. package/lib-next/theme/BlogListPage/index.js +34 -13
  4. package/lib-next/theme/BlogPostPage/index.js +56 -45
  5. package/lib-next/theme/BlogTagsListPage/index.js +16 -12
  6. package/lib-next/theme/BlogTagsPostsPage/index.js +40 -33
  7. package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +27 -6
  8. package/lib-next/theme/DocItem/index.js +78 -63
  9. package/lib-next/theme/DocPage/index.js +85 -77
  10. package/lib-next/theme/DocPage/styles.module.css +0 -4
  11. package/lib-next/theme/DocSidebar/Mobile/index.js +24 -20
  12. package/lib-next/theme/DocTagDocListPage/index.js +38 -31
  13. package/lib-next/theme/DocTagsListPage/index.js +21 -16
  14. package/lib-next/theme/Layout/index.js +15 -10
  15. package/lib-next/theme/LayoutProviders/index.js +4 -6
  16. package/lib-next/theme/MDXPage/index.js +32 -26
  17. package/lib-next/theme/Navbar/ColorModeToggle/index.js +25 -0
  18. package/lib-next/theme/Navbar/Content/index.js +70 -0
  19. package/lib-next/theme/Navbar/Content/styles.module.css +15 -0
  20. package/lib-next/theme/Navbar/Layout/index.js +54 -0
  21. package/{src/theme/Navbar → lib-next/theme/Navbar/Layout}/styles.module.css +0 -13
  22. package/lib-next/theme/Navbar/Logo/index.js +17 -0
  23. package/lib-next/theme/Navbar/MobileSidebar/Header/index.js +33 -0
  24. package/lib-next/theme/Navbar/MobileSidebar/Layout/index.js +28 -0
  25. package/lib-next/theme/Navbar/MobileSidebar/PrimaryMenu/index.js +33 -0
  26. package/lib-next/theme/Navbar/MobileSidebar/SecondaryMenu/index.js +36 -0
  27. package/lib-next/theme/Navbar/MobileSidebar/Toggle/index.js +23 -0
  28. package/lib-next/theme/Navbar/MobileSidebar/index.js +31 -0
  29. package/lib-next/theme/Navbar/index.js +6 -273
  30. package/lib-next/theme/NotFound.js +38 -33
  31. package/lib-next/theme/{LayoutHead → SiteMetadata}/index.js +11 -26
  32. package/package.json +13 -13
  33. package/src/theme/BlogArchivePage/index.tsx +13 -9
  34. package/src/theme/BlogListPage/index.tsx +32 -13
  35. package/src/theme/BlogPostPage/index.tsx +55 -48
  36. package/src/theme/BlogTagsListPage/index.tsx +16 -12
  37. package/src/theme/BlogTagsPostsPage/index.tsx +39 -32
  38. package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +31 -4
  39. package/src/theme/DocItem/index.tsx +65 -52
  40. package/src/theme/DocPage/index.tsx +85 -77
  41. package/src/theme/DocPage/styles.module.css +0 -4
  42. package/src/theme/DocSidebar/Mobile/index.tsx +26 -23
  43. package/src/theme/DocTagDocListPage/index.tsx +38 -30
  44. package/src/theme/DocTagsListPage/index.tsx +21 -16
  45. package/src/theme/Layout/index.tsx +15 -10
  46. package/src/theme/LayoutProviders/index.tsx +4 -6
  47. package/src/theme/MDXPage/index.tsx +32 -26
  48. package/src/theme/Navbar/ColorModeToggle/index.tsx +30 -0
  49. package/src/theme/Navbar/Content/index.tsx +81 -0
  50. package/src/theme/Navbar/Content/styles.module.css +15 -0
  51. package/src/theme/Navbar/Layout/index.tsx +57 -0
  52. package/{lib-next/theme/Navbar → src/theme/Navbar/Layout}/styles.module.css +0 -13
  53. package/src/theme/Navbar/Logo/index.tsx +19 -0
  54. package/src/theme/Navbar/MobileSidebar/Header/index.tsx +34 -0
  55. package/src/theme/Navbar/MobileSidebar/Layout/index.tsx +31 -0
  56. package/src/theme/Navbar/MobileSidebar/PrimaryMenu/index.tsx +38 -0
  57. package/src/theme/Navbar/MobileSidebar/SecondaryMenu/index.tsx +38 -0
  58. package/src/theme/Navbar/MobileSidebar/Toggle/index.tsx +25 -0
  59. package/src/theme/Navbar/MobileSidebar/index.tsx +33 -0
  60. package/src/theme/Navbar/index.tsx +6 -292
  61. package/src/theme/NotFound.tsx +38 -33
  62. package/src/theme/{LayoutHead → SiteMetadata}/index.tsx +11 -25
  63. package/src/theme-classic.d.ts +63 -33
  64. package/lib-next/theme/Seo/index.js +0 -40
  65. package/src/theme/Seo/index.tsx +0 -49
@@ -9,40 +9,46 @@ import clsx from 'clsx';
9
9
  import Layout from '@theme/Layout';
10
10
  import MDXContent from '@theme/MDXContent';
11
11
  import TOC from '@theme/TOC';
12
- import {ThemeClassNames} from '@docusaurus/theme-common';
12
+ import {
13
+ PageMetadata,
14
+ HtmlClassNameProvider,
15
+ ThemeClassNames,
16
+ } from '@docusaurus/theme-common';
13
17
  import styles from './styles.module.css';
14
18
  export default function MDXPage(props) {
15
19
  const {content: MDXPageContent} = props;
16
20
  const {
17
- metadata: {title, description, permalink, frontMatter},
21
+ metadata: {title, description, frontMatter},
18
22
  } = MDXPageContent;
19
23
  const {wrapperClassName, hide_table_of_contents: hideTableOfContents} =
20
24
  frontMatter;
21
25
  return (
22
- <Layout
23
- title={title}
24
- description={description}
25
- permalink={permalink}
26
- wrapperClassName={wrapperClassName ?? ThemeClassNames.wrapper.mdxPages}
27
- pageClassName={ThemeClassNames.page.mdxPage}>
28
- <main className="container container--fluid margin-vert--lg">
29
- <div className={clsx('row', styles.mdxPageWrapper)}>
30
- <div className={clsx('col', !hideTableOfContents && 'col--8')}>
31
- <MDXContent>
32
- <MDXPageContent />
33
- </MDXContent>
34
- </div>
35
- {!hideTableOfContents && MDXPageContent.toc && (
36
- <div className="col col--2">
37
- <TOC
38
- toc={MDXPageContent.toc}
39
- minHeadingLevel={frontMatter.toc_min_heading_level}
40
- maxHeadingLevel={frontMatter.toc_max_heading_level}
41
- />
26
+ <HtmlClassNameProvider
27
+ className={clsx(
28
+ wrapperClassName ?? ThemeClassNames.wrapper.mdxPages,
29
+ ThemeClassNames.page.mdxPage,
30
+ )}>
31
+ <PageMetadata title={title} description={description} />
32
+ <Layout>
33
+ <main className="container container--fluid margin-vert--lg">
34
+ <div className={clsx('row', styles.mdxPageWrapper)}>
35
+ <div className={clsx('col', !hideTableOfContents && 'col--8')}>
36
+ <MDXContent>
37
+ <MDXPageContent />
38
+ </MDXContent>
42
39
  </div>
43
- )}
44
- </div>
45
- </main>
46
- </Layout>
40
+ {!hideTableOfContents && MDXPageContent.toc && (
41
+ <div className="col col--2">
42
+ <TOC
43
+ toc={MDXPageContent.toc}
44
+ minHeadingLevel={frontMatter.toc_min_heading_level}
45
+ maxHeadingLevel={frontMatter.toc_max_heading_level}
46
+ />
47
+ </div>
48
+ )}
49
+ </div>
50
+ </main>
51
+ </Layout>
52
+ </HtmlClassNameProvider>
47
53
  );
48
54
  }
@@ -0,0 +1,25 @@
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 {useColorMode, useThemeConfig} from '@docusaurus/theme-common';
8
+ import ColorModeToggle from '@theme/ColorModeToggle';
9
+ import React from 'react';
10
+ export default function NavbarColorModeToggle({className}) {
11
+ const disabled = useThemeConfig().colorMode.disableSwitch;
12
+ const {colorMode, setColorMode} = useColorMode();
13
+
14
+ if (disabled) {
15
+ return null;
16
+ }
17
+
18
+ return (
19
+ <ColorModeToggle
20
+ className={className}
21
+ value={colorMode}
22
+ onChange={setColorMode}
23
+ />
24
+ );
25
+ }
@@ -0,0 +1,70 @@
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 NavbarItem from '@theme/NavbarItem';
9
+ import NavbarColorModeToggle from '@theme/Navbar/ColorModeToggle';
10
+ import SearchBar from '@theme/SearchBar';
11
+ import {
12
+ splitNavbarItems,
13
+ useNavbarMobileSidebar,
14
+ useThemeConfig,
15
+ } from '@docusaurus/theme-common';
16
+ import NavbarMobileSidebarToggle from '@theme/Navbar/MobileSidebar/Toggle';
17
+ import NavbarLogo from '@theme/Navbar/Logo';
18
+ import styles from './styles.module.css';
19
+
20
+ function useNavbarItems() {
21
+ // TODO temporary casting until ThemeConfig type is improved
22
+ return useThemeConfig().navbar.items;
23
+ }
24
+
25
+ function NavbarItems({items}) {
26
+ return (
27
+ <>
28
+ {items.map((item, i) => (
29
+ <NavbarItem {...item} key={i} />
30
+ ))}
31
+ </>
32
+ );
33
+ }
34
+
35
+ function NavbarContentLayout({left, right}) {
36
+ return (
37
+ <div className="navbar__inner">
38
+ <div className="navbar__items">{left}</div>
39
+ <div className="navbar__items navbar__items--right">{right}</div>
40
+ </div>
41
+ );
42
+ }
43
+
44
+ export default function NavbarContent() {
45
+ const mobileSidebar = useNavbarMobileSidebar();
46
+ const items = useNavbarItems();
47
+ const [leftItems, rightItems] = splitNavbarItems(items);
48
+ const autoAddSearchBar = !items.some((item) => item.type === 'search');
49
+ return (
50
+ <NavbarContentLayout
51
+ left={
52
+ // TODO stop hardcoding items?
53
+ <>
54
+ {!mobileSidebar.disabled && <NavbarMobileSidebarToggle />}
55
+ <NavbarLogo />
56
+ <NavbarItems items={leftItems} />
57
+ </>
58
+ }
59
+ right={
60
+ // TODO stop hardcoding items?
61
+ // Ask the user to add the respective navbar items => more flexible
62
+ <>
63
+ <NavbarItems items={rightItems} />
64
+ <NavbarColorModeToggle className={styles.colorModeToggle} />
65
+ {autoAddSearchBar && <SearchBar />}
66
+ </>
67
+ }
68
+ />
69
+ );
70
+ }
@@ -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
+ /*
9
+ Hide color mode toggle in small viewports
10
+ */
11
+ @media (max-width: 996px) {
12
+ .colorModeToggle {
13
+ display: none;
14
+ }
15
+ }
@@ -0,0 +1,54 @@
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 NavbarMobileSidebar from '@theme/Navbar/MobileSidebar';
10
+ import {
11
+ useThemeConfig,
12
+ useHideableNavbar,
13
+ useNavbarMobileSidebar,
14
+ } from '@docusaurus/theme-common';
15
+ import styles from './styles.module.css';
16
+
17
+ function NavbarBackdrop(props) {
18
+ return (
19
+ <div
20
+ role="presentation"
21
+ {...props}
22
+ className={clsx('navbar-sidebar__backdrop', props.className)}
23
+ />
24
+ );
25
+ }
26
+
27
+ export default function NavbarLayout({children}) {
28
+ const {
29
+ navbar: {hideOnScroll, style},
30
+ } = useThemeConfig();
31
+ const mobileSidebar = useNavbarMobileSidebar();
32
+ const {navbarRef, isNavbarVisible} = useHideableNavbar(hideOnScroll);
33
+ return (
34
+ <nav
35
+ ref={navbarRef}
36
+ className={clsx(
37
+ 'navbar',
38
+ 'navbar--fixed-top',
39
+ hideOnScroll && [
40
+ styles.navbarHideable,
41
+ !isNavbarVisible && styles.navbarHidden,
42
+ ],
43
+ {
44
+ 'navbar--dark': style === 'dark',
45
+ 'navbar--primary': style === 'primary',
46
+ 'navbar-sidebar--show': mobileSidebar.shown,
47
+ },
48
+ )}>
49
+ {children}
50
+ <NavbarBackdrop onClick={mobileSidebar.toggle} />
51
+ <NavbarMobileSidebar />
52
+ </nav>
53
+ );
54
+ }
@@ -5,15 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- /*
9
- Hide toggle in small viewports
10
- */
11
- @media (max-width: 996px) {
12
- .toggle {
13
- display: none;
14
- }
15
- }
16
-
17
8
  .navbarHideable {
18
9
  transition: transform var(--ifm-transition-fast) ease;
19
10
  }
@@ -21,7 +12,3 @@ Hide toggle in small viewports
21
12
  .navbarHidden {
22
13
  transform: translate3d(0, calc(-100% - 2px), 0);
23
14
  }
24
-
25
- .navbarSidebarToggle {
26
- margin-right: 1rem;
27
- }
@@ -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
+ import React from 'react';
8
+ import Logo from '@theme/Logo';
9
+ export default function NavbarLogo() {
10
+ return (
11
+ <Logo
12
+ className="navbar__brand"
13
+ imageClassName="navbar__logo"
14
+ titleClassName="navbar__title"
15
+ />
16
+ );
17
+ }
@@ -0,0 +1,33 @@
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 NavbarColorModeToggle from '@theme/Navbar/ColorModeToggle';
9
+ import IconClose from '@theme/IconClose';
10
+ import NavbarLogo from '@theme/Navbar/Logo';
11
+ import {useNavbarMobileSidebar} from '@docusaurus/theme-common';
12
+
13
+ function CloseButton() {
14
+ const mobileSidebar = useNavbarMobileSidebar();
15
+ return (
16
+ <button
17
+ type="button"
18
+ className="clean-btn navbar-sidebar__close"
19
+ onClick={() => mobileSidebar.toggle()}>
20
+ <IconClose color="var(--ifm-color-emphasis-600)" />
21
+ </button>
22
+ );
23
+ }
24
+
25
+ export default function NavbarMobileSidebarHeader() {
26
+ return (
27
+ <div className="navbar-sidebar__brand">
28
+ <NavbarLogo />
29
+ <NavbarColorModeToggle className="margin-right--md" />
30
+ <CloseButton />
31
+ </div>
32
+ );
33
+ }
@@ -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
+ import React from 'react';
8
+ import clsx from 'clsx';
9
+ import {useNavbarSecondaryMenu} from '@docusaurus/theme-common';
10
+ export default function NavbarMobileSidebarLayout({
11
+ header,
12
+ primaryMenu,
13
+ secondaryMenu,
14
+ }) {
15
+ const {shown: secondaryMenuShown} = useNavbarSecondaryMenu();
16
+ return (
17
+ <div className="navbar-sidebar">
18
+ {header}
19
+ <div
20
+ className={clsx('navbar-sidebar__items', {
21
+ 'navbar-sidebar__items--show-secondary': secondaryMenuShown,
22
+ })}>
23
+ <div className="navbar-sidebar__item menu">{primaryMenu}</div>
24
+ <div className="navbar-sidebar__item menu">{secondaryMenu}</div>
25
+ </div>
26
+ </div>
27
+ );
28
+ }
@@ -0,0 +1,33 @@
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 {useNavbarMobileSidebar, useThemeConfig} from '@docusaurus/theme-common';
9
+ import NavbarItem from '../../../NavbarItem';
10
+
11
+ function useNavbarItems() {
12
+ // TODO temporary casting until ThemeConfig type is improved
13
+ return useThemeConfig().navbar.items;
14
+ } // The primary menu displays the navbar items
15
+
16
+ export default function NavbarMobilePrimaryMenu() {
17
+ const mobileSidebar = useNavbarMobileSidebar(); // TODO how can the order be defined for mobile?
18
+ // Should we allow providing a different list of items?
19
+
20
+ const items = useNavbarItems();
21
+ return (
22
+ <ul className="menu__list">
23
+ {items.map((item, i) => (
24
+ <NavbarItem
25
+ mobile
26
+ {...item}
27
+ onClick={() => mobileSidebar.toggle()}
28
+ key={i}
29
+ />
30
+ ))}
31
+ </ul>
32
+ );
33
+ }
@@ -0,0 +1,36 @@
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 {useNavbarSecondaryMenu, useThemeConfig} from '@docusaurus/theme-common';
9
+ import Translate from '@docusaurus/Translate';
10
+
11
+ function SecondaryMenuBackButton(props) {
12
+ return (
13
+ <button {...props} type="button" className="clean-btn navbar-sidebar__back">
14
+ <Translate
15
+ id="theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel"
16
+ description="The label of the back button to return to main menu, inside the mobile navbar sidebar secondary menu (notably used to display the docs sidebar)">
17
+ ← Back to main menu
18
+ </Translate>
19
+ </button>
20
+ );
21
+ } // The secondary menu slides from the right and shows contextual information
22
+ // such as the docs sidebar
23
+
24
+ export default function NavbarMobileSidebarSecondaryMenu() {
25
+ const isPrimaryMenuEmpty = useThemeConfig().navbar.items.length === 0;
26
+ const secondaryMenu = useNavbarSecondaryMenu();
27
+ return (
28
+ <>
29
+ {/* edge-case: prevent returning to the primaryMenu when it's empty */}
30
+ {!isPrimaryMenuEmpty && (
31
+ <SecondaryMenuBackButton onClick={() => secondaryMenu.hide()} />
32
+ )}
33
+ {secondaryMenu.content}
34
+ </>
35
+ );
36
+ }
@@ -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 IconMenu from '@theme/IconMenu';
9
+ import {useNavbarMobileSidebar} from '@docusaurus/theme-common';
10
+ export default function MobileSidebarToggle() {
11
+ const mobileSidebar = useNavbarMobileSidebar();
12
+ return (
13
+ <button
14
+ onClick={mobileSidebar.toggle}
15
+ onKeyDown={mobileSidebar.toggle}
16
+ aria-label="Navigation bar toggle"
17
+ className="navbar__toggle clean-btn"
18
+ type="button"
19
+ tabIndex={0}>
20
+ <IconMenu />
21
+ </button>
22
+ );
23
+ }
@@ -0,0 +1,31 @@
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 NavbarMobileSidebarLayout from '@theme/Navbar/MobileSidebar/Layout';
9
+ import NavbarMobileSidebarHeader from '@theme/Navbar/MobileSidebar/Header';
10
+ import {
11
+ useLockBodyScroll,
12
+ useNavbarMobileSidebar,
13
+ } from '@docusaurus/theme-common';
14
+ import NavbarMobileSidebarPrimaryMenu from '@theme/Navbar/MobileSidebar/PrimaryMenu';
15
+ import NavbarMobileSidebarSecondaryMenu from '@theme/Navbar/MobileSidebar/SecondaryMenu';
16
+ export default function NavbarMobileSidebar() {
17
+ const mobileSidebar = useNavbarMobileSidebar();
18
+ useLockBodyScroll(mobileSidebar.shown);
19
+
20
+ if (!mobileSidebar.shouldRender) {
21
+ return null;
22
+ }
23
+
24
+ return (
25
+ <NavbarMobileSidebarLayout
26
+ header={<NavbarMobileSidebarHeader />}
27
+ primaryMenu={<NavbarMobileSidebarPrimaryMenu />}
28
+ secondaryMenu={<NavbarMobileSidebarSecondaryMenu />}
29
+ />
30
+ );
31
+ }