@docusaurus/theme-classic 0.0.0-4861 → 0.0.0-4866

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.
@@ -692,6 +692,16 @@ declare module '@theme/Navbar/MobileSidebar/Header' {
692
692
  export default function NavbarMobileSidebarHeader(): JSX.Element;
693
693
  }
694
694
 
695
+ declare module '@theme/Navbar/Search' {
696
+ import type {ReactNode} from 'react';
697
+
698
+ export interface Props {
699
+ readonly children: ReactNode;
700
+ }
701
+
702
+ export default function NavbarSearch(props: Props): JSX.Element;
703
+ }
704
+
695
705
  declare module '@theme/NavbarItem/DefaultNavbarItem' {
696
706
  import type {Props as NavbarNavLinkProps} from '@theme/NavbarItem/NavbarNavLink';
697
707
 
@@ -6,8 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.ThemeConfigSchema = exports.DEFAULT_CONFIG = void 0;
7
7
  exports.validateThemeConfig = validateThemeConfig;
8
8
 
9
+ var _palenight = _interopRequireDefault(require("prism-react-renderer/themes/palenight"));
10
+
9
11
  var _utilsValidation = require("@docusaurus/utils-validation");
10
12
 
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+
11
15
  /**
12
16
  * Copyright (c) Facebook, Inc. and its affiliates.
13
17
  *
@@ -32,7 +36,8 @@ const DEFAULT_CONFIG = {
32
36
  docs: DEFAULT_DOCS_CONFIG,
33
37
  metadata: [],
34
38
  prism: {
35
- additionalLanguages: []
39
+ additionalLanguages: [],
40
+ theme: _palenight.default
36
41
  },
37
42
  navbar: {
38
43
  hideOnScroll: false,
@@ -277,7 +282,7 @@ const ThemeConfigSchema = _utilsValidation.Joi.object({
277
282
  theme: _utilsValidation.Joi.object({
278
283
  plain: _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.array(), _utilsValidation.Joi.object()).required(),
279
284
  styles: _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.array(), _utilsValidation.Joi.object()).required()
280
- }),
285
+ }).default(DEFAULT_CONFIG.prism.theme),
281
286
  darkTheme: _utilsValidation.Joi.object({
282
287
  plain: _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.array(), _utilsValidation.Joi.object()).required(),
283
288
  styles: _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.array(), _utilsValidation.Joi.object()).required()
@@ -7,7 +7,9 @@
7
7
 
8
8
  .copyButton {
9
9
  display: flex;
10
- background: inherit;
10
+ /* TODO: move to base button styling */
11
+ background: var(--prism-background-color);
12
+ color: var(--prism-color);
11
13
  border: 1px solid var(--ifm-color-emphasis-300);
12
14
  border-radius: var(--ifm-global-radius);
13
15
  padding: 0.4rem;
@@ -15,6 +15,7 @@ import {
15
15
  containsLineNumbers,
16
16
  ThemeClassNames,
17
17
  usePrismTheme,
18
+ getPrismCssVariables,
18
19
  } from '@docusaurus/theme-common';
19
20
  import CopyButton from '@theme/CodeBlock/CopyButton';
20
21
  import styles from './styles.module.css';
@@ -42,7 +43,8 @@ export default function CodeBlock({
42
43
  // "title=\"xyz\"" => title: "\"xyz\""
43
44
 
44
45
  const codeBlockTitle = parseCodeBlockTitle(metastring) || title;
45
- const prismTheme = usePrismTheme(); // <pre> tags in markdown map to CodeBlocks and they may contain JSX children.
46
+ const prismTheme = usePrismTheme();
47
+ const prismCssVariables = getPrismCssVariables(prismTheme); // <pre> tags in markdown map to CodeBlocks and they may contain JSX children.
46
48
  // When the children is not a simple string, we just return a styled block
47
49
  // without actually highlighting.
48
50
 
@@ -54,7 +56,7 @@ export default function CodeBlock({
54
56
  theme={prismTheme}
55
57
  code=""
56
58
  language={'text'}>
57
- {({className, style}) => (
59
+ {({className}) => (
58
60
  <pre
59
61
  /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
60
62
  tabIndex={0}
@@ -66,7 +68,7 @@ export default function CodeBlock({
66
68
  blockClassName,
67
69
  ThemeClassNames.common.codeBlock,
68
70
  )}
69
- style={style}>
71
+ style={prismCssVariables}>
70
72
  <code className={styles.codeBlockLines}>{children}</code>
71
73
  </pre>
72
74
  )}
@@ -87,7 +89,7 @@ export default function CodeBlock({
87
89
  theme={prismTheme}
88
90
  code={code}
89
91
  language={language ?? 'text'}>
90
- {({className, style, tokens, getLineProps, getTokenProps}) => (
92
+ {({className, tokens, getLineProps, getTokenProps}) => (
91
93
  <div
92
94
  className={clsx(
93
95
  styles.codeBlockContainer,
@@ -97,13 +99,12 @@ export default function CodeBlock({
97
99
  language && !blockClassName.includes(`language-${language}`),
98
100
  },
99
101
  ThemeClassNames.common.codeBlock,
100
- )}>
102
+ )}
103
+ style={prismCssVariables}>
101
104
  {codeBlockTitle && (
102
- <div style={style} className={styles.codeBlockTitle}>
103
- {codeBlockTitle}
104
- </div>
105
+ <div className={styles.codeBlockTitle}>{codeBlockTitle}</div>
105
106
  )}
106
- <div className={styles.codeBlockContent} style={style}>
107
+ <div className={styles.codeBlockContent}>
107
108
  <pre
108
109
  /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
109
110
  tabIndex={0}
@@ -6,6 +6,8 @@
6
6
  */
7
7
 
8
8
  .codeBlockContainer {
9
+ background: var(--prism-background-color);
10
+ color: var(--prism-color);
9
11
  margin-bottom: var(--ifm-leading);
10
12
  box-shadow: var(--ifm-global-shadow-lw);
11
13
  border-radius: var(--ifm-code-border-radius);
@@ -28,7 +30,7 @@
28
30
  }
29
31
 
30
32
  .codeBlock {
31
- --ifm-pre-background: inherit;
33
+ --ifm-pre-background: var(--prism-background-color);
32
34
  margin: 0;
33
35
  padding: 0;
34
36
  }
@@ -44,7 +46,6 @@
44
46
 
45
47
  .codeBlockLines {
46
48
  font: inherit;
47
- background: var(--ifm-pre-background);
48
49
  /* rtl:ignore */
49
50
  float: left;
50
51
  min-width: 100%;
@@ -15,6 +15,7 @@ import {
15
15
  } from '@docusaurus/theme-common';
16
16
  import NavbarMobileSidebarToggle from '@theme/Navbar/MobileSidebar/Toggle';
17
17
  import NavbarLogo from '@theme/Navbar/Logo';
18
+ import NavbarSearch from '@theme/Navbar/Search';
18
19
  import styles from './styles.module.css';
19
20
 
20
21
  function useNavbarItems() {
@@ -62,7 +63,11 @@ export default function NavbarContent() {
62
63
  <>
63
64
  <NavbarItems items={rightItems} />
64
65
  <NavbarColorModeToggle className={styles.colorModeToggle} />
65
- {autoAddSearchBar && <SearchBar />}
66
+ {autoAddSearchBar && (
67
+ <NavbarSearch>
68
+ <SearchBar />
69
+ </NavbarSearch>
70
+ )}
66
71
  </>
67
72
  }
68
73
  />
@@ -0,0 +1,11 @@
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 styles from './styles.module.css';
9
+ export default function NavbarSearch({children}) {
10
+ return <div className={styles.searchBox}>{children}</div>;
11
+ }
@@ -0,0 +1,20 @@
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 (max-width: 996px) {
9
+ .searchBox {
10
+ position: absolute;
11
+ right: var(--ifm-navbar-padding-horizontal);
12
+ }
13
+ }
14
+
15
+ @media (min-width: 997px) {
16
+ .searchBox {
17
+ padding: var(--ifm-navbar-item-padding-vertical)
18
+ var(--ifm-navbar-item-padding-horizontal);
19
+ }
20
+ }
@@ -6,10 +6,15 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import SearchBar from '@theme/SearchBar';
9
+ import NavbarSearch from '@theme/Navbar/Search';
9
10
  export default function SearchNavbarItem({mobile}) {
10
11
  if (mobile) {
11
12
  return null;
12
13
  }
13
14
 
14
- return <SearchBar />;
15
+ return (
16
+ <NavbarSearch>
17
+ <SearchBar />
18
+ </NavbarSearch>
19
+ );
15
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-4861",
3
+ "version": "0.0.0-4866",
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-4861",
25
- "@docusaurus/plugin-content-blog": "0.0.0-4861",
26
- "@docusaurus/plugin-content-docs": "0.0.0-4861",
27
- "@docusaurus/plugin-content-pages": "0.0.0-4861",
28
- "@docusaurus/theme-common": "0.0.0-4861",
29
- "@docusaurus/theme-translations": "0.0.0-4861",
30
- "@docusaurus/utils": "0.0.0-4861",
31
- "@docusaurus/utils-common": "0.0.0-4861",
32
- "@docusaurus/utils-validation": "0.0.0-4861",
24
+ "@docusaurus/core": "0.0.0-4866",
25
+ "@docusaurus/plugin-content-blog": "0.0.0-4866",
26
+ "@docusaurus/plugin-content-docs": "0.0.0-4866",
27
+ "@docusaurus/plugin-content-pages": "0.0.0-4866",
28
+ "@docusaurus/theme-common": "0.0.0-4866",
29
+ "@docusaurus/theme-translations": "0.0.0-4866",
30
+ "@docusaurus/utils": "0.0.0-4866",
31
+ "@docusaurus/utils-common": "0.0.0-4866",
32
+ "@docusaurus/utils-validation": "0.0.0-4866",
33
33
  "@mdx-js/react": "^1.6.22",
34
34
  "clsx": "^1.1.1",
35
35
  "copy-text-to-clipboard": "^3.0.1",
@@ -45,8 +45,8 @@
45
45
  "@babel/cli": "^7.17.6",
46
46
  "@babel/core": "^7.17.9",
47
47
  "@babel/preset-typescript": "^7.16.7",
48
- "@docusaurus/module-type-aliases": "0.0.0-4861",
49
- "@docusaurus/types": "0.0.0-4861",
48
+ "@docusaurus/module-type-aliases": "0.0.0-4866",
49
+ "@docusaurus/types": "0.0.0-4866",
50
50
  "@types/mdx-js__react": "^1.5.5",
51
51
  "@types/prismjs": "^1.26.0",
52
52
  "@types/rtlcss": "^3.1.3",
@@ -62,5 +62,5 @@
62
62
  "engines": {
63
63
  "node": ">=14"
64
64
  },
65
- "gitHead": "98ec6aafe622a5101a4356e7ea9b30c441e3b977"
65
+ "gitHead": "73ca22c3217a0a2d68d62b19796fde9a0a498a29"
66
66
  }
@@ -7,7 +7,9 @@
7
7
 
8
8
  .copyButton {
9
9
  display: flex;
10
- background: inherit;
10
+ /* TODO: move to base button styling */
11
+ background: var(--prism-background-color);
12
+ color: var(--prism-color);
11
13
  border: 1px solid var(--ifm-color-emphasis-300);
12
14
  border-radius: var(--ifm-global-radius);
13
15
  padding: 0.4rem;
@@ -16,6 +16,7 @@ import {
16
16
  containsLineNumbers,
17
17
  ThemeClassNames,
18
18
  usePrismTheme,
19
+ getPrismCssVariables,
19
20
  } from '@docusaurus/theme-common';
20
21
  import CopyButton from '@theme/CodeBlock/CopyButton';
21
22
  import type {Props} from '@theme/CodeBlock';
@@ -50,6 +51,8 @@ export default function CodeBlock({
50
51
  const codeBlockTitle = parseCodeBlockTitle(metastring) || title;
51
52
  const prismTheme = usePrismTheme();
52
53
 
54
+ const prismCssVariables = getPrismCssVariables(prismTheme);
55
+
53
56
  // <pre> tags in markdown map to CodeBlocks and they may contain JSX children.
54
57
  // When the children is not a simple string, we just return a styled block
55
58
  // without actually highlighting.
@@ -61,7 +64,7 @@ export default function CodeBlock({
61
64
  theme={prismTheme}
62
65
  code=""
63
66
  language={'text' as Language}>
64
- {({className, style}) => (
67
+ {({className}) => (
65
68
  <pre
66
69
  /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
67
70
  tabIndex={0}
@@ -73,7 +76,7 @@ export default function CodeBlock({
73
76
  blockClassName,
74
77
  ThemeClassNames.common.codeBlock,
75
78
  )}
76
- style={style}>
79
+ style={prismCssVariables}>
77
80
  <code className={styles.codeBlockLines}>{children}</code>
78
81
  </pre>
79
82
  )}
@@ -99,7 +102,7 @@ export default function CodeBlock({
99
102
  theme={prismTheme}
100
103
  code={code}
101
104
  language={(language ?? 'text') as Language}>
102
- {({className, style, tokens, getLineProps, getTokenProps}) => (
105
+ {({className, tokens, getLineProps, getTokenProps}) => (
103
106
  <div
104
107
  className={clsx(
105
108
  styles.codeBlockContainer,
@@ -109,13 +112,12 @@ export default function CodeBlock({
109
112
  language && !blockClassName.includes(`language-${language}`),
110
113
  },
111
114
  ThemeClassNames.common.codeBlock,
112
- )}>
115
+ )}
116
+ style={prismCssVariables}>
113
117
  {codeBlockTitle && (
114
- <div style={style} className={styles.codeBlockTitle}>
115
- {codeBlockTitle}
116
- </div>
118
+ <div className={styles.codeBlockTitle}>{codeBlockTitle}</div>
117
119
  )}
118
- <div className={styles.codeBlockContent} style={style}>
120
+ <div className={styles.codeBlockContent}>
119
121
  <pre
120
122
  /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
121
123
  tabIndex={0}
@@ -6,6 +6,8 @@
6
6
  */
7
7
 
8
8
  .codeBlockContainer {
9
+ background: var(--prism-background-color);
10
+ color: var(--prism-color);
9
11
  margin-bottom: var(--ifm-leading);
10
12
  box-shadow: var(--ifm-global-shadow-lw);
11
13
  border-radius: var(--ifm-code-border-radius);
@@ -28,7 +30,7 @@
28
30
  }
29
31
 
30
32
  .codeBlock {
31
- --ifm-pre-background: inherit;
33
+ --ifm-pre-background: var(--prism-background-color);
32
34
  margin: 0;
33
35
  padding: 0;
34
36
  }
@@ -44,7 +46,6 @@
44
46
 
45
47
  .codeBlockLines {
46
48
  font: inherit;
47
- background: var(--ifm-pre-background);
48
49
  /* rtl:ignore */
49
50
  float: left;
50
51
  min-width: 100%;
@@ -17,6 +17,7 @@ import {
17
17
  } from '@docusaurus/theme-common';
18
18
  import NavbarMobileSidebarToggle from '@theme/Navbar/MobileSidebar/Toggle';
19
19
  import NavbarLogo from '@theme/Navbar/Logo';
20
+ import NavbarSearch from '@theme/Navbar/Search';
20
21
  import styles from './styles.module.css';
21
22
 
22
23
  function useNavbarItems() {
@@ -73,7 +74,11 @@ export default function NavbarContent(): JSX.Element {
73
74
  <>
74
75
  <NavbarItems items={rightItems} />
75
76
  <NavbarColorModeToggle className={styles.colorModeToggle} />
76
- {autoAddSearchBar && <SearchBar />}
77
+ {autoAddSearchBar && (
78
+ <NavbarSearch>
79
+ <SearchBar />
80
+ </NavbarSearch>
81
+ )}
77
82
  </>
78
83
  }
79
84
  />
@@ -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
+ import React from 'react';
9
+ import type {Props} from '@theme/Navbar/Search';
10
+
11
+ import styles from './styles.module.css';
12
+
13
+ export default function NavbarSearch({children}: Props): JSX.Element {
14
+ return <div className={styles.searchBox}>{children}</div>;
15
+ }
@@ -0,0 +1,20 @@
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 (max-width: 996px) {
9
+ .searchBox {
10
+ position: absolute;
11
+ right: var(--ifm-navbar-padding-horizontal);
12
+ }
13
+ }
14
+
15
+ @media (min-width: 997px) {
16
+ .searchBox {
17
+ padding: var(--ifm-navbar-item-padding-vertical)
18
+ var(--ifm-navbar-item-padding-horizontal);
19
+ }
20
+ }
@@ -8,11 +8,16 @@
8
8
  import React from 'react';
9
9
  import type {Props} from '@theme/NavbarItem/SearchNavbarItem';
10
10
  import SearchBar from '@theme/SearchBar';
11
+ import NavbarSearch from '@theme/Navbar/Search';
11
12
 
12
13
  export default function SearchNavbarItem({mobile}: Props): JSX.Element | null {
13
14
  if (mobile) {
14
15
  return null;
15
16
  }
16
17
 
17
- return <SearchBar />;
18
+ return (
19
+ <NavbarSearch>
20
+ <SearchBar />
21
+ </NavbarSearch>
22
+ );
18
23
  }
@@ -692,6 +692,16 @@ declare module '@theme/Navbar/MobileSidebar/Header' {
692
692
  export default function NavbarMobileSidebarHeader(): JSX.Element;
693
693
  }
694
694
 
695
+ declare module '@theme/Navbar/Search' {
696
+ import type {ReactNode} from 'react';
697
+
698
+ export interface Props {
699
+ readonly children: ReactNode;
700
+ }
701
+
702
+ export default function NavbarSearch(props: Props): JSX.Element;
703
+ }
704
+
695
705
  declare module '@theme/NavbarItem/DefaultNavbarItem' {
696
706
  import type {Props as NavbarNavLinkProps} from '@theme/NavbarItem/NavbarNavLink';
697
707
 
@@ -5,6 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
+ import defaultPrismTheme from 'prism-react-renderer/themes/palenight';
8
9
  import {Joi, URISchema} from '@docusaurus/utils-validation';
9
10
  import type {
10
11
  ThemeConfig,
@@ -32,6 +33,7 @@ export const DEFAULT_CONFIG = {
32
33
  metadata: [],
33
34
  prism: {
34
35
  additionalLanguages: [],
36
+ theme: defaultPrismTheme,
35
37
  },
36
38
  navbar: {
37
39
  hideOnScroll: false,
@@ -335,7 +337,7 @@ export const ThemeConfigSchema = Joi.object({
335
337
  theme: Joi.object({
336
338
  plain: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
337
339
  styles: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
338
- }),
340
+ }).default(DEFAULT_CONFIG.prism.theme),
339
341
  darkTheme: Joi.object({
340
342
  plain: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
341
343
  styles: Joi.alternatives().try(Joi.array(), Joi.object()).required(),