@docusaurus/theme-classic 0.0.0-4205 → 0.0.0-4209
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.
- package/lib/index.js +7 -11
- package/lib/theme/BlogPostAuthors/index.js +1 -1
- package/lib/theme/BlogSidebar/index.js +5 -7
- package/lib/theme/DocItemFooter/index.js +1 -1
- package/lib/theme/DocSidebar/index.js +5 -6
- package/lib/theme/DocSidebarItem/index.js +5 -7
- package/lib/theme/DocVersionBanner/index.js +1 -1
- package/lib/theme/Footer/index.js +4 -2
- package/lib/theme/Heading/index.js +11 -14
- package/lib/theme/IconArrow/index.js +2 -2
- package/lib/theme/IconEdit/index.js +3 -3
- package/lib/theme/IconExternalLink/index.js +3 -3
- package/lib/theme/IconLanguage/index.js +3 -3
- package/lib/theme/IconMenu/index.js +3 -3
- package/lib/theme/LayoutHead/index.js +1 -1
- package/lib/theme/Logo/index.js +3 -3
- package/lib/theme/Navbar/index.js +4 -6
- package/lib/theme/ThemeProvider/index.js +8 -3
- package/lib/theme/ThemedImage/index.js +2 -2
- package/lib/theme/Toggle/index.js +12 -8
- package/lib/theme/UserPreferencesProvider/index.js +8 -3
- package/lib/theme/hooks/useTheme.js +1 -3
- package/lib/validateThemeConfig.js +1 -1
- package/lib-next/index.js +8 -8
- package/lib-next/theme/BlogPostAuthors/index.js +1 -1
- package/lib-next/theme/BlogSidebar/index.js +11 -13
- package/lib-next/theme/DocItemFooter/index.js +1 -1
- package/lib-next/theme/DocSidebar/index.js +11 -13
- package/lib-next/theme/DocSidebarItem/index.js +11 -16
- package/lib-next/theme/DocVersionBanner/index.js +1 -1
- package/lib-next/theme/Footer/index.js +11 -9
- package/lib-next/theme/Heading/index.js +16 -17
- package/lib-next/theme/IconArrow/index.js +2 -2
- package/lib-next/theme/IconEdit/index.js +2 -2
- package/lib-next/theme/IconExternalLink/index.js +2 -2
- package/lib-next/theme/IconLanguage/index.js +2 -2
- package/lib-next/theme/IconMenu/index.js +2 -2
- package/lib-next/theme/LayoutHead/index.js +1 -1
- package/lib-next/theme/Logo/index.js +3 -3
- package/lib-next/theme/Navbar/index.js +7 -6
- package/lib-next/theme/ThemeProvider/index.js +10 -7
- package/lib-next/theme/ThemedImage/index.js +2 -2
- package/lib-next/theme/Toggle/index.js +14 -10
- package/lib-next/theme/UserPreferencesProvider/index.js +9 -6
- package/lib-next/theme/hooks/useTheme.js +2 -3
- package/package.json +11 -11
- package/src/index.ts +4 -7
- package/src/theme/BlogPostAuthors/index.tsx +5 -2
- package/src/theme/BlogSidebar/index.tsx +11 -13
- package/src/theme/DocItemFooter/index.tsx +2 -2
- package/src/theme/DocSidebar/index.tsx +11 -12
- package/src/theme/DocSidebarItem/index.tsx +4 -7
- package/src/theme/DocVersionBanner/index.tsx +2 -2
- package/src/theme/Footer/index.tsx +12 -10
- package/src/theme/Heading/index.tsx +16 -19
- package/src/theme/IconArrow/index.tsx +2 -2
- package/src/theme/IconEdit/index.tsx +2 -2
- package/src/theme/IconExternalLink/index.tsx +2 -5
- package/src/theme/IconLanguage/index.tsx +2 -6
- package/src/theme/IconMenu/index.tsx +3 -3
- package/src/theme/LayoutHead/index.tsx +1 -1
- package/src/theme/Logo/index.tsx +3 -3
- package/src/theme/Navbar/index.tsx +7 -6
- package/src/theme/ThemeProvider/index.tsx +6 -2
- package/src/theme/ThemedImage/index.tsx +2 -2
- package/src/theme/Toggle/index.tsx +14 -10
- package/src/theme/UserPreferencesProvider/index.tsx +9 -6
- package/src/theme/hooks/useTheme.ts +2 -3
- package/update-code-translations.js +5 -6
|
@@ -16,23 +16,21 @@ import styles from './styles.module.css';
|
|
|
16
16
|
|
|
17
17
|
type HeadingComponent = (props: Props) => JSX.Element;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
19
|
+
// eslint-disable-next-line react/function-component-definition
|
|
20
|
+
export const MainHeading: HeadingComponent = ({...props}) => (
|
|
21
|
+
<header>
|
|
22
|
+
<h1
|
|
23
|
+
{...props}
|
|
24
|
+
id={undefined} // h1 headings do not need an id because they don't appear in the TOC
|
|
25
|
+
>
|
|
26
|
+
{props.children}
|
|
27
|
+
</h1>
|
|
28
|
+
</header>
|
|
29
|
+
);
|
|
31
30
|
|
|
32
|
-
const createAnchorHeading =
|
|
33
|
-
Tag: HeadingType
|
|
34
|
-
|
|
35
|
-
function TargetComponent({id, ...props}) {
|
|
31
|
+
const createAnchorHeading =
|
|
32
|
+
(Tag: HeadingType) =>
|
|
33
|
+
({id, ...props}: Props) => {
|
|
36
34
|
const {
|
|
37
35
|
navbar: {hideOnScroll},
|
|
38
36
|
} = useThemeConfig();
|
|
@@ -65,8 +63,7 @@ const createAnchorHeading = (
|
|
|
65
63
|
);
|
|
66
64
|
};
|
|
67
65
|
|
|
68
|
-
const Heading = (headingType: HeadingType): ((props: Props) => JSX.Element) =>
|
|
69
|
-
|
|
70
|
-
};
|
|
66
|
+
const Heading = (headingType: HeadingType): ((props: Props) => JSX.Element) =>
|
|
67
|
+
headingType === 'h1' ? MainHeading : createAnchorHeading(headingType);
|
|
71
68
|
|
|
72
69
|
export default Heading;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import type {Props} from '@theme/IconArrow';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
function IconArrow(props: Props): JSX.Element {
|
|
12
12
|
return (
|
|
13
13
|
<svg width="20" height="20" aria-hidden="true" {...props}>
|
|
14
14
|
<g fill="#7a7a7a">
|
|
@@ -17,6 +17,6 @@ const IconArrow = (props: Props): JSX.Element => {
|
|
|
17
17
|
</g>
|
|
18
18
|
</svg>
|
|
19
19
|
);
|
|
20
|
-
}
|
|
20
|
+
}
|
|
21
21
|
|
|
22
22
|
export default IconArrow;
|
|
@@ -12,7 +12,7 @@ import type {Props} from '@theme/IconEdit';
|
|
|
12
12
|
|
|
13
13
|
import styles from './styles.module.css';
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
function IconEdit({className, ...restProps}: Props): JSX.Element {
|
|
16
16
|
return (
|
|
17
17
|
<svg
|
|
18
18
|
fill="currentColor"
|
|
@@ -27,6 +27,6 @@ const IconEdit = ({className, ...restProps}: Props): JSX.Element => {
|
|
|
27
27
|
</g>
|
|
28
28
|
</svg>
|
|
29
29
|
);
|
|
30
|
-
}
|
|
30
|
+
}
|
|
31
31
|
|
|
32
32
|
export default IconEdit;
|
|
@@ -10,10 +10,7 @@ import type {Props} from '@theme/IconExternalLink';
|
|
|
10
10
|
|
|
11
11
|
import styles from './styles.module.css';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
width = 13.5,
|
|
15
|
-
height = 13.5,
|
|
16
|
-
}: Props): JSX.Element => {
|
|
13
|
+
function IconExternalLink({width = 13.5, height = 13.5}: Props): JSX.Element {
|
|
17
14
|
return (
|
|
18
15
|
<svg
|
|
19
16
|
width={width}
|
|
@@ -27,6 +24,6 @@ const IconExternalLink = ({
|
|
|
27
24
|
/>
|
|
28
25
|
</svg>
|
|
29
26
|
);
|
|
30
|
-
}
|
|
27
|
+
}
|
|
31
28
|
|
|
32
29
|
export default IconExternalLink;
|
|
@@ -8,11 +8,7 @@
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import type {Props} from '@theme/IconLanguage';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
width = 20,
|
|
13
|
-
height = 20,
|
|
14
|
-
...props
|
|
15
|
-
}: Props): JSX.Element => {
|
|
11
|
+
function IconLanguage({width = 20, height = 20, ...props}: Props): JSX.Element {
|
|
16
12
|
return (
|
|
17
13
|
<svg
|
|
18
14
|
viewBox="0 0 20 20"
|
|
@@ -26,6 +22,6 @@ const IconLanguage = ({
|
|
|
26
22
|
/>
|
|
27
23
|
</svg>
|
|
28
24
|
);
|
|
29
|
-
}
|
|
25
|
+
}
|
|
30
26
|
|
|
31
27
|
export default IconLanguage;
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import type {Props} from '@theme/IconMenu';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
function IconMenu({
|
|
12
12
|
width = 30,
|
|
13
13
|
height = 30,
|
|
14
14
|
className,
|
|
15
15
|
...restProps
|
|
16
|
-
}: Props): JSX.Element
|
|
16
|
+
}: Props): JSX.Element {
|
|
17
17
|
return (
|
|
18
18
|
<svg
|
|
19
19
|
className={className}
|
|
@@ -31,6 +31,6 @@ const IconMenu = ({
|
|
|
31
31
|
/>
|
|
32
32
|
</svg>
|
|
33
33
|
);
|
|
34
|
-
}
|
|
34
|
+
}
|
|
35
35
|
|
|
36
36
|
export default IconMenu;
|
|
@@ -101,7 +101,7 @@ export default function LayoutHead(props: Props): JSX.Element {
|
|
|
101
101
|
<>
|
|
102
102
|
<Head>
|
|
103
103
|
<html lang={htmlLang} dir={htmlDir} />
|
|
104
|
-
{favicon && <link rel="
|
|
104
|
+
{favicon && <link rel="icon" href={faviconUrl} />}
|
|
105
105
|
<title>{pageTitle}</title>
|
|
106
106
|
<meta property="og:title" content={pageTitle} />
|
|
107
107
|
<meta name="twitter:card" content="summary_large_image" />
|
package/src/theme/Logo/index.tsx
CHANGED
|
@@ -14,7 +14,7 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
|
14
14
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
15
15
|
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
function Logo(props: Props): JSX.Element {
|
|
18
18
|
const {
|
|
19
19
|
siteConfig: {title},
|
|
20
20
|
} = useDocusaurusContext();
|
|
@@ -46,11 +46,11 @@ const Logo = (props: Props): JSX.Element => {
|
|
|
46
46
|
(imageClassName ? (
|
|
47
47
|
<div className={imageClassName}>{themedImage}</div>
|
|
48
48
|
) : (
|
|
49
|
-
|
|
49
|
+
themedImage
|
|
50
50
|
))}
|
|
51
51
|
{navbarTitle != null && <b className={titleClassName}>{navbarTitle}</b>}
|
|
52
52
|
</Link>
|
|
53
53
|
);
|
|
54
|
-
}
|
|
54
|
+
}
|
|
55
55
|
|
|
56
56
|
export default Logo;
|
|
@@ -105,12 +105,13 @@ function useSecondaryMenu({
|
|
|
105
105
|
});
|
|
106
106
|
const previousContent = usePrevious(content);
|
|
107
107
|
|
|
108
|
-
const [shown, setShown] = useState<boolean>(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
const [shown, setShown] = useState<boolean>(
|
|
109
|
+
() =>
|
|
110
|
+
// /!\ content is set with useEffect,
|
|
111
|
+
// so it's not available on mount anyway
|
|
112
|
+
// "return !!content" => always returns false
|
|
113
|
+
false,
|
|
114
|
+
);
|
|
114
115
|
|
|
115
116
|
// When content is become available for the first time (set in useEffect)
|
|
116
117
|
// we set this content to be shown!
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React from 'react';
|
|
8
|
+
import React, {useMemo} from 'react';
|
|
9
9
|
|
|
10
10
|
import useTheme from '@theme/hooks/useTheme';
|
|
11
11
|
import ThemeContext from '@theme/ThemeContext';
|
|
@@ -13,9 +13,13 @@ import type {Props} from '@theme/ThemeProvider';
|
|
|
13
13
|
|
|
14
14
|
function ThemeProvider(props: Props): JSX.Element {
|
|
15
15
|
const {isDarkTheme, setLightTheme, setDarkTheme} = useTheme();
|
|
16
|
+
const contextValue = useMemo(
|
|
17
|
+
() => ({isDarkTheme, setLightTheme, setDarkTheme}),
|
|
18
|
+
[isDarkTheme, setLightTheme, setDarkTheme],
|
|
19
|
+
);
|
|
16
20
|
|
|
17
21
|
return (
|
|
18
|
-
<ThemeContext.Provider value={
|
|
22
|
+
<ThemeContext.Provider value={contextValue}>
|
|
19
23
|
{props.children}
|
|
20
24
|
</ThemeContext.Provider>
|
|
21
25
|
);
|
|
@@ -14,7 +14,7 @@ import type {Props} from '@theme/ThemedImage';
|
|
|
14
14
|
|
|
15
15
|
import styles from './styles.module.css';
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
function ThemedImage(props: Props): JSX.Element {
|
|
18
18
|
const isBrowser = useIsBrowser();
|
|
19
19
|
const {isDarkTheme} = useThemeContext();
|
|
20
20
|
const {sources, className, alt = '', ...propsRest} = props;
|
|
@@ -46,6 +46,6 @@ const ThemedImage = (props: Props): JSX.Element => {
|
|
|
46
46
|
))}
|
|
47
47
|
</>
|
|
48
48
|
);
|
|
49
|
-
}
|
|
49
|
+
}
|
|
50
50
|
|
|
51
51
|
export default ThemedImage;
|
|
@@ -18,16 +18,20 @@ interface IconProps {
|
|
|
18
18
|
style: CSSProperties;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
)
|
|
21
|
+
function Dark({icon, style}: IconProps): JSX.Element {
|
|
22
|
+
return (
|
|
23
|
+
<span className={clsx(styles.toggleIcon, styles.dark)} style={style}>
|
|
24
|
+
{icon}
|
|
25
|
+
</span>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
function Light({icon, style}: IconProps): JSX.Element {
|
|
29
|
+
return (
|
|
30
|
+
<span className={clsx(styles.toggleIcon, styles.light)} style={style}>
|
|
31
|
+
{icon}
|
|
32
|
+
</span>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
31
35
|
|
|
32
36
|
// Based on react-toggle (https://github.com/aaronshaf/react-toggle/).
|
|
33
37
|
const Toggle = memo(
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React from 'react';
|
|
8
|
+
import React, {useMemo} from 'react';
|
|
9
9
|
|
|
10
10
|
import useTabGroupChoice from '@theme/hooks/useTabGroupChoice';
|
|
11
11
|
import UserPreferencesContext from '@theme/UserPreferencesContext';
|
|
@@ -13,12 +13,15 @@ import type {Props} from '@theme/UserPreferencesProvider';
|
|
|
13
13
|
|
|
14
14
|
function UserPreferencesProvider(props: Props): JSX.Element {
|
|
15
15
|
const {tabGroupChoices, setTabGroupChoices} = useTabGroupChoice();
|
|
16
|
+
const contextValue = useMemo(
|
|
17
|
+
() => ({
|
|
18
|
+
tabGroupChoices,
|
|
19
|
+
setTabGroupChoices,
|
|
20
|
+
}),
|
|
21
|
+
[tabGroupChoices, setTabGroupChoices],
|
|
22
|
+
);
|
|
16
23
|
return (
|
|
17
|
-
<UserPreferencesContext.Provider
|
|
18
|
-
value={{
|
|
19
|
-
tabGroupChoices,
|
|
20
|
-
setTabGroupChoices,
|
|
21
|
-
}}>
|
|
24
|
+
<UserPreferencesContext.Provider value={contextValue}>
|
|
22
25
|
{props.children}
|
|
23
26
|
</UserPreferencesContext.Provider>
|
|
24
27
|
);
|
|
@@ -21,9 +21,8 @@ const themes = {
|
|
|
21
21
|
type Themes = typeof themes[keyof typeof themes];
|
|
22
22
|
|
|
23
23
|
// Ensure to always return a valid theme even if input is invalid
|
|
24
|
-
const coerceToTheme = (theme?: string | null): Themes =>
|
|
25
|
-
|
|
26
|
-
};
|
|
24
|
+
const coerceToTheme = (theme?: string | null): Themes =>
|
|
25
|
+
theme === themes.dark ? themes.dark : themes.light;
|
|
27
26
|
|
|
28
27
|
const getInitialTheme = (defaultMode: Themes | undefined): Themes => {
|
|
29
28
|
if (!ExecutionEnvironment.canUseDOM) {
|
|
@@ -80,9 +80,10 @@ ${warning}
|
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
const translations = filesExtractedTranslations.reduce(
|
|
83
|
-
(acc, extractedTranslations) => {
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
(acc, extractedTranslations) => ({
|
|
84
|
+
...acc,
|
|
85
|
+
...extractedTranslations.translations,
|
|
86
|
+
}),
|
|
86
87
|
{},
|
|
87
88
|
);
|
|
88
89
|
|
|
@@ -193,9 +194,7 @@ ${logKeys(unknownMessages)}`),
|
|
|
193
194
|
};
|
|
194
195
|
|
|
195
196
|
const untranslatedKeys = Object.entries(newLocaleFileMessages)
|
|
196
|
-
.filter(([key, value]) =>
|
|
197
|
-
return value === baseFileMessages[key];
|
|
198
|
-
})
|
|
197
|
+
.filter(([key, value]) => value === baseFileMessages[key])
|
|
199
198
|
.map(([key]) => key);
|
|
200
199
|
|
|
201
200
|
if (untranslatedKeys.length) {
|