@docusaurus/theme-classic 2.0.0-beta.1ab8aa0af → 2.0.0-beta.2
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/codeTranslations/ar.json +2 -0
- package/codeTranslations/base.json +4 -0
- package/codeTranslations/bn.json +56 -0
- package/codeTranslations/da.json +2 -0
- package/codeTranslations/de.json +2 -0
- package/codeTranslations/es.json +2 -0
- package/codeTranslations/fa.json +2 -0
- package/codeTranslations/fil.json +2 -0
- package/codeTranslations/fr.json +2 -0
- package/codeTranslations/he.json +18 -16
- package/codeTranslations/hi.json +2 -0
- package/codeTranslations/ja.json +2 -0
- package/codeTranslations/ko.json +2 -0
- package/codeTranslations/pl.json +2 -0
- package/codeTranslations/pt-BR.json +2 -0
- package/codeTranslations/pt-PT.json +2 -0
- package/codeTranslations/ru.json +2 -0
- package/codeTranslations/tr.json +2 -0
- package/codeTranslations/vi.json +2 -0
- package/codeTranslations/zh-Hans.json +2 -0
- package/codeTranslations/zh-Hant.json +2 -0
- package/lib/index.js +28 -7
- package/lib/theme/AnnouncementBar/index.js +5 -7
- package/lib/theme/AnnouncementBar/styles.module.css +6 -6
- package/lib/theme/BlogListPage/index.js +2 -2
- package/lib/theme/BlogListPaginator/index.js +2 -2
- package/lib/theme/BlogPostItem/index.js +32 -23
- package/lib/theme/BlogPostItem/styles.module.css +5 -1
- package/lib/theme/BlogPostPage/index.js +4 -10
- package/lib/theme/BlogPostPaginator/index.js +3 -3
- package/lib/theme/BlogSidebar/index.js +11 -3
- package/lib/theme/BlogSidebar/styles.module.css +4 -6
- package/lib/theme/BlogTagsListPage/index.js +15 -20
- package/lib/theme/BlogTagsPostsPage/index.js +29 -33
- package/lib/theme/CodeBlock/index.js +11 -11
- package/lib/theme/CodeBlock/styles.module.css +4 -7
- package/lib/theme/DocItem/index.js +35 -26
- package/lib/theme/DocItem/styles.module.css +8 -10
- package/lib/theme/DocPage/index.js +43 -11
- package/lib/theme/DocPage/styles.module.css +7 -19
- package/lib/theme/DocPaginator/index.js +3 -3
- package/lib/theme/DocSidebar/index.js +23 -24
- package/lib/theme/DocSidebar/styles.module.css +0 -14
- package/lib/theme/DocVersionBanner/index.js +128 -0
- package/lib/theme/DocVersionSuggestions/index.js +4 -4
- package/lib/theme/Heading/index.js +18 -2
- package/lib/theme/Heading/styles.module.css +5 -0
- package/lib/theme/IconArrow/index.js +1 -1
- package/lib/theme/IconEdit/index.js +1 -1
- package/lib/theme/IconExternalLink/index.js +30 -0
- package/lib/theme/IconExternalLink/styles.module.css +12 -0
- package/lib/theme/IconLanguage/index.js +1 -1
- package/lib/theme/IconMenu/index.js +1 -2
- package/lib/theme/LastUpdated/index.js +17 -21
- package/lib/theme/Layout/styles.css +6 -0
- package/lib/theme/LayoutHead/index.js +3 -1
- package/lib/theme/LayoutProviders/index.js +7 -5
- package/lib/theme/Logo/index.js +13 -12
- package/lib/theme/MDXComponents/index.js +2 -2
- package/lib/theme/MDXPage/index.js +13 -15
- package/{src/theme/LastUpdated → lib/theme/MDXPage}/styles.module.css +2 -2
- package/lib/theme/Navbar/index.js +4 -4
- package/lib/theme/Navbar/styles.module.css +1 -1
- package/lib/theme/NavbarItem/DefaultNavbarItem.js +18 -4
- package/lib/theme/NavbarItem/DocNavbarItem.js +19 -11
- package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +5 -4
- package/lib/theme/NavbarItem/SearchNavbarItem.js +1 -5
- package/lib/theme/NavbarItem/index.js +1 -1
- package/lib/theme/NotFound.js +9 -2
- package/lib/theme/SearchMetadatas/index.js +1 -1
- package/lib/theme/Seo/index.js +0 -1
- package/lib/theme/SkipToContent/index.js +6 -4
- package/lib/theme/SkipToContent/styles.module.css +1 -3
- package/lib/theme/TOC/styles.module.css +1 -1
- package/lib/theme/Tabs/index.js +2 -2
- package/lib/theme/ThemedImage/index.js +2 -1
- package/lib/theme/ThemedImage/styles.module.css +7 -0
- package/lib/theme/Toggle/index.js +12 -24
- package/lib/theme/Toggle/styles.css +103 -0
- package/lib/theme/Toggle/styles.module.css +0 -97
- package/lib/theme/UserPreferencesProvider/index.js +1 -9
- package/lib/theme/hooks/useHideableNavbar.js +2 -2
- package/lib/theme/hooks/useTabGroupChoice.js +2 -4
- package/lib/theme/hooks/useThemeContext.js +1 -1
- package/lib/theme/hooks/useUserPreferencesContext.js +1 -1
- package/lib/types.d.ts +10 -12
- package/lib/validateThemeConfig.js +3 -3
- package/lib-next/index.js +31 -8
- package/lib-next/theme/AnnouncementBar/index.js +5 -9
- package/lib-next/theme/AnnouncementBar/styles.module.css +6 -6
- package/lib-next/theme/BlogListPage/index.js +2 -2
- package/lib-next/theme/BlogPostItem/index.js +41 -24
- package/lib-next/theme/BlogPostItem/styles.module.css +5 -1
- package/lib-next/theme/BlogPostPage/index.js +4 -8
- package/lib-next/theme/BlogPostPaginator/index.js +1 -1
- package/lib-next/theme/BlogSidebar/index.js +12 -3
- package/lib-next/theme/BlogSidebar/styles.module.css +4 -6
- package/lib-next/theme/BlogTagsListPage/index.js +17 -23
- package/lib-next/theme/BlogTagsPostsPage/index.js +36 -40
- package/lib-next/theme/CodeBlock/index.js +10 -9
- package/lib-next/theme/CodeBlock/styles.module.css +4 -7
- package/lib-next/theme/DocItem/index.js +41 -41
- package/lib-next/theme/DocItem/styles.module.css +8 -10
- package/lib-next/theme/DocPage/index.js +36 -9
- package/lib-next/theme/DocPage/styles.module.css +7 -19
- package/lib-next/theme/DocPaginator/index.js +1 -1
- package/lib-next/theme/DocSidebar/index.js +28 -21
- package/lib-next/theme/DocSidebar/styles.module.css +0 -14
- package/lib-next/theme/DocVersionBanner/index.js +127 -0
- package/lib-next/theme/DocVersionSuggestions/index.js +4 -4
- package/lib-next/theme/Heading/index.js +17 -1
- package/lib-next/theme/Heading/styles.module.css +5 -0
- package/lib-next/theme/IconArrow/index.js +1 -1
- package/lib-next/theme/IconEdit/index.js +3 -5
- package/lib-next/theme/IconExternalLink/index.js +26 -0
- package/{lib/theme/NavbarItem → lib-next/theme/IconExternalLink}/styles.module.css +4 -5
- package/lib-next/theme/IconLanguage/index.js +1 -1
- package/lib-next/theme/IconMenu/index.js +1 -4
- package/lib-next/theme/LastUpdated/index.js +34 -39
- package/lib-next/theme/Layout/styles.css +6 -0
- package/lib-next/theme/LayoutHead/index.js +5 -1
- package/lib-next/theme/LayoutProviders/index.js +11 -6
- package/lib-next/theme/Logo/index.js +12 -8
- package/lib-next/theme/MDXPage/index.js +13 -17
- package/lib-next/theme/{LastUpdated → MDXPage}/styles.module.css +2 -2
- package/lib-next/theme/Navbar/index.js +2 -2
- package/lib-next/theme/Navbar/styles.module.css +1 -1
- package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +19 -2
- package/lib-next/theme/NavbarItem/DocNavbarItem.js +23 -9
- package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +6 -6
- package/lib-next/theme/NavbarItem/SearchNavbarItem.js +1 -6
- package/lib-next/theme/NavbarItem/index.js +1 -1
- package/lib-next/theme/NotFound.js +6 -2
- package/lib-next/theme/SearchMetadatas/index.js +1 -1
- package/lib-next/theme/Seo/index.js +0 -1
- package/lib-next/theme/SkipToContent/index.js +3 -3
- package/lib-next/theme/SkipToContent/styles.module.css +1 -3
- package/lib-next/theme/TOC/styles.module.css +1 -1
- package/lib-next/theme/ThemedImage/index.js +2 -3
- package/lib-next/theme/ThemedImage/styles.module.css +7 -0
- package/lib-next/theme/Toggle/index.js +9 -24
- package/lib-next/theme/Toggle/styles.css +103 -0
- package/lib-next/theme/Toggle/styles.module.css +0 -97
- package/lib-next/theme/UserPreferencesProvider/index.js +0 -4
- package/lib-next/theme/hooks/useHideableNavbar.js +3 -3
- package/lib-next/theme/hooks/useTabGroupChoice.js +2 -4
- package/lib-next/theme/hooks/useThemeContext.js +1 -1
- package/lib-next/theme/hooks/useUserPreferencesContext.js +1 -1
- package/lib-next/types.d.ts +10 -12
- package/lib-next/validateThemeConfig.js +3 -3
- package/package.json +18 -17
- package/src/index.ts +32 -8
- package/src/theme/AnnouncementBar/index.tsx +6 -9
- package/src/theme/AnnouncementBar/styles.module.css +6 -6
- package/src/theme/BlogListPage/index.tsx +2 -2
- package/src/theme/BlogPostItem/index.tsx +40 -24
- package/src/theme/BlogPostItem/styles.module.css +5 -1
- package/src/theme/BlogPostPage/index.tsx +4 -8
- package/src/theme/BlogPostPaginator/index.tsx +1 -1
- package/src/theme/BlogSidebar/index.tsx +12 -3
- package/src/theme/BlogSidebar/styles.module.css +4 -6
- package/src/theme/BlogTagsListPage/index.tsx +17 -22
- package/src/theme/BlogTagsPostsPage/index.tsx +33 -43
- package/src/theme/CodeBlock/index.tsx +10 -9
- package/src/theme/CodeBlock/styles.module.css +4 -7
- package/src/theme/DocItem/index.tsx +40 -40
- package/src/theme/DocItem/styles.module.css +8 -10
- package/src/theme/DocPage/index.tsx +29 -9
- package/src/theme/DocPage/styles.module.css +7 -19
- package/src/theme/DocPaginator/index.tsx +1 -1
- package/src/theme/DocSidebar/index.tsx +28 -21
- package/src/theme/DocSidebar/styles.module.css +0 -14
- package/src/theme/{DocVersionSuggestions → DocVersionBanner}/index.tsx +46 -43
- package/src/theme/Heading/index.tsx +22 -1
- package/src/theme/Heading/styles.module.css +5 -0
- package/src/theme/IconArrow/index.tsx +1 -1
- package/src/theme/IconEdit/index.tsx +3 -5
- package/src/theme/IconExternalLink/index.tsx +32 -0
- package/src/theme/IconExternalLink/styles.module.css +12 -0
- package/src/theme/IconLanguage/index.tsx +1 -1
- package/src/theme/IconMenu/index.tsx +1 -4
- package/src/theme/LastUpdated/index.tsx +34 -39
- package/src/theme/Layout/styles.css +6 -0
- package/src/theme/LayoutHead/index.tsx +5 -1
- package/src/theme/LayoutProviders/index.tsx +11 -6
- package/src/theme/Logo/index.tsx +10 -6
- package/src/theme/MDXPage/index.tsx +14 -17
- package/{lib/theme/LastUpdated → src/theme/MDXPage}/styles.module.css +2 -2
- package/src/theme/Navbar/index.tsx +2 -2
- package/src/theme/Navbar/styles.module.css +1 -1
- package/src/theme/NavbarItem/DefaultNavbarItem.tsx +15 -2
- package/src/theme/NavbarItem/DocNavbarItem.tsx +29 -10
- package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +7 -6
- package/src/theme/NavbarItem/SearchNavbarItem.tsx +1 -6
- package/src/theme/NavbarItem/index.tsx +1 -1
- package/src/theme/NotFound.tsx +6 -2
- package/src/theme/SearchMetadatas/index.tsx +1 -1
- package/src/theme/Seo/index.tsx +0 -1
- package/src/theme/SkipToContent/index.tsx +3 -3
- package/src/theme/SkipToContent/styles.module.css +1 -3
- package/src/theme/TOC/styles.module.css +1 -1
- package/src/theme/ThemedImage/index.tsx +3 -3
- package/src/theme/ThemedImage/styles.module.css +7 -0
- package/src/theme/Toggle/index.tsx +9 -22
- package/src/theme/Toggle/styles.css +103 -0
- package/src/theme/Toggle/styles.module.css +0 -97
- package/src/theme/UserPreferencesProvider/index.tsx +0 -5
- package/src/theme/hooks/useHideableNavbar.ts +3 -3
- package/src/theme/hooks/useTabGroupChoice.ts +2 -2
- package/src/theme/hooks/useThemeContext.ts +1 -1
- package/src/theme/hooks/useUserPreferencesContext.ts +1 -1
- package/src/types.d.ts +10 -12
- package/src/validateThemeConfig.js +3 -3
- package/update-code-translations.js +1 -0
- package/lib-next/theme/NavbarItem/styles.module.css +0 -13
- package/src/theme/NavbarItem/styles.module.css +0 -13
- package/src/theme/hooks/useAnnouncementBar.ts +0 -58
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* Styles for React Toggle
|
|
10
|
+
* copied over because we want to allow user to swizzle it and modify the css
|
|
11
|
+
* and also to make sure its compatible with our dark mode
|
|
12
|
+
* https://github.com/aaronshaf/react-toggle/blob/master/style.css
|
|
13
|
+
*/
|
|
14
|
+
.react-toggle {
|
|
15
|
+
touch-action: pan-x;
|
|
16
|
+
position: relative;
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
user-select: none;
|
|
19
|
+
-webkit-tap-highlight-color: transparent;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.react-toggle-screenreader-only {
|
|
23
|
+
border: 0;
|
|
24
|
+
clip: rect(0 0 0 0);
|
|
25
|
+
height: 1px;
|
|
26
|
+
margin: -1px;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
position: absolute;
|
|
29
|
+
width: 1px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.react-toggle--disabled {
|
|
33
|
+
cursor: not-allowed;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.react-toggle-track {
|
|
37
|
+
width: 50px;
|
|
38
|
+
height: 24px;
|
|
39
|
+
border-radius: 30px;
|
|
40
|
+
background-color: #4d4d4d;
|
|
41
|
+
transition: all 0.2s ease;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.react-toggle-track-check {
|
|
45
|
+
position: absolute;
|
|
46
|
+
width: 14px;
|
|
47
|
+
height: 10px;
|
|
48
|
+
top: 0px;
|
|
49
|
+
bottom: 0px;
|
|
50
|
+
margin: auto 0;
|
|
51
|
+
left: 8px;
|
|
52
|
+
opacity: 0;
|
|
53
|
+
transition: opacity 0.25s ease;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
[data-theme='dark'] .react-toggle .react-toggle-track-check,
|
|
57
|
+
.react-toggle--checked .react-toggle-track-check {
|
|
58
|
+
opacity: 1;
|
|
59
|
+
transition: opacity 0.25s ease;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.react-toggle-track-x {
|
|
63
|
+
position: absolute;
|
|
64
|
+
width: 10px;
|
|
65
|
+
height: 10px;
|
|
66
|
+
top: 0px;
|
|
67
|
+
bottom: 0px;
|
|
68
|
+
margin: auto 0;
|
|
69
|
+
right: 10px;
|
|
70
|
+
opacity: 1;
|
|
71
|
+
transition: opacity 0.25s ease;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
[data-theme='dark'] .react-toggle .react-toggle-track-x,
|
|
75
|
+
.react-toggle--checked .react-toggle-track-x {
|
|
76
|
+
opacity: 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.react-toggle-thumb {
|
|
80
|
+
position: absolute;
|
|
81
|
+
top: 1px;
|
|
82
|
+
left: 1px;
|
|
83
|
+
width: 22px;
|
|
84
|
+
height: 22px;
|
|
85
|
+
border: 1px solid #4d4d4d;
|
|
86
|
+
border-radius: 50%;
|
|
87
|
+
background-color: #fafafa;
|
|
88
|
+
transition: all 0.25s ease;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
[data-theme='dark'] .react-toggle .react-toggle-thumb,
|
|
92
|
+
.react-toggle--checked .react-toggle-thumb {
|
|
93
|
+
left: 27px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.react-toggle--focus .react-toggle-thumb,
|
|
97
|
+
.react-toggle:hover .react-toggle-thumb {
|
|
98
|
+
box-shadow: 0px 0px 2px 3px var(--ifm-color-primary);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.react-toggle:active:not(.react-toggle--disabled) .react-toggle-thumb {
|
|
102
|
+
box-shadow: 0px 0px 5px 5px var(--ifm-color-primary);
|
|
103
|
+
}
|
|
@@ -15,100 +15,3 @@
|
|
|
15
15
|
.toggle::before {
|
|
16
16
|
position: absolute;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* styles for React Toggle
|
|
21
|
-
* copied over because we want to allow user to swizzle it and modify the css
|
|
22
|
-
* and also to make sure its compatible with our dark mode
|
|
23
|
-
* https://github.com/aaronshaf/react-toggle/blob/master/style.css
|
|
24
|
-
*/
|
|
25
|
-
:global(.react-toggle) {
|
|
26
|
-
touch-action: pan-x;
|
|
27
|
-
position: relative;
|
|
28
|
-
cursor: pointer;
|
|
29
|
-
user-select: none;
|
|
30
|
-
-webkit-tap-highlight-color: transparent;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
:global(.react-toggle-screenreader-only) {
|
|
34
|
-
border: 0;
|
|
35
|
-
clip: rect(0 0 0 0);
|
|
36
|
-
height: 1px;
|
|
37
|
-
margin: -1px;
|
|
38
|
-
overflow: hidden;
|
|
39
|
-
position: absolute;
|
|
40
|
-
width: 1px;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
:global(.react-toggle--disabled) {
|
|
44
|
-
cursor: not-allowed;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
:global(.react-toggle-track) {
|
|
48
|
-
width: 50px;
|
|
49
|
-
height: 24px;
|
|
50
|
-
border-radius: 30px;
|
|
51
|
-
background-color: #4d4d4d;
|
|
52
|
-
transition: all 0.2s ease;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
:global(.react-toggle-track-check) {
|
|
56
|
-
position: absolute;
|
|
57
|
-
width: 14px;
|
|
58
|
-
height: 10px;
|
|
59
|
-
top: 0px;
|
|
60
|
-
bottom: 0px;
|
|
61
|
-
margin: auto 0;
|
|
62
|
-
left: 8px;
|
|
63
|
-
opacity: 0;
|
|
64
|
-
transition: opacity 0.25s ease;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
:global([data-theme='dark'] .react-toggle .react-toggle-track-check),
|
|
68
|
-
:global(.react-toggle--checked .react-toggle-track-check) {
|
|
69
|
-
opacity: 1;
|
|
70
|
-
transition: opacity 0.25s ease;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
:global(.react-toggle-track-x) {
|
|
74
|
-
position: absolute;
|
|
75
|
-
width: 10px;
|
|
76
|
-
height: 10px;
|
|
77
|
-
top: 0px;
|
|
78
|
-
bottom: 0px;
|
|
79
|
-
margin: auto 0;
|
|
80
|
-
right: 10px;
|
|
81
|
-
opacity: 1;
|
|
82
|
-
transition: opacity 0.25s ease;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
:global([data-theme='dark'] .react-toggle .react-toggle-track-x),
|
|
86
|
-
:global(.react-toggle--checked .react-toggle-track-x) {
|
|
87
|
-
opacity: 0;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
:global(.react-toggle-thumb) {
|
|
91
|
-
position: absolute;
|
|
92
|
-
top: 1px;
|
|
93
|
-
left: 1px;
|
|
94
|
-
width: 22px;
|
|
95
|
-
height: 22px;
|
|
96
|
-
border: 1px solid #4d4d4d;
|
|
97
|
-
border-radius: 50%;
|
|
98
|
-
background-color: #fafafa;
|
|
99
|
-
transition: all 0.25s ease;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
:global([data-theme='dark'] .react-toggle .react-toggle-thumb),
|
|
103
|
-
:global(.react-toggle--checked .react-toggle-thumb) {
|
|
104
|
-
left: 27px;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
:global(.react-toggle--focus .react-toggle-thumb),
|
|
108
|
-
:global(.react-toggle:hover .react-toggle-thumb) {
|
|
109
|
-
box-shadow: 0px 0px 2px 3px var(--ifm-color-primary);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
:global(.react-toggle:active:not(.react-toggle--disabled) .react-toggle-thumb) {
|
|
113
|
-
box-shadow: 0px 0px 5px 5px var(--ifm-color-primary);
|
|
114
|
-
}
|
|
@@ -6,19 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import useTabGroupChoice from '@theme/hooks/useTabGroupChoice';
|
|
9
|
-
import useAnnouncementBar from '@theme/hooks/useAnnouncementBar';
|
|
10
9
|
import UserPreferencesContext from '@theme/UserPreferencesContext';
|
|
11
10
|
|
|
12
11
|
function UserPreferencesProvider(props) {
|
|
13
12
|
const {tabGroupChoices, setTabGroupChoices} = useTabGroupChoice();
|
|
14
|
-
const {isAnnouncementBarClosed, closeAnnouncementBar} = useAnnouncementBar();
|
|
15
13
|
return (
|
|
16
14
|
<UserPreferencesContext.Provider
|
|
17
15
|
value={{
|
|
18
16
|
tabGroupChoices,
|
|
19
17
|
setTabGroupChoices,
|
|
20
|
-
isAnnouncementBarClosed,
|
|
21
|
-
closeAnnouncementBar,
|
|
22
18
|
}}>
|
|
23
19
|
{props.children}
|
|
24
20
|
</UserPreferencesContext.Provider>
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import {useState, useCallback, useEffect, useRef} from 'react';
|
|
8
8
|
import {useLocation} from '@docusaurus/router';
|
|
9
9
|
import useScrollPosition from '@theme/hooks/useScrollPosition';
|
|
10
|
-
import {
|
|
10
|
+
import {useLocationChange} from '@docusaurus/theme-common';
|
|
11
11
|
|
|
12
12
|
const useHideableNavbar = (hideOnScroll) => {
|
|
13
13
|
const location = useLocation();
|
|
@@ -52,8 +52,8 @@ const useHideableNavbar = (hideOnScroll) => {
|
|
|
52
52
|
},
|
|
53
53
|
[navbarHeight, isFocusedAnchor],
|
|
54
54
|
);
|
|
55
|
-
|
|
56
|
-
if (!hideOnScroll) {
|
|
55
|
+
useLocationChange((locationChangeEvent) => {
|
|
56
|
+
if (!hideOnScroll || locationChangeEvent.location.hash) {
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -16,14 +16,12 @@ const useTabGroupChoice = () => {
|
|
|
16
16
|
useEffect(() => {
|
|
17
17
|
try {
|
|
18
18
|
const localStorageChoices = {};
|
|
19
|
-
|
|
20
|
-
for (const storageKey of listStorageKeys()) {
|
|
19
|
+
listStorageKeys().forEach((storageKey) => {
|
|
21
20
|
if (storageKey.startsWith(TAB_CHOICE_PREFIX)) {
|
|
22
21
|
const groupId = storageKey.substring(TAB_CHOICE_PREFIX.length);
|
|
23
22
|
localStorageChoices[groupId] = createStorageSlot(storageKey).get();
|
|
24
23
|
}
|
|
25
|
-
}
|
|
26
|
-
|
|
24
|
+
});
|
|
27
25
|
setChoices(localStorageChoices);
|
|
28
26
|
} catch (err) {
|
|
29
27
|
console.error(err);
|
|
@@ -12,7 +12,7 @@ function useThemeContext() {
|
|
|
12
12
|
|
|
13
13
|
if (context == null) {
|
|
14
14
|
throw new Error(
|
|
15
|
-
'
|
|
15
|
+
'"useThemeContext" is used outside of "Layout" component. Please see https://docusaurus.io/docs/api/themes/configuration#usethemecontext.',
|
|
16
16
|
);
|
|
17
17
|
}
|
|
18
18
|
|
package/lib-next/types.d.ts
CHANGED
|
@@ -114,16 +114,7 @@ declare module '@theme/Heading' {
|
|
|
114
114
|
|
|
115
115
|
const Heading: (Tag: HeadingType) => (props: Props) => JSX.Element;
|
|
116
116
|
export default Heading;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
declare module '@theme/hooks/useAnnouncementBar' {
|
|
120
|
-
export type useAnnouncementBarReturns = {
|
|
121
|
-
readonly isAnnouncementBarClosed: boolean;
|
|
122
|
-
readonly closeAnnouncementBar: () => void;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const useAnnouncementBar: () => useAnnouncementBarReturns;
|
|
126
|
-
export default useAnnouncementBar;
|
|
117
|
+
export const MainHeading: (props: Props) => JSX.Element;
|
|
127
118
|
}
|
|
128
119
|
|
|
129
120
|
declare module '@theme/hooks/useHideableNavbar' {
|
|
@@ -213,8 +204,6 @@ declare module '@theme/hooks/useUserPreferencesContext' {
|
|
|
213
204
|
export type UserPreferencesContextProps = {
|
|
214
205
|
tabGroupChoices: {readonly [groupId: string]: string};
|
|
215
206
|
setTabGroupChoices: (groupId: string, newChoice: string) => void;
|
|
216
|
-
isAnnouncementBarClosed: boolean;
|
|
217
|
-
closeAnnouncementBar: () => void;
|
|
218
207
|
};
|
|
219
208
|
|
|
220
209
|
export default function useUserPreferencesContext(): UserPreferencesContextProps;
|
|
@@ -598,3 +587,12 @@ declare module '@theme/IconLanguage' {
|
|
|
598
587
|
const IconLanguage: (props: Props) => JSX.Element;
|
|
599
588
|
export default IconLanguage;
|
|
600
589
|
}
|
|
590
|
+
|
|
591
|
+
declare module '@theme/IconExternalLink' {
|
|
592
|
+
import type {ComponentProps} from 'react';
|
|
593
|
+
|
|
594
|
+
export type Props = ComponentProps<'svg'>;
|
|
595
|
+
|
|
596
|
+
const IconExternalLink: (props: Props) => JSX.Element;
|
|
597
|
+
export default IconExternalLink;
|
|
598
|
+
}
|
|
@@ -50,7 +50,7 @@ const BaseNavbarItemSchema = Joi.object({
|
|
|
50
50
|
href: URISchema,
|
|
51
51
|
label: Joi.string(),
|
|
52
52
|
className: Joi.string(),
|
|
53
|
-
prependBaseUrlToHref: Joi.
|
|
53
|
+
prependBaseUrlToHref: Joi.bool(),
|
|
54
54
|
})
|
|
55
55
|
// We allow any unknown attributes on the links
|
|
56
56
|
// (users may need additional attributes like target, aria-role, data-customAttribute...)
|
|
@@ -250,8 +250,8 @@ const ThemeConfigSchema = Joi.object({
|
|
|
250
250
|
announcementBar: Joi.object({
|
|
251
251
|
id: Joi.string().default('announcement-bar'),
|
|
252
252
|
content: Joi.string(),
|
|
253
|
-
backgroundColor: Joi.string()
|
|
254
|
-
textColor: Joi.string()
|
|
253
|
+
backgroundColor: Joi.string(),
|
|
254
|
+
textColor: Joi.string(),
|
|
255
255
|
isCloseable: Joi.bool().default(true),
|
|
256
256
|
}).optional(),
|
|
257
257
|
navbar: Joi.object({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.2",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/types.d.ts",
|
|
@@ -23,33 +23,34 @@
|
|
|
23
23
|
"update-code-translations": "node -e 'require(\"./update-code-translations.js\").run()'"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@docusaurus/core": "2.0.0-beta.
|
|
27
|
-
"@docusaurus/plugin-content-blog": "2.0.0-beta.
|
|
28
|
-
"@docusaurus/plugin-content-docs": "2.0.0-beta.
|
|
29
|
-
"@docusaurus/plugin-content-pages": "2.0.0-beta.
|
|
30
|
-
"@docusaurus/theme-common": "2.0.0-beta.
|
|
31
|
-
"@docusaurus/types": "2.0.0-beta.
|
|
32
|
-
"@docusaurus/utils": "2.0.0-beta.
|
|
33
|
-
"@docusaurus/utils-
|
|
26
|
+
"@docusaurus/core": "2.0.0-beta.2",
|
|
27
|
+
"@docusaurus/plugin-content-blog": "2.0.0-beta.2",
|
|
28
|
+
"@docusaurus/plugin-content-docs": "2.0.0-beta.2",
|
|
29
|
+
"@docusaurus/plugin-content-pages": "2.0.0-beta.2",
|
|
30
|
+
"@docusaurus/theme-common": "2.0.0-beta.2",
|
|
31
|
+
"@docusaurus/types": "2.0.0-beta.2",
|
|
32
|
+
"@docusaurus/utils": "2.0.0-beta.2",
|
|
33
|
+
"@docusaurus/utils-common": "2.0.0-beta.2",
|
|
34
|
+
"@docusaurus/utils-validation": "2.0.0-beta.2",
|
|
34
35
|
"@mdx-js/mdx": "^1.6.21",
|
|
35
36
|
"@mdx-js/react": "^1.6.21",
|
|
36
|
-
"chalk": "^4.1.
|
|
37
|
+
"chalk": "^4.1.1",
|
|
37
38
|
"clsx": "^1.1.1",
|
|
38
|
-
"copy-text-to-clipboard": "^3.0.
|
|
39
|
-
"fs-extra": "^
|
|
39
|
+
"copy-text-to-clipboard": "^3.0.1",
|
|
40
|
+
"fs-extra": "^10.0.0",
|
|
40
41
|
"globby": "^11.0.2",
|
|
41
|
-
"infima": "0.2.0-alpha.
|
|
42
|
+
"infima": "0.2.0-alpha.26",
|
|
42
43
|
"lodash": "^4.17.20",
|
|
43
44
|
"parse-numeric-range": "^1.2.0",
|
|
44
|
-
"postcss": "^8.2.
|
|
45
|
-
"prism-react-renderer": "^1.
|
|
45
|
+
"postcss": "^8.2.15",
|
|
46
|
+
"prism-react-renderer": "^1.2.1",
|
|
46
47
|
"prismjs": "^1.23.0",
|
|
47
48
|
"prop-types": "^15.7.2",
|
|
48
49
|
"react-router-dom": "^5.2.0",
|
|
49
50
|
"rtlcss": "^3.1.2"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
|
-
"@docusaurus/module-type-aliases": "2.0.0-beta.
|
|
53
|
+
"@docusaurus/module-type-aliases": "2.0.0-beta.2"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
55
56
|
"react": "^16.8.4 || ^17.0.0",
|
|
@@ -58,5 +59,5 @@
|
|
|
58
59
|
"engines": {
|
|
59
60
|
"node": ">=12.13.0"
|
|
60
61
|
},
|
|
61
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "883f07fddffaf1657407c8e202e370cc436e25f7"
|
|
62
63
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import {DocusaurusContext, Plugin} from '@docusaurus/types';
|
|
9
|
-
import {ThemeConfig} from '@docusaurus/theme-common';
|
|
9
|
+
import type {ThemeConfig} from '@docusaurus/theme-common';
|
|
10
10
|
import {getTranslationFiles, translateThemeConfig} from './translations';
|
|
11
11
|
import path from 'path';
|
|
12
12
|
import Module from 'module';
|
|
@@ -24,7 +24,7 @@ const ContextReplacementPlugin = requireFromDocusaurusCore(
|
|
|
24
24
|
|
|
25
25
|
// Need to be inlined to prevent dark mode FOUC
|
|
26
26
|
// Make sure that the 'storageKey' is the same as the one in `/theme/hooks/useTheme.js`
|
|
27
|
-
const
|
|
27
|
+
const ThemeStorageKey = 'theme';
|
|
28
28
|
const noFlashColorMode = ({defaultMode, respectPrefersColorScheme}) => {
|
|
29
29
|
return `(function() {
|
|
30
30
|
var defaultMode = '${defaultMode}';
|
|
@@ -37,7 +37,7 @@ const noFlashColorMode = ({defaultMode, respectPrefersColorScheme}) => {
|
|
|
37
37
|
function getStoredTheme() {
|
|
38
38
|
var theme = null;
|
|
39
39
|
try {
|
|
40
|
-
theme = localStorage.getItem('${
|
|
40
|
+
theme = localStorage.getItem('${ThemeStorageKey}');
|
|
41
41
|
} catch (err) {}
|
|
42
42
|
return theme;
|
|
43
43
|
}
|
|
@@ -63,6 +63,26 @@ const noFlashColorMode = ({defaultMode, respectPrefersColorScheme}) => {
|
|
|
63
63
|
})();`;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
+
// Duplicated constant. Unfortunately we can't import it from theme-common, as we need to support older nodejs versions without ESM support
|
|
67
|
+
// TODO: import from theme-common once we only support Node.js with ESM support
|
|
68
|
+
// + move all those announcementBar stuff there too
|
|
69
|
+
export const AnnouncementBarDismissStorageKey =
|
|
70
|
+
'docusaurus.announcement.dismiss';
|
|
71
|
+
const AnnouncementBarDismissDataAttribute =
|
|
72
|
+
'data-announcement-bar-initially-dismissed';
|
|
73
|
+
// We always render the announcement bar html on the server, to prevent layout shifts on React hydration
|
|
74
|
+
// The theme can use CSS + the data attribute to hide the announcement bar asap (before React hydration)
|
|
75
|
+
const AnnouncementBarInlineJavaScript = `
|
|
76
|
+
(function() {
|
|
77
|
+
function isDismissed() {
|
|
78
|
+
try {
|
|
79
|
+
return localStorage.getItem('${AnnouncementBarDismissStorageKey}') === 'true';
|
|
80
|
+
} catch (err) {}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
document.documentElement.setAttribute('${AnnouncementBarDismissDataAttribute}', isDismissed());
|
|
84
|
+
})();`;
|
|
85
|
+
|
|
66
86
|
function getInfimaCSSFile(direction) {
|
|
67
87
|
return `infima/dist/css/default/default${
|
|
68
88
|
direction === 'rtl' ? '-rtl' : ''
|
|
@@ -82,7 +102,11 @@ export default function docusaurusThemeClassic(
|
|
|
82
102
|
i18n: {currentLocale, localeConfigs},
|
|
83
103
|
} = context;
|
|
84
104
|
const themeConfig = (roughlyTypedThemeConfig || {}) as ThemeConfig;
|
|
85
|
-
const {
|
|
105
|
+
const {
|
|
106
|
+
announcementBar,
|
|
107
|
+
colorMode,
|
|
108
|
+
prism: {additionalLanguages = []} = {},
|
|
109
|
+
} = themeConfig;
|
|
86
110
|
const {customCss} = options || {};
|
|
87
111
|
const {direction} = localeConfigs[currentLocale];
|
|
88
112
|
|
|
@@ -178,10 +202,10 @@ export default function docusaurusThemeClassic(
|
|
|
178
202
|
preBodyTags: [
|
|
179
203
|
{
|
|
180
204
|
tagName: 'script',
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
205
|
+
innerHTML: `
|
|
206
|
+
${noFlashColorMode(colorMode)}
|
|
207
|
+
${announcementBar ? AnnouncementBarInlineJavaScript : ''}
|
|
208
|
+
`,
|
|
185
209
|
},
|
|
186
210
|
],
|
|
187
211
|
};
|
|
@@ -7,17 +7,13 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
|
-
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
11
|
-
import useUserPreferencesContext from '@theme/hooks/useUserPreferencesContext';
|
|
10
|
+
import {useThemeConfig, useAnnouncementBar} from '@docusaurus/theme-common';
|
|
12
11
|
import {translate} from '@docusaurus/Translate';
|
|
13
12
|
|
|
14
13
|
import styles from './styles.module.css';
|
|
15
14
|
|
|
16
15
|
function AnnouncementBar(): JSX.Element | null {
|
|
17
|
-
const {
|
|
18
|
-
isAnnouncementBarClosed,
|
|
19
|
-
closeAnnouncementBar,
|
|
20
|
-
} = useUserPreferencesContext();
|
|
16
|
+
const {isClosed, close} = useAnnouncementBar();
|
|
21
17
|
const {announcementBar} = useThemeConfig();
|
|
22
18
|
|
|
23
19
|
if (!announcementBar) {
|
|
@@ -25,7 +21,8 @@ function AnnouncementBar(): JSX.Element | null {
|
|
|
25
21
|
}
|
|
26
22
|
|
|
27
23
|
const {content, backgroundColor, textColor, isCloseable} = announcementBar;
|
|
28
|
-
|
|
24
|
+
|
|
25
|
+
if (!content || (isCloseable && isClosed)) {
|
|
29
26
|
return null;
|
|
30
27
|
}
|
|
31
28
|
|
|
@@ -45,8 +42,8 @@ function AnnouncementBar(): JSX.Element | null {
|
|
|
45
42
|
{isCloseable ? (
|
|
46
43
|
<button
|
|
47
44
|
type="button"
|
|
48
|
-
className={styles.announcementBarClose}
|
|
49
|
-
onClick={
|
|
45
|
+
className={clsx(styles.announcementBarClose, 'clean-btn')}
|
|
46
|
+
onClick={close}
|
|
50
47
|
aria-label={translate({
|
|
51
48
|
id: 'theme.AnnouncementBar.closeButtonAriaLabel',
|
|
52
49
|
message: 'Close',
|
|
@@ -13,8 +13,13 @@
|
|
|
13
13
|
position: relative;
|
|
14
14
|
width: 100%;
|
|
15
15
|
height: var(--docusaurus-announcement-bar-height);
|
|
16
|
-
background-color: var(--ifm-color-
|
|
16
|
+
background-color: var(--ifm-color-white);
|
|
17
17
|
color: var(--ifm-color-black);
|
|
18
|
+
border-bottom: 1px solid var(--ifm-color-emphasis-100);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
html[data-announcement-bar-initially-dismissed='true'] .announcementBar {
|
|
22
|
+
display: none;
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
@media print {
|
|
@@ -35,11 +40,6 @@
|
|
|
35
40
|
top: 0;
|
|
36
41
|
width: 55px;
|
|
37
42
|
font-size: 1.25rem;
|
|
38
|
-
padding: 0;
|
|
39
|
-
border: none;
|
|
40
|
-
cursor: pointer;
|
|
41
|
-
background: none;
|
|
42
|
-
color: inherit;
|
|
43
43
|
height: 100%;
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -35,9 +35,9 @@ function BlogListPage(props: Props): JSX.Element {
|
|
|
35
35
|
}}>
|
|
36
36
|
<div className="container margin-vert--lg">
|
|
37
37
|
<div className="row">
|
|
38
|
-
<
|
|
38
|
+
<aside className="col col--3">
|
|
39
39
|
<BlogSidebar sidebar={sidebar} />
|
|
40
|
-
</
|
|
40
|
+
</aside>
|
|
41
41
|
<main className="col col--7">
|
|
42
42
|
{items.map(({content: BlogPostContent}) => (
|
|
43
43
|
<BlogPostItem
|