@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.
Files changed (217) hide show
  1. package/codeTranslations/ar.json +2 -0
  2. package/codeTranslations/base.json +4 -0
  3. package/codeTranslations/bn.json +56 -0
  4. package/codeTranslations/da.json +2 -0
  5. package/codeTranslations/de.json +2 -0
  6. package/codeTranslations/es.json +2 -0
  7. package/codeTranslations/fa.json +2 -0
  8. package/codeTranslations/fil.json +2 -0
  9. package/codeTranslations/fr.json +2 -0
  10. package/codeTranslations/he.json +18 -16
  11. package/codeTranslations/hi.json +2 -0
  12. package/codeTranslations/ja.json +2 -0
  13. package/codeTranslations/ko.json +2 -0
  14. package/codeTranslations/pl.json +2 -0
  15. package/codeTranslations/pt-BR.json +2 -0
  16. package/codeTranslations/pt-PT.json +2 -0
  17. package/codeTranslations/ru.json +2 -0
  18. package/codeTranslations/tr.json +2 -0
  19. package/codeTranslations/vi.json +2 -0
  20. package/codeTranslations/zh-Hans.json +2 -0
  21. package/codeTranslations/zh-Hant.json +2 -0
  22. package/lib/index.js +28 -7
  23. package/lib/theme/AnnouncementBar/index.js +5 -7
  24. package/lib/theme/AnnouncementBar/styles.module.css +6 -6
  25. package/lib/theme/BlogListPage/index.js +2 -2
  26. package/lib/theme/BlogListPaginator/index.js +2 -2
  27. package/lib/theme/BlogPostItem/index.js +32 -23
  28. package/lib/theme/BlogPostItem/styles.module.css +5 -1
  29. package/lib/theme/BlogPostPage/index.js +4 -10
  30. package/lib/theme/BlogPostPaginator/index.js +3 -3
  31. package/lib/theme/BlogSidebar/index.js +11 -3
  32. package/lib/theme/BlogSidebar/styles.module.css +4 -6
  33. package/lib/theme/BlogTagsListPage/index.js +15 -20
  34. package/lib/theme/BlogTagsPostsPage/index.js +29 -33
  35. package/lib/theme/CodeBlock/index.js +11 -11
  36. package/lib/theme/CodeBlock/styles.module.css +4 -7
  37. package/lib/theme/DocItem/index.js +35 -26
  38. package/lib/theme/DocItem/styles.module.css +8 -10
  39. package/lib/theme/DocPage/index.js +43 -11
  40. package/lib/theme/DocPage/styles.module.css +7 -19
  41. package/lib/theme/DocPaginator/index.js +3 -3
  42. package/lib/theme/DocSidebar/index.js +23 -24
  43. package/lib/theme/DocSidebar/styles.module.css +0 -14
  44. package/lib/theme/DocVersionBanner/index.js +128 -0
  45. package/lib/theme/DocVersionSuggestions/index.js +4 -4
  46. package/lib/theme/Heading/index.js +18 -2
  47. package/lib/theme/Heading/styles.module.css +5 -0
  48. package/lib/theme/IconArrow/index.js +1 -1
  49. package/lib/theme/IconEdit/index.js +1 -1
  50. package/lib/theme/IconExternalLink/index.js +30 -0
  51. package/lib/theme/IconExternalLink/styles.module.css +12 -0
  52. package/lib/theme/IconLanguage/index.js +1 -1
  53. package/lib/theme/IconMenu/index.js +1 -2
  54. package/lib/theme/LastUpdated/index.js +17 -21
  55. package/lib/theme/Layout/styles.css +6 -0
  56. package/lib/theme/LayoutHead/index.js +3 -1
  57. package/lib/theme/LayoutProviders/index.js +7 -5
  58. package/lib/theme/Logo/index.js +13 -12
  59. package/lib/theme/MDXComponents/index.js +2 -2
  60. package/lib/theme/MDXPage/index.js +13 -15
  61. package/{src/theme/LastUpdated → lib/theme/MDXPage}/styles.module.css +2 -2
  62. package/lib/theme/Navbar/index.js +4 -4
  63. package/lib/theme/Navbar/styles.module.css +1 -1
  64. package/lib/theme/NavbarItem/DefaultNavbarItem.js +18 -4
  65. package/lib/theme/NavbarItem/DocNavbarItem.js +19 -11
  66. package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +5 -4
  67. package/lib/theme/NavbarItem/SearchNavbarItem.js +1 -5
  68. package/lib/theme/NavbarItem/index.js +1 -1
  69. package/lib/theme/NotFound.js +9 -2
  70. package/lib/theme/SearchMetadatas/index.js +1 -1
  71. package/lib/theme/Seo/index.js +0 -1
  72. package/lib/theme/SkipToContent/index.js +6 -4
  73. package/lib/theme/SkipToContent/styles.module.css +1 -3
  74. package/lib/theme/TOC/styles.module.css +1 -1
  75. package/lib/theme/Tabs/index.js +2 -2
  76. package/lib/theme/ThemedImage/index.js +2 -1
  77. package/lib/theme/ThemedImage/styles.module.css +7 -0
  78. package/lib/theme/Toggle/index.js +12 -24
  79. package/lib/theme/Toggle/styles.css +103 -0
  80. package/lib/theme/Toggle/styles.module.css +0 -97
  81. package/lib/theme/UserPreferencesProvider/index.js +1 -9
  82. package/lib/theme/hooks/useHideableNavbar.js +2 -2
  83. package/lib/theme/hooks/useTabGroupChoice.js +2 -4
  84. package/lib/theme/hooks/useThemeContext.js +1 -1
  85. package/lib/theme/hooks/useUserPreferencesContext.js +1 -1
  86. package/lib/types.d.ts +10 -12
  87. package/lib/validateThemeConfig.js +3 -3
  88. package/lib-next/index.js +31 -8
  89. package/lib-next/theme/AnnouncementBar/index.js +5 -9
  90. package/lib-next/theme/AnnouncementBar/styles.module.css +6 -6
  91. package/lib-next/theme/BlogListPage/index.js +2 -2
  92. package/lib-next/theme/BlogPostItem/index.js +41 -24
  93. package/lib-next/theme/BlogPostItem/styles.module.css +5 -1
  94. package/lib-next/theme/BlogPostPage/index.js +4 -8
  95. package/lib-next/theme/BlogPostPaginator/index.js +1 -1
  96. package/lib-next/theme/BlogSidebar/index.js +12 -3
  97. package/lib-next/theme/BlogSidebar/styles.module.css +4 -6
  98. package/lib-next/theme/BlogTagsListPage/index.js +17 -23
  99. package/lib-next/theme/BlogTagsPostsPage/index.js +36 -40
  100. package/lib-next/theme/CodeBlock/index.js +10 -9
  101. package/lib-next/theme/CodeBlock/styles.module.css +4 -7
  102. package/lib-next/theme/DocItem/index.js +41 -41
  103. package/lib-next/theme/DocItem/styles.module.css +8 -10
  104. package/lib-next/theme/DocPage/index.js +36 -9
  105. package/lib-next/theme/DocPage/styles.module.css +7 -19
  106. package/lib-next/theme/DocPaginator/index.js +1 -1
  107. package/lib-next/theme/DocSidebar/index.js +28 -21
  108. package/lib-next/theme/DocSidebar/styles.module.css +0 -14
  109. package/lib-next/theme/DocVersionBanner/index.js +127 -0
  110. package/lib-next/theme/DocVersionSuggestions/index.js +4 -4
  111. package/lib-next/theme/Heading/index.js +17 -1
  112. package/lib-next/theme/Heading/styles.module.css +5 -0
  113. package/lib-next/theme/IconArrow/index.js +1 -1
  114. package/lib-next/theme/IconEdit/index.js +3 -5
  115. package/lib-next/theme/IconExternalLink/index.js +26 -0
  116. package/{lib/theme/NavbarItem → lib-next/theme/IconExternalLink}/styles.module.css +4 -5
  117. package/lib-next/theme/IconLanguage/index.js +1 -1
  118. package/lib-next/theme/IconMenu/index.js +1 -4
  119. package/lib-next/theme/LastUpdated/index.js +34 -39
  120. package/lib-next/theme/Layout/styles.css +6 -0
  121. package/lib-next/theme/LayoutHead/index.js +5 -1
  122. package/lib-next/theme/LayoutProviders/index.js +11 -6
  123. package/lib-next/theme/Logo/index.js +12 -8
  124. package/lib-next/theme/MDXPage/index.js +13 -17
  125. package/lib-next/theme/{LastUpdated → MDXPage}/styles.module.css +2 -2
  126. package/lib-next/theme/Navbar/index.js +2 -2
  127. package/lib-next/theme/Navbar/styles.module.css +1 -1
  128. package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +19 -2
  129. package/lib-next/theme/NavbarItem/DocNavbarItem.js +23 -9
  130. package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +6 -6
  131. package/lib-next/theme/NavbarItem/SearchNavbarItem.js +1 -6
  132. package/lib-next/theme/NavbarItem/index.js +1 -1
  133. package/lib-next/theme/NotFound.js +6 -2
  134. package/lib-next/theme/SearchMetadatas/index.js +1 -1
  135. package/lib-next/theme/Seo/index.js +0 -1
  136. package/lib-next/theme/SkipToContent/index.js +3 -3
  137. package/lib-next/theme/SkipToContent/styles.module.css +1 -3
  138. package/lib-next/theme/TOC/styles.module.css +1 -1
  139. package/lib-next/theme/ThemedImage/index.js +2 -3
  140. package/lib-next/theme/ThemedImage/styles.module.css +7 -0
  141. package/lib-next/theme/Toggle/index.js +9 -24
  142. package/lib-next/theme/Toggle/styles.css +103 -0
  143. package/lib-next/theme/Toggle/styles.module.css +0 -97
  144. package/lib-next/theme/UserPreferencesProvider/index.js +0 -4
  145. package/lib-next/theme/hooks/useHideableNavbar.js +3 -3
  146. package/lib-next/theme/hooks/useTabGroupChoice.js +2 -4
  147. package/lib-next/theme/hooks/useThemeContext.js +1 -1
  148. package/lib-next/theme/hooks/useUserPreferencesContext.js +1 -1
  149. package/lib-next/types.d.ts +10 -12
  150. package/lib-next/validateThemeConfig.js +3 -3
  151. package/package.json +18 -17
  152. package/src/index.ts +32 -8
  153. package/src/theme/AnnouncementBar/index.tsx +6 -9
  154. package/src/theme/AnnouncementBar/styles.module.css +6 -6
  155. package/src/theme/BlogListPage/index.tsx +2 -2
  156. package/src/theme/BlogPostItem/index.tsx +40 -24
  157. package/src/theme/BlogPostItem/styles.module.css +5 -1
  158. package/src/theme/BlogPostPage/index.tsx +4 -8
  159. package/src/theme/BlogPostPaginator/index.tsx +1 -1
  160. package/src/theme/BlogSidebar/index.tsx +12 -3
  161. package/src/theme/BlogSidebar/styles.module.css +4 -6
  162. package/src/theme/BlogTagsListPage/index.tsx +17 -22
  163. package/src/theme/BlogTagsPostsPage/index.tsx +33 -43
  164. package/src/theme/CodeBlock/index.tsx +10 -9
  165. package/src/theme/CodeBlock/styles.module.css +4 -7
  166. package/src/theme/DocItem/index.tsx +40 -40
  167. package/src/theme/DocItem/styles.module.css +8 -10
  168. package/src/theme/DocPage/index.tsx +29 -9
  169. package/src/theme/DocPage/styles.module.css +7 -19
  170. package/src/theme/DocPaginator/index.tsx +1 -1
  171. package/src/theme/DocSidebar/index.tsx +28 -21
  172. package/src/theme/DocSidebar/styles.module.css +0 -14
  173. package/src/theme/{DocVersionSuggestions → DocVersionBanner}/index.tsx +46 -43
  174. package/src/theme/Heading/index.tsx +22 -1
  175. package/src/theme/Heading/styles.module.css +5 -0
  176. package/src/theme/IconArrow/index.tsx +1 -1
  177. package/src/theme/IconEdit/index.tsx +3 -5
  178. package/src/theme/IconExternalLink/index.tsx +32 -0
  179. package/src/theme/IconExternalLink/styles.module.css +12 -0
  180. package/src/theme/IconLanguage/index.tsx +1 -1
  181. package/src/theme/IconMenu/index.tsx +1 -4
  182. package/src/theme/LastUpdated/index.tsx +34 -39
  183. package/src/theme/Layout/styles.css +6 -0
  184. package/src/theme/LayoutHead/index.tsx +5 -1
  185. package/src/theme/LayoutProviders/index.tsx +11 -6
  186. package/src/theme/Logo/index.tsx +10 -6
  187. package/src/theme/MDXPage/index.tsx +14 -17
  188. package/{lib/theme/LastUpdated → src/theme/MDXPage}/styles.module.css +2 -2
  189. package/src/theme/Navbar/index.tsx +2 -2
  190. package/src/theme/Navbar/styles.module.css +1 -1
  191. package/src/theme/NavbarItem/DefaultNavbarItem.tsx +15 -2
  192. package/src/theme/NavbarItem/DocNavbarItem.tsx +29 -10
  193. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +7 -6
  194. package/src/theme/NavbarItem/SearchNavbarItem.tsx +1 -6
  195. package/src/theme/NavbarItem/index.tsx +1 -1
  196. package/src/theme/NotFound.tsx +6 -2
  197. package/src/theme/SearchMetadatas/index.tsx +1 -1
  198. package/src/theme/Seo/index.tsx +0 -1
  199. package/src/theme/SkipToContent/index.tsx +3 -3
  200. package/src/theme/SkipToContent/styles.module.css +1 -3
  201. package/src/theme/TOC/styles.module.css +1 -1
  202. package/src/theme/ThemedImage/index.tsx +3 -3
  203. package/src/theme/ThemedImage/styles.module.css +7 -0
  204. package/src/theme/Toggle/index.tsx +9 -22
  205. package/src/theme/Toggle/styles.css +103 -0
  206. package/src/theme/Toggle/styles.module.css +0 -97
  207. package/src/theme/UserPreferencesProvider/index.tsx +0 -5
  208. package/src/theme/hooks/useHideableNavbar.ts +3 -3
  209. package/src/theme/hooks/useTabGroupChoice.ts +2 -2
  210. package/src/theme/hooks/useThemeContext.ts +1 -1
  211. package/src/theme/hooks/useUserPreferencesContext.ts +1 -1
  212. package/src/types.d.ts +10 -12
  213. package/src/validateThemeConfig.js +3 -3
  214. package/update-code-translations.js +1 -0
  215. package/lib-next/theme/NavbarItem/styles.module.css +0 -13
  216. package/src/theme/NavbarItem/styles.module.css +0 -13
  217. 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 {useChangeRoute} from '@docusaurus/theme-common';
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
- useChangeRoute(() => {
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
- '`useThemeContext` is used outside of `Layout` Component. See https://docusaurus.io/docs/api/themes/configuration#usethemecontext.',
15
+ '"useThemeContext" is used outside of "Layout" component. Please see https://docusaurus.io/docs/api/themes/configuration#usethemecontext.',
16
16
  );
17
17
  }
18
18
 
@@ -12,7 +12,7 @@ function useUserPreferencesContext() {
12
12
 
13
13
  if (context == null) {
14
14
  throw new Error(
15
- '`useUserPreferencesContext` is used outside of `Layout` Component.',
15
+ '"useUserPreferencesContext" is used outside of "Layout" component.',
16
16
  );
17
17
  }
18
18
 
@@ -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.string(),
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().default('#fff'),
254
- textColor: Joi.string().default('#000'),
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.1ab8aa0af",
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.1ab8aa0af",
27
- "@docusaurus/plugin-content-blog": "2.0.0-beta.1ab8aa0af",
28
- "@docusaurus/plugin-content-docs": "2.0.0-beta.1ab8aa0af",
29
- "@docusaurus/plugin-content-pages": "2.0.0-beta.1ab8aa0af",
30
- "@docusaurus/theme-common": "2.0.0-beta.1ab8aa0af",
31
- "@docusaurus/types": "2.0.0-beta.1ab8aa0af",
32
- "@docusaurus/utils": "2.0.0-beta.1ab8aa0af",
33
- "@docusaurus/utils-validation": "2.0.0-beta.1ab8aa0af",
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.0",
37
+ "chalk": "^4.1.1",
37
38
  "clsx": "^1.1.1",
38
- "copy-text-to-clipboard": "^3.0.0",
39
- "fs-extra": "^9.1.0",
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.23",
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.10",
45
- "prism-react-renderer": "^1.1.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.1ab8aa0af"
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": "63c06baac39707a1a4c3cc4c0031cb2163f256c4"
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 storageKey = 'theme';
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('${storageKey}');
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 {colorMode, prism: {additionalLanguages = []} = {}} = themeConfig;
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
- attributes: {
182
- type: 'text/javascript',
183
- },
184
- innerHTML: noFlashColorMode(colorMode),
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
- if (!content || (isCloseable && isAnnouncementBarClosed)) {
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={closeAnnouncementBar}
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-primary);
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
- <div className="col col--3">
38
+ <aside className="col col--3">
39
39
  <BlogSidebar sidebar={sidebar} />
40
- </div>
40
+ </aside>
41
41
  <main className="col col--7">
42
42
  {items.map(({content: BlogPostContent}) => (
43
43
  <BlogPostItem