@docusaurus/theme-classic 0.0.0-4591 → 0.0.0-4595

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.
@@ -0,0 +1,71 @@
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 {ThemeClassNames, useSidebarBreadcrumbs} from '@docusaurus/theme-common';
9
+ import styles from './styles.module.css';
10
+ import clsx from 'clsx';
11
+ import Link from '@docusaurus/Link';
12
+ import useBaseUrl from '@docusaurus/useBaseUrl'; // TODO move to design system folder
13
+
14
+ function BreadcrumbsItemLink({children, href}) {
15
+ const className = clsx('breadcrumbs__link', styles.breadcrumbsItemLink);
16
+ return href ? (
17
+ <Link className={className} href={href}>
18
+ {children}
19
+ </Link>
20
+ ) : (
21
+ <span className={className}>{children}</span>
22
+ );
23
+ } // TODO move to design system folder
24
+
25
+ function BreadcrumbsItem({children, active}) {
26
+ return (
27
+ <li
28
+ className={clsx('breadcrumbs__item', {
29
+ 'breadcrumbs__item--active': active,
30
+ })}>
31
+ {children}
32
+ </li>
33
+ );
34
+ }
35
+
36
+ function HomeBreadcrumbItem() {
37
+ const homeHref = useBaseUrl('/');
38
+ return (
39
+ <BreadcrumbsItem>
40
+ <BreadcrumbsItemLink href={homeHref}>🏠</BreadcrumbsItemLink>
41
+ </BreadcrumbsItem>
42
+ );
43
+ }
44
+
45
+ export default function DocBreadcrumbs() {
46
+ const breadcrumbs = useSidebarBreadcrumbs();
47
+
48
+ if (!breadcrumbs) {
49
+ return null;
50
+ }
51
+
52
+ return (
53
+ <nav
54
+ className={clsx(
55
+ ThemeClassNames.docs.docBreadcrumbs,
56
+ styles.breadcrumbsContainer,
57
+ )}
58
+ aria-label="breadcrumbs">
59
+ <ul className="breadcrumbs">
60
+ <HomeBreadcrumbItem />
61
+ {breadcrumbs.map((item, idx) => (
62
+ <BreadcrumbsItem key={idx} active={idx === breadcrumbs.length - 1}>
63
+ <BreadcrumbsItemLink href={item.href}>
64
+ {item.label}
65
+ </BreadcrumbsItemLink>
66
+ </BreadcrumbsItem>
67
+ ))}
68
+ </ul>
69
+ </nav>
70
+ );
71
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ .breadcrumbsContainer {
9
+ margin-bottom: 0.4rem;
10
+ }
11
+
12
+ .breadcrumbsItemLink {
13
+ --ifm-breadcrumb-size-multiplier: 0.7 !important;
14
+ margin-bottom: 0.4rem;
15
+ background: var(--ifm-color-gray-100);
16
+ }
17
+
18
+ html[data-theme='dark'] .breadcrumbsItemLink {
19
+ background-color: var(--ifm-color-gray-900);
20
+ }
21
+
22
+ @media (min-width: 997px) {
23
+ .breadcrumbsItemLink {
24
+ --ifm-breadcrumb-size-multiplier: 0.8;
25
+ }
26
+ }
@@ -11,6 +11,7 @@ import DocPaginator from '@theme/DocPaginator';
11
11
  import Seo from '@theme/Seo';
12
12
  import DocVersionBanner from '@theme/DocVersionBanner';
13
13
  import DocVersionBadge from '@theme/DocVersionBadge';
14
+ import DocBreadcrumbs from '@theme/DocBreadcrumbs';
14
15
  import Heading from '@theme/Heading';
15
16
  import useBaseUrl from '@docusaurus/useBaseUrl';
16
17
  import styles from './styles.module.css';
@@ -28,6 +29,7 @@ export default function DocCategoryGeneratedIndexPage({
28
29
  />
29
30
  <div className={styles.generatedIndexPage}>
30
31
  <DocVersionBanner />
32
+ <DocBreadcrumbs />
31
33
  <DocVersionBadge />
32
34
  <header>
33
35
  <Heading as="h1" className={styles.title}>
@@ -16,6 +16,7 @@ import TOCCollapsible from '@theme/TOCCollapsible';
16
16
  import Heading from '@theme/Heading';
17
17
  import styles from './styles.module.css';
18
18
  import {ThemeClassNames, useWindowSize} from '@docusaurus/theme-common';
19
+ import DocBreadcrumbs from '@theme/DocBreadcrumbs';
19
20
  export default function DocItem(props) {
20
21
  const {content: DocContent} = props;
21
22
  const {metadata, frontMatter} = DocContent;
@@ -57,6 +58,7 @@ export default function DocItem(props) {
57
58
  <DocVersionBanner />
58
59
  <div className={styles.docItemContainer}>
59
60
  <article>
61
+ <DocBreadcrumbs />
60
62
  <DocVersionBadge />
61
63
 
62
64
  {canRenderTOC && (
@@ -48,11 +48,26 @@ const ToggleComponent = memo(
48
48
  checked={checked}
49
49
  type="checkbox"
50
50
  className={styles.toggleScreenReader}
51
- aria-label={translate({
52
- message: 'Switch between dark and light mode',
53
- id: 'theme.colorToggle.ariaLabel',
54
- description: 'The ARIA label for the navbar color mode toggle',
55
- })}
51
+ aria-label={translate(
52
+ {
53
+ message: 'Switch between dark and light mode (currently {mode})',
54
+ id: 'theme.colorToggle.ariaLabel',
55
+ description: 'The ARIA label for the navbar color mode toggle',
56
+ },
57
+ {
58
+ mode: checked
59
+ ? translate({
60
+ message: 'dark mode',
61
+ id: 'theme.colorToggle.ariaLabel.mode.dark',
62
+ description: 'The name for the dark color mode',
63
+ })
64
+ : translate({
65
+ message: 'light mode',
66
+ id: 'theme.colorToggle.ariaLabel.mode.light',
67
+ description: 'The name for the light color mode',
68
+ }),
69
+ },
70
+ )}
56
71
  onChange={onChange}
57
72
  onClick={() => setChecked(!checked)}
58
73
  onFocus={() => setFocused(true)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-4591",
3
+ "version": "0.0.0-4595",
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-4591",
25
- "@docusaurus/plugin-content-blog": "0.0.0-4591",
26
- "@docusaurus/plugin-content-docs": "0.0.0-4591",
27
- "@docusaurus/plugin-content-pages": "0.0.0-4591",
28
- "@docusaurus/theme-common": "0.0.0-4591",
29
- "@docusaurus/theme-translations": "0.0.0-4591",
30
- "@docusaurus/utils": "0.0.0-4591",
31
- "@docusaurus/utils-common": "0.0.0-4591",
32
- "@docusaurus/utils-validation": "0.0.0-4591",
24
+ "@docusaurus/core": "0.0.0-4595",
25
+ "@docusaurus/plugin-content-blog": "0.0.0-4595",
26
+ "@docusaurus/plugin-content-docs": "0.0.0-4595",
27
+ "@docusaurus/plugin-content-pages": "0.0.0-4595",
28
+ "@docusaurus/theme-common": "0.0.0-4595",
29
+ "@docusaurus/theme-translations": "0.0.0-4595",
30
+ "@docusaurus/utils": "0.0.0-4595",
31
+ "@docusaurus/utils-common": "0.0.0-4595",
32
+ "@docusaurus/utils-validation": "0.0.0-4595",
33
33
  "@mdx-js/react": "^1.6.22",
34
34
  "clsx": "^1.1.1",
35
35
  "copy-text-to-clipboard": "^3.0.1",
@@ -42,8 +42,8 @@
42
42
  "rtlcss": "^3.3.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@docusaurus/module-type-aliases": "0.0.0-4591",
46
- "@docusaurus/types": "0.0.0-4591",
45
+ "@docusaurus/module-type-aliases": "0.0.0-4595",
46
+ "@docusaurus/types": "0.0.0-4595",
47
47
  "@types/mdx-js__react": "^1.5.5",
48
48
  "@types/prismjs": "^1.26.0",
49
49
  "@types/rtlcss": "^3.1.2",
@@ -59,5 +59,5 @@
59
59
  "engines": {
60
60
  "node": ">=14"
61
61
  },
62
- "gitHead": "a15b2171f3a3fe3182be0201921f30b867c9df9d"
62
+ "gitHead": "3bd73b49c00b9438753da2f060eba352b1f8536b"
63
63
  }
@@ -0,0 +1,86 @@
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, {type ReactNode} from 'react';
9
+ import {ThemeClassNames, useSidebarBreadcrumbs} from '@docusaurus/theme-common';
10
+ import styles from './styles.module.css';
11
+ import clsx from 'clsx';
12
+ import Link from '@docusaurus/Link';
13
+ import useBaseUrl from '@docusaurus/useBaseUrl';
14
+
15
+ // TODO move to design system folder
16
+ function BreadcrumbsItemLink({
17
+ children,
18
+ href,
19
+ }: {
20
+ children: ReactNode;
21
+ href?: string;
22
+ }): JSX.Element {
23
+ const className = clsx('breadcrumbs__link', styles.breadcrumbsItemLink);
24
+ return href ? (
25
+ <Link className={className} href={href}>
26
+ {children}
27
+ </Link>
28
+ ) : (
29
+ <span className={className}>{children}</span>
30
+ );
31
+ }
32
+
33
+ // TODO move to design system folder
34
+ function BreadcrumbsItem({
35
+ children,
36
+ active,
37
+ }: {
38
+ children: ReactNode;
39
+ active?: boolean;
40
+ }): JSX.Element {
41
+ return (
42
+ <li
43
+ className={clsx('breadcrumbs__item', {
44
+ 'breadcrumbs__item--active': active,
45
+ })}>
46
+ {children}
47
+ </li>
48
+ );
49
+ }
50
+
51
+ function HomeBreadcrumbItem() {
52
+ const homeHref = useBaseUrl('/');
53
+ return (
54
+ <BreadcrumbsItem>
55
+ <BreadcrumbsItemLink href={homeHref}>🏠</BreadcrumbsItemLink>
56
+ </BreadcrumbsItem>
57
+ );
58
+ }
59
+
60
+ export default function DocBreadcrumbs(): JSX.Element | null {
61
+ const breadcrumbs = useSidebarBreadcrumbs();
62
+
63
+ if (!breadcrumbs) {
64
+ return null;
65
+ }
66
+
67
+ return (
68
+ <nav
69
+ className={clsx(
70
+ ThemeClassNames.docs.docBreadcrumbs,
71
+ styles.breadcrumbsContainer,
72
+ )}
73
+ aria-label="breadcrumbs">
74
+ <ul className="breadcrumbs">
75
+ <HomeBreadcrumbItem />
76
+ {breadcrumbs.map((item, idx) => (
77
+ <BreadcrumbsItem key={idx} active={idx === breadcrumbs.length - 1}>
78
+ <BreadcrumbsItemLink href={item.href}>
79
+ {item.label}
80
+ </BreadcrumbsItemLink>
81
+ </BreadcrumbsItem>
82
+ ))}
83
+ </ul>
84
+ </nav>
85
+ );
86
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ .breadcrumbsContainer {
9
+ margin-bottom: 0.4rem;
10
+ }
11
+
12
+ .breadcrumbsItemLink {
13
+ --ifm-breadcrumb-size-multiplier: 0.7 !important;
14
+ margin-bottom: 0.4rem;
15
+ background: var(--ifm-color-gray-100);
16
+ }
17
+
18
+ html[data-theme='dark'] .breadcrumbsItemLink {
19
+ background-color: var(--ifm-color-gray-900);
20
+ }
21
+
22
+ @media (min-width: 997px) {
23
+ .breadcrumbsItemLink {
24
+ --ifm-breadcrumb-size-multiplier: 0.8;
25
+ }
26
+ }
@@ -13,6 +13,7 @@ import DocPaginator from '@theme/DocPaginator';
13
13
  import Seo from '@theme/Seo';
14
14
  import DocVersionBanner from '@theme/DocVersionBanner';
15
15
  import DocVersionBadge from '@theme/DocVersionBadge';
16
+ import DocBreadcrumbs from '@theme/DocBreadcrumbs';
16
17
  import Heading from '@theme/Heading';
17
18
  import useBaseUrl from '@docusaurus/useBaseUrl';
18
19
 
@@ -33,6 +34,7 @@ export default function DocCategoryGeneratedIndexPage({
33
34
  />
34
35
  <div className={styles.generatedIndexPage}>
35
36
  <DocVersionBanner />
37
+ <DocBreadcrumbs />
36
38
  <DocVersionBadge />
37
39
  <header>
38
40
  <Heading as="h1" className={styles.title}>
@@ -18,6 +18,7 @@ import TOCCollapsible from '@theme/TOCCollapsible';
18
18
  import Heading from '@theme/Heading';
19
19
  import styles from './styles.module.css';
20
20
  import {ThemeClassNames, useWindowSize} from '@docusaurus/theme-common';
21
+ import DocBreadcrumbs from '@theme/DocBreadcrumbs';
21
22
 
22
23
  export default function DocItem(props: Props): JSX.Element {
23
24
  const {content: DocContent} = props;
@@ -58,6 +59,7 @@ export default function DocItem(props: Props): JSX.Element {
58
59
  <DocVersionBanner />
59
60
  <div className={styles.docItemContainer}>
60
61
  <article>
62
+ <DocBreadcrumbs />
61
63
  <DocVersionBadge />
62
64
 
63
65
  {canRenderTOC && (
@@ -62,11 +62,26 @@ const ToggleComponent = memo(
62
62
  checked={checked}
63
63
  type="checkbox"
64
64
  className={styles.toggleScreenReader}
65
- aria-label={translate({
66
- message: 'Switch between dark and light mode',
67
- id: 'theme.colorToggle.ariaLabel',
68
- description: 'The ARIA label for the navbar color mode toggle',
69
- })}
65
+ aria-label={translate(
66
+ {
67
+ message: 'Switch between dark and light mode (currently {mode})',
68
+ id: 'theme.colorToggle.ariaLabel',
69
+ description: 'The ARIA label for the navbar color mode toggle',
70
+ },
71
+ {
72
+ mode: checked
73
+ ? translate({
74
+ message: 'dark mode',
75
+ id: 'theme.colorToggle.ariaLabel.mode.dark',
76
+ description: 'The name for the dark color mode',
77
+ })
78
+ : translate({
79
+ message: 'light mode',
80
+ id: 'theme.colorToggle.ariaLabel.mode.light',
81
+ description: 'The name for the light color mode',
82
+ }),
83
+ },
84
+ )}
70
85
  onChange={onChange}
71
86
  onClick={() => setChecked(!checked)}
72
87
  onFocus={() => setFocused(true)}