@docusaurus/theme-classic 0.0.0-4705 → 0.0.0-4709

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 (45) hide show
  1. package/lib/getSwizzleConfig.js +50 -2
  2. package/lib/theme-classic.d.ts +107 -0
  3. package/lib-next/theme/DocSidebar/Desktop/CollapseButton/index.js +34 -0
  4. package/lib-next/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +44 -0
  5. package/lib-next/theme/DocSidebar/Desktop/Content/index.js +46 -0
  6. package/lib-next/theme/DocSidebar/Desktop/Content/styles.module.css +17 -0
  7. package/lib-next/theme/DocSidebar/Desktop/index.js +34 -0
  8. package/lib-next/theme/DocSidebar/Desktop/styles.module.css +50 -0
  9. package/lib-next/theme/DocSidebar/Mobile/index.js +45 -0
  10. package/lib-next/theme/DocSidebar/index.js +6 -113
  11. package/lib-next/theme/Footer/Copyright/index.js +18 -0
  12. package/lib-next/theme/Footer/Layout/index.js +26 -0
  13. package/lib-next/theme/Footer/LinkItem/index.js +35 -0
  14. package/lib-next/theme/Footer/Links/MultiColumn/index.js +47 -0
  15. package/lib-next/theme/Footer/Links/Simple/index.js +41 -0
  16. package/lib-next/theme/Footer/Links/index.js +17 -0
  17. package/lib-next/theme/Footer/Logo/index.js +38 -0
  18. package/lib-next/theme/Footer/{styles.module.css → Logo/styles.module.css} +0 -0
  19. package/lib-next/theme/Footer/index.js +11 -156
  20. package/lib-next/theme/MDXComponents/index.js +1 -1
  21. package/lib-next/theme/Tabs/index.js +2 -2
  22. package/package.json +13 -13
  23. package/src/getSwizzleConfig.ts +52 -1
  24. package/src/theme/DocSidebar/Desktop/CollapseButton/index.tsx +38 -0
  25. package/src/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +44 -0
  26. package/src/theme/DocSidebar/Desktop/Content/index.tsx +55 -0
  27. package/src/theme/DocSidebar/Desktop/Content/styles.module.css +17 -0
  28. package/src/theme/DocSidebar/Desktop/index.tsx +38 -0
  29. package/src/theme/DocSidebar/Desktop/styles.module.css +50 -0
  30. package/src/theme/DocSidebar/Mobile/index.tsx +51 -0
  31. package/src/theme/DocSidebar/index.tsx +6 -121
  32. package/src/theme/Footer/Copyright/index.tsx +22 -0
  33. package/src/theme/Footer/Layout/index.tsx +34 -0
  34. package/src/theme/Footer/LinkItem/index.tsx +38 -0
  35. package/src/theme/Footer/Links/MultiColumn/index.tsx +53 -0
  36. package/src/theme/Footer/Links/Simple/index.tsx +44 -0
  37. package/src/theme/Footer/Links/index.tsx +21 -0
  38. package/src/theme/Footer/Logo/index.tsx +41 -0
  39. package/src/theme/Footer/{styles.module.css → Logo/styles.module.css} +0 -0
  40. package/src/theme/Footer/index.tsx +12 -170
  41. package/src/theme/MDXComponents/index.tsx +2 -2
  42. package/src/theme/Tabs/index.tsx +1 -2
  43. package/src/theme-classic.d.ts +107 -0
  44. package/lib-next/theme/DocSidebar/styles.module.css +0 -107
  45. package/src/theme/DocSidebar/styles.module.css +0 -107
@@ -0,0 +1,50 @@
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
+ .sidebar {
10
+ display: flex;
11
+ flex-direction: column;
12
+ max-height: 100vh;
13
+ height: 100%;
14
+ position: sticky;
15
+ top: 0;
16
+ padding-top: var(--ifm-navbar-height);
17
+ width: var(--doc-sidebar-width);
18
+ transition: opacity 50ms ease;
19
+ }
20
+
21
+ .sidebarWithHideableNavbar {
22
+ padding-top: 0;
23
+ }
24
+
25
+ .sidebarHidden {
26
+ opacity: 0;
27
+ height: 0;
28
+ overflow: hidden;
29
+ visibility: hidden;
30
+ }
31
+
32
+ .sidebarLogo {
33
+ display: flex !important;
34
+ align-items: center;
35
+ margin: 0 var(--ifm-navbar-padding-horizontal);
36
+ min-height: var(--ifm-navbar-height);
37
+ max-height: var(--ifm-navbar-height);
38
+ color: inherit !important;
39
+ text-decoration: none !important;
40
+ }
41
+
42
+ .sidebarLogo img {
43
+ margin-right: 0.5rem;
44
+ height: 2rem;
45
+ }
46
+ }
47
+
48
+ .sidebarLogo {
49
+ display: none;
50
+ }
@@ -0,0 +1,51 @@
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 clsx from 'clsx';
10
+ import {
11
+ MobileSecondaryMenuFiller,
12
+ type MobileSecondaryMenuComponent,
13
+ ThemeClassNames,
14
+ } from '@docusaurus/theme-common';
15
+ import DocSidebarItems from '@theme/DocSidebarItems';
16
+ import type {Props} from '@theme/DocSidebar/Mobile';
17
+
18
+ // eslint-disable-next-line react/function-component-definition
19
+ const DocSidebarMobileSecondaryMenu: MobileSecondaryMenuComponent<Props> = ({
20
+ toggleSidebar,
21
+ sidebar,
22
+ path,
23
+ }) => (
24
+ <ul className={clsx(ThemeClassNames.docs.docSidebarMenu, 'menu__list')}>
25
+ <DocSidebarItems
26
+ items={sidebar}
27
+ activePath={path}
28
+ onItemClick={(item) => {
29
+ // Mobile sidebar should only be closed if the category has a link
30
+ if (item.type === 'category' && item.href) {
31
+ toggleSidebar();
32
+ }
33
+ if (item.type === 'link') {
34
+ toggleSidebar();
35
+ }
36
+ }}
37
+ level={1}
38
+ />
39
+ </ul>
40
+ );
41
+
42
+ function DocSidebarMobile(props: Props) {
43
+ return (
44
+ <MobileSecondaryMenuFiller
45
+ component={DocSidebarMobileSecondaryMenu}
46
+ props={props}
47
+ />
48
+ );
49
+ }
50
+
51
+ export default React.memo(DocSidebarMobile);
@@ -5,126 +5,11 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React, {useState} from 'react';
9
- import clsx from 'clsx';
10
- import {
11
- useThemeConfig,
12
- useAnnouncementBar,
13
- MobileSecondaryMenuFiller,
14
- type MobileSecondaryMenuComponent,
15
- ThemeClassNames,
16
- useScrollPosition,
17
- useWindowSize,
18
- } from '@docusaurus/theme-common';
19
- import Logo from '@theme/Logo';
20
- import IconArrow from '@theme/IconArrow';
21
- import {translate} from '@docusaurus/Translate';
22
- import DocSidebarItems from '@theme/DocSidebarItems';
8
+ import React from 'react';
9
+ import {useWindowSize} from '@docusaurus/theme-common';
23
10
  import type {Props} from '@theme/DocSidebar';
24
-
25
- import styles from './styles.module.css';
26
-
27
- function useShowAnnouncementBar() {
28
- const {isActive} = useAnnouncementBar();
29
- const [showAnnouncementBar, setShowAnnouncementBar] = useState(isActive);
30
-
31
- useScrollPosition(
32
- ({scrollY}) => {
33
- if (isActive) {
34
- setShowAnnouncementBar(scrollY === 0);
35
- }
36
- },
37
- [isActive],
38
- );
39
- return isActive && showAnnouncementBar;
40
- }
41
-
42
- function HideableSidebarButton({onClick}: {onClick: React.MouseEventHandler}) {
43
- return (
44
- <button
45
- type="button"
46
- title={translate({
47
- id: 'theme.docs.sidebar.collapseButtonTitle',
48
- message: 'Collapse sidebar',
49
- description: 'The title attribute for collapse button of doc sidebar',
50
- })}
51
- aria-label={translate({
52
- id: 'theme.docs.sidebar.collapseButtonAriaLabel',
53
- message: 'Collapse sidebar',
54
- description: 'The title attribute for collapse button of doc sidebar',
55
- })}
56
- className={clsx(
57
- 'button button--secondary button--outline',
58
- styles.collapseSidebarButton,
59
- )}
60
- onClick={onClick}>
61
- <IconArrow className={styles.collapseSidebarButtonIcon} />
62
- </button>
63
- );
64
- }
65
-
66
- function DocSidebarDesktop({path, sidebar, onCollapse, isHidden}: Props) {
67
- const showAnnouncementBar = useShowAnnouncementBar();
68
- const {
69
- navbar: {hideOnScroll},
70
- hideableSidebar,
71
- } = useThemeConfig();
72
-
73
- return (
74
- <div
75
- className={clsx(styles.sidebar, {
76
- [styles.sidebarWithHideableNavbar!]: hideOnScroll,
77
- [styles.sidebarHidden!]: isHidden,
78
- })}>
79
- {hideOnScroll && <Logo tabIndex={-1} className={styles.sidebarLogo} />}
80
- <nav
81
- className={clsx('menu thin-scrollbar', styles.menu, {
82
- [styles.menuWithAnnouncementBar!]: showAnnouncementBar,
83
- })}>
84
- <ul className={clsx(ThemeClassNames.docs.docSidebarMenu, 'menu__list')}>
85
- <DocSidebarItems items={sidebar} activePath={path} level={1} />
86
- </ul>
87
- </nav>
88
- {hideableSidebar && <HideableSidebarButton onClick={onCollapse} />}
89
- </div>
90
- );
91
- }
92
-
93
- // eslint-disable-next-line react/function-component-definition
94
- const DocSidebarMobileSecondaryMenu: MobileSecondaryMenuComponent<Props> = ({
95
- toggleSidebar,
96
- sidebar,
97
- path,
98
- }) => (
99
- <ul className={clsx(ThemeClassNames.docs.docSidebarMenu, 'menu__list')}>
100
- <DocSidebarItems
101
- items={sidebar}
102
- activePath={path}
103
- onItemClick={(item) => {
104
- // Mobile sidebar should only be closed if the category has a link
105
- if (item.type === 'category' && item.href) {
106
- toggleSidebar();
107
- }
108
- if (item.type === 'link') {
109
- toggleSidebar();
110
- }
111
- }}
112
- level={1}
113
- />
114
- </ul>
115
- );
116
-
117
- function DocSidebarMobile(props: Props) {
118
- return (
119
- <MobileSecondaryMenuFiller
120
- component={DocSidebarMobileSecondaryMenu}
121
- props={props}
122
- />
123
- );
124
- }
125
-
126
- const DocSidebarDesktopMemo = React.memo(DocSidebarDesktop);
127
- const DocSidebarMobileMemo = React.memo(DocSidebarMobile);
11
+ import DocSidebarDesktop from '@theme/DocSidebar/Desktop';
12
+ import DocSidebarMobile from '@theme/DocSidebar/Mobile';
128
13
 
129
14
  export default function DocSidebar(props: Props): JSX.Element {
130
15
  const windowSize = useWindowSize();
@@ -138,8 +23,8 @@ export default function DocSidebar(props: Props): JSX.Element {
138
23
 
139
24
  return (
140
25
  <>
141
- {shouldRenderSidebarDesktop && <DocSidebarDesktopMemo {...props} />}
142
- {shouldRenderSidebarMobile && <DocSidebarMobileMemo {...props} />}
26
+ {shouldRenderSidebarDesktop && <DocSidebarDesktop {...props} />}
27
+ {shouldRenderSidebarMobile && <DocSidebarMobile {...props} />}
143
28
  </>
144
29
  );
145
30
  }
@@ -0,0 +1,22 @@
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 type {Props} from '@theme/Footer/Copyright';
10
+
11
+ export default function FooterCopyright({copyright}: Props): JSX.Element {
12
+ return (
13
+ <div
14
+ className="footer__copyright"
15
+ // Developer provided the HTML, so assume it's safe.
16
+ // eslint-disable-next-line react/no-danger
17
+ dangerouslySetInnerHTML={{
18
+ __html: copyright,
19
+ }}
20
+ />
21
+ );
22
+ }
@@ -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
+
8
+ import React from 'react';
9
+ import clsx from 'clsx';
10
+ import type {Props} from '@theme/Footer/Layout';
11
+
12
+ export default function FooterLayout({
13
+ style,
14
+ links,
15
+ logo,
16
+ copyright,
17
+ }: Props): JSX.Element {
18
+ return (
19
+ <footer
20
+ className={clsx('footer', {
21
+ 'footer--dark': style === 'dark',
22
+ })}>
23
+ <div className="container container-fluid">
24
+ {links}
25
+ {(logo || copyright) && (
26
+ <div className="footer__bottom text--center">
27
+ {logo && <div className="margin-bottom--sm">{logo}</div>}
28
+ {copyright}
29
+ </div>
30
+ )}
31
+ </div>
32
+ </footer>
33
+ );
34
+ }
@@ -0,0 +1,38 @@
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
+
10
+ import Link from '@docusaurus/Link';
11
+ import useBaseUrl from '@docusaurus/useBaseUrl';
12
+ import isInternalUrl from '@docusaurus/isInternalUrl';
13
+ import IconExternalLink from '@theme/IconExternalLink';
14
+ import type {Props} from '@theme/Footer/LinkItem';
15
+
16
+ export default function FooterLinkItem({item}: Props): JSX.Element {
17
+ const {to, href, label, prependBaseUrlToHref, ...props} = item;
18
+ const toUrl = useBaseUrl(to);
19
+ const normalizedHref = useBaseUrl(href, {forcePrependBaseUrl: true});
20
+
21
+ return (
22
+ <Link
23
+ className="footer__link-item"
24
+ {...(href
25
+ ? {
26
+ href: prependBaseUrlToHref ? normalizedHref : href,
27
+ }
28
+ : {
29
+ to: toUrl,
30
+ })}
31
+ {...props}>
32
+ <span>
33
+ {label}
34
+ {href && !isInternalUrl(href) && <IconExternalLink />}
35
+ </span>
36
+ </Link>
37
+ );
38
+ }
@@ -0,0 +1,53 @@
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 type {Props} from '@theme/Footer/Links/MultiColumn';
10
+ import LinkItem from '@theme/Footer/LinkItem';
11
+
12
+ type ColumnType = Props['columns'][number];
13
+ type ColumnItemType = ColumnType['items'][number];
14
+
15
+ function ColumnLinkItem({item}: {item: ColumnItemType}) {
16
+ return item.html ? (
17
+ <li
18
+ className="footer__item"
19
+ // Developer provided the HTML, so assume it's safe.
20
+ // eslint-disable-next-line react/no-danger
21
+ dangerouslySetInnerHTML={{
22
+ __html: item.html,
23
+ }}
24
+ />
25
+ ) : (
26
+ <li key={item.href || item.to} className="footer__item">
27
+ <LinkItem item={item} />
28
+ </li>
29
+ );
30
+ }
31
+
32
+ function Column({column}: {column: ColumnType}) {
33
+ return (
34
+ <div className="col footer__col">
35
+ <div className="footer__title">{column.title}</div>
36
+ <ul className="footer__items">
37
+ {column.items.map((item, i) => (
38
+ <ColumnLinkItem key={i} item={item} />
39
+ ))}
40
+ </ul>
41
+ </div>
42
+ );
43
+ }
44
+
45
+ export default function FooterLinksMultiColumn({columns}: Props): JSX.Element {
46
+ return (
47
+ <div className="row footer__links">
48
+ {columns.map((column, i) => (
49
+ <Column key={i} column={column} />
50
+ ))}
51
+ </div>
52
+ );
53
+ }
@@ -0,0 +1,44 @@
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 type {Props} from '@theme/Footer/Links/Simple';
10
+ import LinkItem from '@theme/Footer/LinkItem';
11
+
12
+ function Separator() {
13
+ return <span className="footer__link-separator">·</span>;
14
+ }
15
+
16
+ function SimpleLinkItem({item}: {item: Props['links'][number]}) {
17
+ return item.html ? (
18
+ <span
19
+ className="footer__link-item"
20
+ // Developer provided the HTML, so assume it's safe.
21
+ // eslint-disable-next-line react/no-danger
22
+ dangerouslySetInnerHTML={{
23
+ __html: item.html,
24
+ }}
25
+ />
26
+ ) : (
27
+ <LinkItem item={item} />
28
+ );
29
+ }
30
+
31
+ export default function FooterLinksSimple({links}: Props): JSX.Element {
32
+ return (
33
+ <div className="footer__links text--center">
34
+ <div className="footer__links">
35
+ {links.map((item, i) => (
36
+ <React.Fragment key={i}>
37
+ <SimpleLinkItem item={item} />
38
+ {links.length !== i + 1 && <Separator />}
39
+ </React.Fragment>
40
+ ))}
41
+ </div>
42
+ </div>
43
+ );
44
+ }
@@ -0,0 +1,21 @@
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
+
10
+ import {isMultiColumnFooterLinks} from '@docusaurus/theme-common';
11
+ import type {Props} from '@theme/Footer/Links';
12
+ import FooterLinksMultiColumn from '@theme/Footer/Links/MultiColumn';
13
+ import FooterLinksSimple from '@theme/Footer/Links/Simple';
14
+
15
+ export default function FooterLinks({links}: Props): JSX.Element {
16
+ return isMultiColumnFooterLinks(links) ? (
17
+ <FooterLinksMultiColumn columns={links} />
18
+ ) : (
19
+ <FooterLinksSimple links={links} />
20
+ );
21
+ }
@@ -0,0 +1,41 @@
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
+
10
+ import Link from '@docusaurus/Link';
11
+ import {useBaseUrlUtils} from '@docusaurus/useBaseUrl';
12
+ import styles from './styles.module.css';
13
+ import ThemedImage from '@theme/ThemedImage';
14
+ import type {Props} from '@theme/Footer/Logo';
15
+
16
+ function LogoImage({logo}: Props) {
17
+ const {withBaseUrl} = useBaseUrlUtils();
18
+ const sources = {
19
+ light: withBaseUrl(logo.src),
20
+ dark: withBaseUrl(logo.srcDark ?? logo.src),
21
+ };
22
+ return (
23
+ <ThemedImage
24
+ className="footer__logo"
25
+ alt={logo.alt}
26
+ sources={sources}
27
+ width={logo.width}
28
+ height={logo.height}
29
+ />
30
+ );
31
+ }
32
+
33
+ export default function FooterLogo({logo}: Props): JSX.Element {
34
+ return logo.href ? (
35
+ <Link href={logo.href} className={styles.footerLogoLink}>
36
+ <LogoImage logo={logo} />
37
+ </Link>
38
+ ) : (
39
+ <LogoImage logo={logo} />
40
+ );
41
+ }