@docusaurus/theme-classic 0.0.0-4772 → 0.0.0-4775

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.
@@ -35,7 +35,7 @@ export default function CopyButton({code}) {
35
35
  message: 'Copy code to clipboard',
36
36
  description: 'The ARIA label for copy code blocks button',
37
37
  })
38
- } // @todo: check it again later
38
+ }
39
39
  title={translate({
40
40
  id: 'theme.CodeBlock.copy',
41
41
  message: 'Copy',
@@ -99,9 +99,7 @@ export default function CodeBlock({
99
99
  {codeBlockTitle}
100
100
  </div>
101
101
  )}
102
- <div
103
- className={clsx(styles.codeBlockContent, language)}
104
- style={style}>
102
+ <div className={styles.codeBlockContent} style={style}>
105
103
  <pre
106
104
  /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
107
105
  tabIndex={0}
@@ -7,7 +7,6 @@
7
7
 
8
8
  .codeBlockContainer {
9
9
  margin-bottom: var(--ifm-leading);
10
- border-radius: var(--ifm-global-radius);
11
10
  box-shadow: var(--ifm-global-shadow-lw);
12
11
  }
13
12
 
@@ -15,6 +14,7 @@
15
14
  position: relative;
16
15
  /* rtl:ignore */
17
16
  direction: ltr;
17
+ border-radius: var(--ifm-global-radius);
18
18
  }
19
19
 
20
20
  .codeBlockTitle {
@@ -29,7 +29,6 @@
29
29
  .codeBlock {
30
30
  margin: 0;
31
31
  padding: 0;
32
- border-radius: var(--ifm-global-radius);
33
32
  background-color: inherit;
34
33
  }
35
34
 
@@ -40,7 +39,6 @@
40
39
 
41
40
  .codeBlockStandalone {
42
41
  padding: 0;
43
- border-radius: var(--ifm-global-radius);
44
42
  }
45
43
 
46
44
  .codeBlockLines {
@@ -13,17 +13,12 @@ import isInternalUrl from '@docusaurus/isInternalUrl';
13
13
  import {translate} from '@docusaurus/Translate';
14
14
 
15
15
  function CardContainer({href, children}) {
16
- const className = clsx(
17
- 'card margin-bottom--lg padding--lg',
18
- styles.cardContainer,
19
- href && styles.cardContainerLink,
20
- );
21
- return href ? (
22
- <Link href={href} className={className}>
16
+ return (
17
+ <Link
18
+ href={href}
19
+ className={clsx('card padding--lg', styles.cardContainer)}>
23
20
  {children}
24
21
  </Link>
25
- ) : (
26
- <div className={className}>{children}</div>
27
22
  );
28
23
  }
29
24
 
@@ -33,17 +28,24 @@ function CardLayout({href, icon, title, description}) {
33
28
  <h2 className={clsx('text--truncate', styles.cardTitle)} title={title}>
34
29
  {icon} {title}
35
30
  </h2>
36
- <div
37
- className={clsx('text--truncate', styles.cardDescription)}
38
- title={description}>
39
- {description}
40
- </div>
31
+ {description && (
32
+ <p
33
+ className={clsx('text--truncate', styles.cardDescription)}
34
+ title={description}>
35
+ {description}
36
+ </p>
37
+ )}
41
38
  </CardContainer>
42
39
  );
43
40
  }
44
41
 
45
42
  function CardCategory({item}) {
46
- const href = findFirstCategoryLink(item);
43
+ const href = findFirstCategoryLink(item); // Unexpected: categories that don't have a link have been filtered upfront
44
+
45
+ if (!href) {
46
+ return null;
47
+ }
48
+
47
49
  return (
48
50
  <CardLayout
49
51
  href={href}
@@ -6,38 +6,29 @@
6
6
  */
7
7
 
8
8
  .cardContainer {
9
- height: 8rem;
10
- color: var(--ifm-color-emphasis-800);
11
9
  --ifm-link-color: var(--ifm-color-emphasis-800);
12
- --ifm-link-hover-color: var(--ifm-color-emphasis-800);
10
+ --ifm-link-hover-color: var(--ifm-color-emphasis-700);
13
11
  --ifm-link-hover-decoration: none;
14
12
 
15
- /* box-shadow: var(--ifm-global-shadow-lw); */
16
13
  box-shadow: 0 1.5px 3px 0 rgb(0 0 0 / 15%);
17
14
  border: 1px solid var(--ifm-color-emphasis-200);
18
- transition: box-shadow var(--ifm-transition-fast) ease,
19
- background-color var(--ifm-transition-fast) ease;
15
+ transition: all var(--ifm-transition-fast) ease;
16
+ transition-property: border, box-shadow;
20
17
  }
21
18
 
22
- .cardContainer.cardContainerLink:hover {
23
- /* box-shadow: var(--ifm-global-shadow-md); */
24
- box-shadow: 0 4px 8px 0 rgb(0 0 0 / 20%);
19
+ .cardContainer:hover {
20
+ border-color: var(--ifm-color-primary);
21
+ box-shadow: 0 3px 6px 0 rgb(0 0 0 / 20%);
25
22
  }
26
23
 
27
- [data-theme='dark'] .cardContainer.cardContainerLink:hover {
28
- --ifm-card-background-color: #2d2d2d; /* original, non-hovered color is #242526 */
29
- }
30
-
31
- .cardContainer:not(.cardContainerLink) {
32
- cursor: not-allowed;
24
+ .cardContainer *:last-child {
25
+ margin-bottom: 0;
33
26
  }
34
27
 
35
28
  .cardTitle {
36
29
  font-size: 1.2rem;
37
- min-height: 1.2rem;
38
30
  }
39
31
 
40
32
  .cardDescription {
41
33
  font-size: 0.8rem;
42
- min-height: 0.8rem;
43
34
  }
@@ -6,12 +6,24 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import DocCard from '@theme/DocCard';
9
+ import {findFirstCategoryLink} from '@docusaurus/theme-common'; // Filter categories that don't have a link.
10
+
11
+ function filterItems(items) {
12
+ return items.filter((item) => {
13
+ if (item.type === 'category') {
14
+ return !!findFirstCategoryLink(item);
15
+ }
16
+
17
+ return true;
18
+ });
19
+ }
20
+
9
21
  export default function DocCardList({items}) {
10
22
  return (
11
23
  <div className="row">
12
- {items.map((item, index) => (
13
- <article key={index} className="col col--6">
14
- <DocCard item={item} />
24
+ {filterItems(items).map((item, index) => (
25
+ <article key={index} className="col col--6 margin-bottom--lg">
26
+ <DocCard key={index} item={item} />
15
27
  </article>
16
28
  ))}
17
29
  </div>
@@ -64,6 +64,9 @@ function DropdownNavbarItemDesktop({items, position, className, ...props}) {
64
64
  'dropdown--show': showDropdown,
65
65
  })}>
66
66
  <NavbarNavLink
67
+ aria-haspopup="true"
68
+ aria-expanded={showDropdown}
69
+ role="button"
67
70
  href={props.to ? undefined : '#'}
68
71
  className={clsx('navbar__link', className)}
69
72
  {...props}
@@ -87,7 +90,12 @@ function DropdownNavbarItemDesktop({items, position, className, ...props}) {
87
90
  const nextNavbarItem = dropdownRef.current.nextElementSibling;
88
91
 
89
92
  if (nextNavbarItem) {
90
- nextNavbarItem.focus();
93
+ const targetItem =
94
+ nextNavbarItem instanceof HTMLAnchorElement
95
+ ? nextNavbarItem // Next item is another dropdown; focus on the inner
96
+ : // anchor element instead so there's outline
97
+ nextNavbarItem.querySelector('a');
98
+ targetItem.focus();
91
99
  }
92
100
  }
93
101
  }}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-4772",
3
+ "version": "0.0.0-4775",
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-4772",
25
- "@docusaurus/plugin-content-blog": "0.0.0-4772",
26
- "@docusaurus/plugin-content-docs": "0.0.0-4772",
27
- "@docusaurus/plugin-content-pages": "0.0.0-4772",
28
- "@docusaurus/theme-common": "0.0.0-4772",
29
- "@docusaurus/theme-translations": "0.0.0-4772",
30
- "@docusaurus/utils": "0.0.0-4772",
31
- "@docusaurus/utils-common": "0.0.0-4772",
32
- "@docusaurus/utils-validation": "0.0.0-4772",
24
+ "@docusaurus/core": "0.0.0-4775",
25
+ "@docusaurus/plugin-content-blog": "0.0.0-4775",
26
+ "@docusaurus/plugin-content-docs": "0.0.0-4775",
27
+ "@docusaurus/plugin-content-pages": "0.0.0-4775",
28
+ "@docusaurus/theme-common": "0.0.0-4775",
29
+ "@docusaurus/theme-translations": "0.0.0-4775",
30
+ "@docusaurus/utils": "0.0.0-4775",
31
+ "@docusaurus/utils-common": "0.0.0-4775",
32
+ "@docusaurus/utils-validation": "0.0.0-4775",
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.5.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@docusaurus/module-type-aliases": "0.0.0-4772",
46
- "@docusaurus/types": "0.0.0-4772",
45
+ "@docusaurus/module-type-aliases": "0.0.0-4775",
46
+ "@docusaurus/types": "0.0.0-4775",
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": "50ef1fb8e19a46e43c122d625c8bff2110546260"
62
+ "gitHead": "c5116b4d028c288e4adca7a00a781655dae43131"
63
63
  }
@@ -42,7 +42,6 @@ export default function CopyButton({code}: Props): JSX.Element {
42
42
  description: 'The ARIA label for copy code blocks button',
43
43
  })
44
44
  }
45
- // @todo: check it again later
46
45
  title={translate({
47
46
  id: 'theme.CodeBlock.copy',
48
47
  message: 'Copy',
@@ -111,9 +111,7 @@ export default function CodeBlock({
111
111
  {codeBlockTitle}
112
112
  </div>
113
113
  )}
114
- <div
115
- className={clsx(styles.codeBlockContent, language)}
116
- style={style}>
114
+ <div className={styles.codeBlockContent} style={style}>
117
115
  <pre
118
116
  /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
119
117
  tabIndex={0}
@@ -7,7 +7,6 @@
7
7
 
8
8
  .codeBlockContainer {
9
9
  margin-bottom: var(--ifm-leading);
10
- border-radius: var(--ifm-global-radius);
11
10
  box-shadow: var(--ifm-global-shadow-lw);
12
11
  }
13
12
 
@@ -15,6 +14,7 @@
15
14
  position: relative;
16
15
  /* rtl:ignore */
17
16
  direction: ltr;
17
+ border-radius: var(--ifm-global-radius);
18
18
  }
19
19
 
20
20
  .codeBlockTitle {
@@ -29,7 +29,6 @@
29
29
  .codeBlock {
30
30
  margin: 0;
31
31
  padding: 0;
32
- border-radius: var(--ifm-global-radius);
33
32
  background-color: inherit;
34
33
  }
35
34
 
@@ -40,7 +39,6 @@
40
39
 
41
40
  .codeBlockStandalone {
42
41
  padding: 0;
43
- border-radius: var(--ifm-global-radius);
44
42
  }
45
43
 
46
44
  .codeBlockLines {
@@ -22,20 +22,15 @@ function CardContainer({
22
22
  href,
23
23
  children,
24
24
  }: {
25
- href?: string;
25
+ href: string;
26
26
  children: ReactNode;
27
27
  }): JSX.Element {
28
- const className = clsx(
29
- 'card margin-bottom--lg padding--lg',
30
- styles.cardContainer,
31
- href && styles.cardContainerLink,
32
- );
33
- return href ? (
34
- <Link href={href} className={className}>
28
+ return (
29
+ <Link
30
+ href={href}
31
+ className={clsx('card padding--lg', styles.cardContainer)}>
35
32
  {children}
36
33
  </Link>
37
- ) : (
38
- <div className={className}>{children}</div>
39
34
  );
40
35
  }
41
36
 
@@ -45,7 +40,7 @@ function CardLayout({
45
40
  title,
46
41
  description,
47
42
  }: {
48
- href?: string;
43
+ href: string;
49
44
  icon: ReactNode;
50
45
  title: string;
51
46
  description?: string;
@@ -55,17 +50,29 @@ function CardLayout({
55
50
  <h2 className={clsx('text--truncate', styles.cardTitle)} title={title}>
56
51
  {icon} {title}
57
52
  </h2>
58
- <div
59
- className={clsx('text--truncate', styles.cardDescription)}
60
- title={description}>
61
- {description}
62
- </div>
53
+ {description && (
54
+ <p
55
+ className={clsx('text--truncate', styles.cardDescription)}
56
+ title={description}>
57
+ {description}
58
+ </p>
59
+ )}
63
60
  </CardContainer>
64
61
  );
65
62
  }
66
63
 
67
- function CardCategory({item}: {item: PropSidebarItemCategory}): JSX.Element {
64
+ function CardCategory({
65
+ item,
66
+ }: {
67
+ item: PropSidebarItemCategory;
68
+ }): JSX.Element | null {
68
69
  const href = findFirstCategoryLink(item);
70
+
71
+ // Unexpected: categories that don't have a link have been filtered upfront
72
+ if (!href) {
73
+ return null;
74
+ }
75
+
69
76
  return (
70
77
  <CardLayout
71
78
  href={href}
@@ -6,38 +6,29 @@
6
6
  */
7
7
 
8
8
  .cardContainer {
9
- height: 8rem;
10
- color: var(--ifm-color-emphasis-800);
11
9
  --ifm-link-color: var(--ifm-color-emphasis-800);
12
- --ifm-link-hover-color: var(--ifm-color-emphasis-800);
10
+ --ifm-link-hover-color: var(--ifm-color-emphasis-700);
13
11
  --ifm-link-hover-decoration: none;
14
12
 
15
- /* box-shadow: var(--ifm-global-shadow-lw); */
16
13
  box-shadow: 0 1.5px 3px 0 rgb(0 0 0 / 15%);
17
14
  border: 1px solid var(--ifm-color-emphasis-200);
18
- transition: box-shadow var(--ifm-transition-fast) ease,
19
- background-color var(--ifm-transition-fast) ease;
15
+ transition: all var(--ifm-transition-fast) ease;
16
+ transition-property: border, box-shadow;
20
17
  }
21
18
 
22
- .cardContainer.cardContainerLink:hover {
23
- /* box-shadow: var(--ifm-global-shadow-md); */
24
- box-shadow: 0 4px 8px 0 rgb(0 0 0 / 20%);
19
+ .cardContainer:hover {
20
+ border-color: var(--ifm-color-primary);
21
+ box-shadow: 0 3px 6px 0 rgb(0 0 0 / 20%);
25
22
  }
26
23
 
27
- [data-theme='dark'] .cardContainer.cardContainerLink:hover {
28
- --ifm-card-background-color: #2d2d2d; /* original, non-hovered color is #242526 */
29
- }
30
-
31
- .cardContainer:not(.cardContainerLink) {
32
- cursor: not-allowed;
24
+ .cardContainer *:last-child {
25
+ margin-bottom: 0;
33
26
  }
34
27
 
35
28
  .cardTitle {
36
29
  font-size: 1.2rem;
37
- min-height: 1.2rem;
38
30
  }
39
31
 
40
32
  .cardDescription {
41
33
  font-size: 0.8rem;
42
- min-height: 0.8rem;
43
34
  }
@@ -9,6 +9,17 @@ import React from 'react';
9
9
 
10
10
  import DocCard from '@theme/DocCard';
11
11
  import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
12
+ import {findFirstCategoryLink} from '@docusaurus/theme-common';
13
+
14
+ // Filter categories that don't have a link.
15
+ function filterItems(items: PropSidebarItem[]): PropSidebarItem[] {
16
+ return items.filter((item) => {
17
+ if (item.type === 'category') {
18
+ return !!findFirstCategoryLink(item);
19
+ }
20
+ return true;
21
+ });
22
+ }
12
23
 
13
24
  export default function DocCardList({
14
25
  items,
@@ -17,9 +28,9 @@ export default function DocCardList({
17
28
  }): JSX.Element {
18
29
  return (
19
30
  <div className="row">
20
- {items.map((item, index) => (
21
- <article key={index} className="col col--6">
22
- <DocCard item={item} />
31
+ {filterItems(items).map((item, index) => (
32
+ <article key={index} className="col col--6 margin-bottom--lg">
33
+ <DocCard key={index} item={item} />
23
34
  </article>
24
35
  ))}
25
36
  </div>
@@ -85,6 +85,9 @@ function DropdownNavbarItemDesktop({
85
85
  'dropdown--show': showDropdown,
86
86
  })}>
87
87
  <NavbarNavLink
88
+ aria-haspopup="true"
89
+ aria-expanded={showDropdown}
90
+ role="button"
88
91
  href={props.to ? undefined : '#'}
89
92
  className={clsx('navbar__link', className)}
90
93
  {...props}
@@ -107,7 +110,13 @@ function DropdownNavbarItemDesktop({
107
110
  setShowDropdown(false);
108
111
  const nextNavbarItem = dropdownRef.current!.nextElementSibling;
109
112
  if (nextNavbarItem) {
110
- (nextNavbarItem as HTMLElement).focus();
113
+ const targetItem =
114
+ nextNavbarItem instanceof HTMLAnchorElement
115
+ ? nextNavbarItem
116
+ : // Next item is another dropdown; focus on the inner
117
+ // anchor element instead so there's outline
118
+ nextNavbarItem.querySelector('a');
119
+ (targetItem as HTMLElement).focus();
111
120
  }
112
121
  }
113
122
  }}