@docusaurus/theme-classic 0.0.0-4735 → 0.0.0-4736
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/theme-classic.d.ts +59 -1
- package/lib-next/theme/DocSidebar/Mobile/index.js +24 -20
- package/lib-next/theme/LayoutProviders/index.js +4 -6
- package/lib-next/theme/Navbar/ColorModeToggle/index.js +25 -0
- package/lib-next/theme/Navbar/Content/index.js +70 -0
- package/lib-next/theme/Navbar/Content/styles.module.css +15 -0
- package/lib-next/theme/Navbar/Layout/index.js +54 -0
- package/lib-next/theme/Navbar/{styles.module.css → Layout/styles.module.css} +0 -13
- package/lib-next/theme/Navbar/Logo/index.js +17 -0
- package/lib-next/theme/Navbar/MobileSidebar/Header/index.js +33 -0
- package/lib-next/theme/Navbar/MobileSidebar/Layout/index.js +28 -0
- package/lib-next/theme/Navbar/MobileSidebar/PrimaryMenu/index.js +33 -0
- package/lib-next/theme/Navbar/MobileSidebar/SecondaryMenu/index.js +36 -0
- package/lib-next/theme/Navbar/MobileSidebar/Toggle/index.js +23 -0
- package/lib-next/theme/Navbar/MobileSidebar/index.js +31 -0
- package/lib-next/theme/Navbar/index.js +6 -273
- package/package.json +13 -13
- package/src/theme/DocSidebar/Mobile/index.tsx +26 -23
- package/src/theme/LayoutProviders/index.tsx +4 -6
- package/src/theme/Navbar/ColorModeToggle/index.tsx +30 -0
- package/src/theme/Navbar/Content/index.tsx +81 -0
- package/src/theme/Navbar/Content/styles.module.css +15 -0
- package/src/theme/Navbar/Layout/index.tsx +57 -0
- package/src/theme/Navbar/{styles.module.css → Layout/styles.module.css} +0 -13
- package/src/theme/Navbar/Logo/index.tsx +19 -0
- package/src/theme/Navbar/MobileSidebar/Header/index.tsx +34 -0
- package/src/theme/Navbar/MobileSidebar/Layout/index.tsx +31 -0
- package/src/theme/Navbar/MobileSidebar/PrimaryMenu/index.tsx +38 -0
- package/src/theme/Navbar/MobileSidebar/SecondaryMenu/index.tsx +38 -0
- package/src/theme/Navbar/MobileSidebar/Toggle/index.tsx +25 -0
- package/src/theme/Navbar/MobileSidebar/index.tsx +33 -0
- package/src/theme/Navbar/index.tsx +6 -292
- package/src/theme-classic.d.ts +59 -1
|
@@ -4,280 +4,13 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import SearchBar from '@theme/SearchBar';
|
|
11
|
-
import ColorModeToggle from '@theme/ColorModeToggle';
|
|
12
|
-
import {
|
|
13
|
-
useThemeConfig,
|
|
14
|
-
useMobileSecondaryMenuRenderer,
|
|
15
|
-
usePrevious,
|
|
16
|
-
useHistoryPopHandler,
|
|
17
|
-
useHideableNavbar,
|
|
18
|
-
useLockBodyScroll,
|
|
19
|
-
useWindowSize,
|
|
20
|
-
useColorMode,
|
|
21
|
-
} from '@docusaurus/theme-common';
|
|
22
|
-
import {useActivePlugin} from '@docusaurus/plugin-content-docs/client';
|
|
23
|
-
import NavbarItem from '@theme/NavbarItem';
|
|
24
|
-
import Logo from '@theme/Logo';
|
|
25
|
-
import IconMenu from '@theme/IconMenu';
|
|
26
|
-
import IconClose from '@theme/IconClose';
|
|
27
|
-
import styles from './styles.module.css'; // retrocompatible with v1
|
|
28
|
-
|
|
29
|
-
const DefaultNavItemPosition = 'right';
|
|
30
|
-
|
|
31
|
-
function useNavbarItems() {
|
|
32
|
-
// TODO temporary casting until ThemeConfig type is improved
|
|
33
|
-
return useThemeConfig().navbar.items;
|
|
34
|
-
} // If split links by left/right
|
|
35
|
-
// if position is unspecified, fallback to right (as v1)
|
|
36
|
-
|
|
37
|
-
function splitNavItemsByPosition(items) {
|
|
38
|
-
const leftItems = items.filter(
|
|
39
|
-
(item) => (item.position ?? DefaultNavItemPosition) === 'left',
|
|
40
|
-
);
|
|
41
|
-
const rightItems = items.filter(
|
|
42
|
-
(item) => (item.position ?? DefaultNavItemPosition) === 'right',
|
|
43
|
-
);
|
|
44
|
-
return {
|
|
45
|
-
leftItems,
|
|
46
|
-
rightItems,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function useMobileSidebar() {
|
|
51
|
-
const windowSize = useWindowSize(); // Mobile sidebar not visible on hydration: can avoid SSR rendering
|
|
52
|
-
|
|
53
|
-
const shouldRender = windowSize === 'mobile'; // || windowSize === 'ssr';
|
|
54
|
-
|
|
55
|
-
const [shown, setShown] = useState(false); // Close mobile sidebar on navigation pop
|
|
56
|
-
// Most likely firing when using the Android back button (but not only)
|
|
57
|
-
|
|
58
|
-
useHistoryPopHandler(() => {
|
|
59
|
-
if (shown) {
|
|
60
|
-
setShown(false); // Should we prevent the navigation here?
|
|
61
|
-
// See https://github.com/facebook/docusaurus/pull/5462#issuecomment-911699846
|
|
62
|
-
|
|
63
|
-
return false; // prevent pop navigation
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return undefined;
|
|
67
|
-
});
|
|
68
|
-
const toggle = useCallback(() => {
|
|
69
|
-
setShown((s) => !s);
|
|
70
|
-
}, []);
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
if (windowSize === 'desktop') {
|
|
73
|
-
setShown(false);
|
|
74
|
-
}
|
|
75
|
-
}, [windowSize]);
|
|
76
|
-
return {
|
|
77
|
-
shouldRender,
|
|
78
|
-
toggle,
|
|
79
|
-
shown,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function useColorModeToggle() {
|
|
84
|
-
const {
|
|
85
|
-
colorMode: {disableSwitch},
|
|
86
|
-
} = useThemeConfig();
|
|
87
|
-
const {colorMode, setColorMode} = useColorMode();
|
|
88
|
-
return {
|
|
89
|
-
value: colorMode,
|
|
90
|
-
onChange: setColorMode,
|
|
91
|
-
disabled: disableSwitch,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function useSecondaryMenu({sidebarShown, toggleSidebar}) {
|
|
96
|
-
const content = useMobileSecondaryMenuRenderer()?.({
|
|
97
|
-
toggleSidebar,
|
|
98
|
-
});
|
|
99
|
-
const previousContent = usePrevious(content);
|
|
100
|
-
const [shown, setShown] = useState(
|
|
101
|
-
() =>
|
|
102
|
-
// /!\ content is set with useEffect,
|
|
103
|
-
// so it's not available on mount anyway
|
|
104
|
-
// "return !!content" => always returns false
|
|
105
|
-
false,
|
|
106
|
-
); // When content is become available for the first time (set in useEffect)
|
|
107
|
-
// we set this content to be shown!
|
|
108
|
-
|
|
109
|
-
useEffect(() => {
|
|
110
|
-
const contentBecameAvailable = content && !previousContent;
|
|
111
|
-
|
|
112
|
-
if (contentBecameAvailable) {
|
|
113
|
-
setShown(true);
|
|
114
|
-
}
|
|
115
|
-
}, [content, previousContent]);
|
|
116
|
-
const hasContent = !!content; // On sidebar close, secondary menu is set to be shown on next re-opening
|
|
117
|
-
// (if any secondary menu content available)
|
|
118
|
-
|
|
119
|
-
useEffect(() => {
|
|
120
|
-
if (!hasContent) {
|
|
121
|
-
setShown(false);
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (!sidebarShown) {
|
|
126
|
-
setShown(true);
|
|
127
|
-
}
|
|
128
|
-
}, [sidebarShown, hasContent]);
|
|
129
|
-
const hide = useCallback(() => {
|
|
130
|
-
setShown(false);
|
|
131
|
-
}, []);
|
|
132
|
-
return {
|
|
133
|
-
shown,
|
|
134
|
-
hide,
|
|
135
|
-
content,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function NavbarMobileSidebar({sidebarShown, toggleSidebar}) {
|
|
140
|
-
useLockBodyScroll(sidebarShown);
|
|
141
|
-
const items = useNavbarItems();
|
|
142
|
-
const colorModeToggle = useColorModeToggle();
|
|
143
|
-
const secondaryMenu = useSecondaryMenu({
|
|
144
|
-
sidebarShown,
|
|
145
|
-
toggleSidebar,
|
|
146
|
-
});
|
|
147
|
-
return (
|
|
148
|
-
<div className="navbar-sidebar">
|
|
149
|
-
<div className="navbar-sidebar__brand">
|
|
150
|
-
<Logo
|
|
151
|
-
className="navbar__brand"
|
|
152
|
-
imageClassName="navbar__logo"
|
|
153
|
-
titleClassName="navbar__title"
|
|
154
|
-
/>
|
|
155
|
-
{!colorModeToggle.disabled && (
|
|
156
|
-
<ColorModeToggle
|
|
157
|
-
className={styles.navbarSidebarToggle}
|
|
158
|
-
value={colorModeToggle.value}
|
|
159
|
-
onChange={colorModeToggle.onChange}
|
|
160
|
-
/>
|
|
161
|
-
)}
|
|
162
|
-
<button
|
|
163
|
-
type="button"
|
|
164
|
-
className="clean-btn navbar-sidebar__close"
|
|
165
|
-
onClick={toggleSidebar}>
|
|
166
|
-
<IconClose
|
|
167
|
-
color="var(--ifm-color-emphasis-600)"
|
|
168
|
-
className={styles.navbarSidebarCloseSvg}
|
|
169
|
-
/>
|
|
170
|
-
</button>
|
|
171
|
-
</div>
|
|
172
|
-
|
|
173
|
-
<div
|
|
174
|
-
className={clsx('navbar-sidebar__items', {
|
|
175
|
-
'navbar-sidebar__items--show-secondary': secondaryMenu.shown,
|
|
176
|
-
})}>
|
|
177
|
-
<div className="navbar-sidebar__item menu">
|
|
178
|
-
<ul className="menu__list">
|
|
179
|
-
{items.map((item, i) => (
|
|
180
|
-
<NavbarItem mobile {...item} onClick={toggleSidebar} key={i} />
|
|
181
|
-
))}
|
|
182
|
-
</ul>
|
|
183
|
-
</div>
|
|
184
|
-
|
|
185
|
-
<div className="navbar-sidebar__item menu">
|
|
186
|
-
{items.length > 0 && (
|
|
187
|
-
<button
|
|
188
|
-
type="button"
|
|
189
|
-
className="clean-btn navbar-sidebar__back"
|
|
190
|
-
onClick={secondaryMenu.hide}>
|
|
191
|
-
<Translate
|
|
192
|
-
id="theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel"
|
|
193
|
-
description="The label of the back button to return to main menu, inside the mobile navbar sidebar secondary menu (notably used to display the docs sidebar)">
|
|
194
|
-
← Back to main menu
|
|
195
|
-
</Translate>
|
|
196
|
-
</button>
|
|
197
|
-
)}
|
|
198
|
-
{secondaryMenu.content}
|
|
199
|
-
</div>
|
|
200
|
-
</div>
|
|
201
|
-
</div>
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import NavbarLayout from '@theme/Navbar/Layout';
|
|
9
|
+
import NavbarContent from '@theme/Navbar/Content';
|
|
205
10
|
export default function Navbar() {
|
|
206
|
-
const {
|
|
207
|
-
navbar: {hideOnScroll, style},
|
|
208
|
-
} = useThemeConfig();
|
|
209
|
-
const mobileSidebar = useMobileSidebar();
|
|
210
|
-
const colorModeToggle = useColorModeToggle();
|
|
211
|
-
const activeDocPlugin = useActivePlugin();
|
|
212
|
-
const {navbarRef, isNavbarVisible} = useHideableNavbar(hideOnScroll);
|
|
213
|
-
const items = useNavbarItems();
|
|
214
|
-
const hasSearchNavbarItem = items.some((item) => item.type === 'search');
|
|
215
|
-
const {leftItems, rightItems} = splitNavItemsByPosition(items);
|
|
216
11
|
return (
|
|
217
|
-
<
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
'navbar',
|
|
221
|
-
'navbar--fixed-top',
|
|
222
|
-
hideOnScroll && [
|
|
223
|
-
styles.navbarHideable,
|
|
224
|
-
!isNavbarVisible && styles.navbarHidden,
|
|
225
|
-
],
|
|
226
|
-
{
|
|
227
|
-
'navbar--dark': style === 'dark',
|
|
228
|
-
'navbar--primary': style === 'primary',
|
|
229
|
-
'navbar-sidebar--show': mobileSidebar.shown,
|
|
230
|
-
},
|
|
231
|
-
)}>
|
|
232
|
-
<div className="navbar__inner">
|
|
233
|
-
<div className="navbar__items">
|
|
234
|
-
{(items?.length > 0 || activeDocPlugin) && (
|
|
235
|
-
<button
|
|
236
|
-
aria-label="Navigation bar toggle"
|
|
237
|
-
className="navbar__toggle clean-btn"
|
|
238
|
-
type="button"
|
|
239
|
-
tabIndex={0}
|
|
240
|
-
onClick={mobileSidebar.toggle}
|
|
241
|
-
onKeyDown={mobileSidebar.toggle}>
|
|
242
|
-
<IconMenu />
|
|
243
|
-
</button>
|
|
244
|
-
)}
|
|
245
|
-
<Logo
|
|
246
|
-
className="navbar__brand"
|
|
247
|
-
imageClassName="navbar__logo"
|
|
248
|
-
titleClassName="navbar__title"
|
|
249
|
-
/>
|
|
250
|
-
{leftItems.map((item, i) => (
|
|
251
|
-
<NavbarItem {...item} key={i} />
|
|
252
|
-
))}
|
|
253
|
-
</div>
|
|
254
|
-
<div className="navbar__items navbar__items--right">
|
|
255
|
-
{rightItems.map((item, i) => (
|
|
256
|
-
<NavbarItem {...item} key={i} />
|
|
257
|
-
))}
|
|
258
|
-
{!colorModeToggle.disabled && (
|
|
259
|
-
<ColorModeToggle
|
|
260
|
-
className={styles.toggle}
|
|
261
|
-
value={colorModeToggle.value}
|
|
262
|
-
onChange={colorModeToggle.onChange}
|
|
263
|
-
/>
|
|
264
|
-
)}
|
|
265
|
-
{!hasSearchNavbarItem && <SearchBar />}
|
|
266
|
-
</div>
|
|
267
|
-
</div>
|
|
268
|
-
|
|
269
|
-
<div
|
|
270
|
-
role="presentation"
|
|
271
|
-
className="navbar-sidebar__backdrop"
|
|
272
|
-
onClick={mobileSidebar.toggle}
|
|
273
|
-
/>
|
|
274
|
-
|
|
275
|
-
{mobileSidebar.shouldRender && (
|
|
276
|
-
<NavbarMobileSidebar
|
|
277
|
-
sidebarShown={mobileSidebar.shown}
|
|
278
|
-
toggleSidebar={mobileSidebar.toggle}
|
|
279
|
-
/>
|
|
280
|
-
)}
|
|
281
|
-
</nav>
|
|
12
|
+
<NavbarLayout>
|
|
13
|
+
<NavbarContent />
|
|
14
|
+
</NavbarLayout>
|
|
282
15
|
);
|
|
283
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4736",
|
|
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-
|
|
25
|
-
"@docusaurus/plugin-content-blog": "0.0.0-
|
|
26
|
-
"@docusaurus/plugin-content-docs": "0.0.0-
|
|
27
|
-
"@docusaurus/plugin-content-pages": "0.0.0-
|
|
28
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
29
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
30
|
-
"@docusaurus/utils": "0.0.0-
|
|
31
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
32
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
24
|
+
"@docusaurus/core": "0.0.0-4736",
|
|
25
|
+
"@docusaurus/plugin-content-blog": "0.0.0-4736",
|
|
26
|
+
"@docusaurus/plugin-content-docs": "0.0.0-4736",
|
|
27
|
+
"@docusaurus/plugin-content-pages": "0.0.0-4736",
|
|
28
|
+
"@docusaurus/theme-common": "0.0.0-4736",
|
|
29
|
+
"@docusaurus/theme-translations": "0.0.0-4736",
|
|
30
|
+
"@docusaurus/utils": "0.0.0-4736",
|
|
31
|
+
"@docusaurus/utils-common": "0.0.0-4736",
|
|
32
|
+
"@docusaurus/utils-validation": "0.0.0-4736",
|
|
33
33
|
"@mdx-js/react": "^1.6.22",
|
|
34
34
|
"clsx": "^1.1.1",
|
|
35
35
|
"copy-text-to-clipboard": "^3.0.1",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"rtlcss": "^3.5.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
46
|
-
"@docusaurus/types": "0.0.0-
|
|
45
|
+
"@docusaurus/module-type-aliases": "0.0.0-4736",
|
|
46
|
+
"@docusaurus/types": "0.0.0-4736",
|
|
47
47
|
"@types/mdx-js__react": "^1.5.5",
|
|
48
48
|
"@types/prismjs": "^1.26.0",
|
|
49
49
|
"@types/rtlcss": "^3.1.2",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">=14"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "6715ee0543eaae8589cb83c32946218abb147266"
|
|
63
63
|
}
|
|
@@ -8,40 +8,43 @@
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
type
|
|
11
|
+
NavbarSecondaryMenuFiller,
|
|
12
|
+
type NavbarSecondaryMenuComponent,
|
|
13
13
|
ThemeClassNames,
|
|
14
|
+
useNavbarMobileSidebar,
|
|
14
15
|
} from '@docusaurus/theme-common';
|
|
15
16
|
import DocSidebarItems from '@theme/DocSidebarItems';
|
|
16
17
|
import type {Props} from '@theme/DocSidebar/Mobile';
|
|
17
18
|
|
|
18
19
|
// eslint-disable-next-line react/function-component-definition
|
|
19
|
-
const DocSidebarMobileSecondaryMenu:
|
|
20
|
-
toggleSidebar,
|
|
20
|
+
const DocSidebarMobileSecondaryMenu: NavbarSecondaryMenuComponent<Props> = ({
|
|
21
21
|
sidebar,
|
|
22
22
|
path,
|
|
23
|
-
}) =>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
}) => {
|
|
24
|
+
const mobileSidebar = useNavbarMobileSidebar();
|
|
25
|
+
return (
|
|
26
|
+
<ul className={clsx(ThemeClassNames.docs.docSidebarMenu, 'menu__list')}>
|
|
27
|
+
<DocSidebarItems
|
|
28
|
+
items={sidebar}
|
|
29
|
+
activePath={path}
|
|
30
|
+
onItemClick={(item) => {
|
|
31
|
+
// Mobile sidebar should only be closed if the category has a link
|
|
32
|
+
if (item.type === 'category' && item.href) {
|
|
33
|
+
mobileSidebar.toggle();
|
|
34
|
+
}
|
|
35
|
+
if (item.type === 'link') {
|
|
36
|
+
mobileSidebar.toggle();
|
|
37
|
+
}
|
|
38
|
+
}}
|
|
39
|
+
level={1}
|
|
40
|
+
/>
|
|
41
|
+
</ul>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
41
44
|
|
|
42
45
|
function DocSidebarMobile(props: Props) {
|
|
43
46
|
return (
|
|
44
|
-
<
|
|
47
|
+
<NavbarSecondaryMenuFiller
|
|
45
48
|
component={DocSidebarMobileSecondaryMenu}
|
|
46
49
|
props={props}
|
|
47
50
|
/>
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
TabGroupChoiceProvider,
|
|
12
12
|
AnnouncementBarProvider,
|
|
13
13
|
DocsPreferredVersionContextProvider,
|
|
14
|
-
MobileSecondaryMenuProvider,
|
|
15
14
|
ScrollControllerProvider,
|
|
15
|
+
NavbarProvider,
|
|
16
16
|
PluginHtmlClassNameProvider,
|
|
17
17
|
} from '@docusaurus/theme-common';
|
|
18
18
|
import type {Props} from '@theme/LayoutProviders';
|
|
@@ -24,11 +24,9 @@ export default function LayoutProviders({children}: Props): JSX.Element {
|
|
|
24
24
|
<TabGroupChoiceProvider>
|
|
25
25
|
<ScrollControllerProvider>
|
|
26
26
|
<DocsPreferredVersionContextProvider>
|
|
27
|
-
<
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
</PluginHtmlClassNameProvider>
|
|
31
|
-
</MobileSecondaryMenuProvider>
|
|
27
|
+
<PluginHtmlClassNameProvider>
|
|
28
|
+
<NavbarProvider>{children}</NavbarProvider>
|
|
29
|
+
</PluginHtmlClassNameProvider>
|
|
32
30
|
</DocsPreferredVersionContextProvider>
|
|
33
31
|
</ScrollControllerProvider>
|
|
34
32
|
</TabGroupChoiceProvider>
|
|
@@ -0,0 +1,30 @@
|
|
|
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 {useColorMode, useThemeConfig} from '@docusaurus/theme-common';
|
|
9
|
+
import ColorModeToggle from '@theme/ColorModeToggle';
|
|
10
|
+
import type {Props} from '@theme/Navbar/ColorModeToggle';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
|
|
13
|
+
export default function NavbarColorModeToggle({
|
|
14
|
+
className,
|
|
15
|
+
}: Props): JSX.Element | null {
|
|
16
|
+
const disabled = useThemeConfig().colorMode.disableSwitch;
|
|
17
|
+
const {colorMode, setColorMode} = useColorMode();
|
|
18
|
+
|
|
19
|
+
if (disabled) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<ColorModeToggle
|
|
25
|
+
className={className}
|
|
26
|
+
value={colorMode}
|
|
27
|
+
onChange={setColorMode}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
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, {type ReactNode} from 'react';
|
|
9
|
+
import type {Props as NavbarItemConfig} from '@theme/NavbarItem';
|
|
10
|
+
import NavbarItem from '@theme/NavbarItem';
|
|
11
|
+
import NavbarColorModeToggle from '@theme/Navbar/ColorModeToggle';
|
|
12
|
+
import SearchBar from '@theme/SearchBar';
|
|
13
|
+
import {
|
|
14
|
+
splitNavbarItems,
|
|
15
|
+
useNavbarMobileSidebar,
|
|
16
|
+
useThemeConfig,
|
|
17
|
+
} from '@docusaurus/theme-common';
|
|
18
|
+
import NavbarMobileSidebarToggle from '@theme/Navbar/MobileSidebar/Toggle';
|
|
19
|
+
import NavbarLogo from '@theme/Navbar/Logo';
|
|
20
|
+
import styles from './styles.module.css';
|
|
21
|
+
|
|
22
|
+
function useNavbarItems() {
|
|
23
|
+
// TODO temporary casting until ThemeConfig type is improved
|
|
24
|
+
return useThemeConfig().navbar.items as NavbarItemConfig[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function NavbarItems({items}: {items: NavbarItemConfig[]}): JSX.Element {
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
{items.map((item, i) => (
|
|
31
|
+
<NavbarItem {...item} key={i} />
|
|
32
|
+
))}
|
|
33
|
+
</>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function NavbarContentLayout({
|
|
38
|
+
left,
|
|
39
|
+
right,
|
|
40
|
+
}: {
|
|
41
|
+
left: ReactNode;
|
|
42
|
+
right: ReactNode;
|
|
43
|
+
}) {
|
|
44
|
+
return (
|
|
45
|
+
<div className="navbar__inner">
|
|
46
|
+
<div className="navbar__items">{left}</div>
|
|
47
|
+
<div className="navbar__items navbar__items--right">{right}</div>
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default function NavbarContent(): JSX.Element {
|
|
53
|
+
const mobileSidebar = useNavbarMobileSidebar();
|
|
54
|
+
|
|
55
|
+
const items = useNavbarItems();
|
|
56
|
+
const [leftItems, rightItems] = splitNavbarItems(items);
|
|
57
|
+
|
|
58
|
+
const autoAddSearchBar = !items.some((item) => item.type === 'search');
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<NavbarContentLayout
|
|
62
|
+
left={
|
|
63
|
+
// TODO stop hardcoding items?
|
|
64
|
+
<>
|
|
65
|
+
{!mobileSidebar.disabled && <NavbarMobileSidebarToggle />}
|
|
66
|
+
<NavbarLogo />
|
|
67
|
+
<NavbarItems items={leftItems} />
|
|
68
|
+
</>
|
|
69
|
+
}
|
|
70
|
+
right={
|
|
71
|
+
// TODO stop hardcoding items?
|
|
72
|
+
// Ask the user to add the respective navbar items => more flexible
|
|
73
|
+
<>
|
|
74
|
+
<NavbarItems items={rightItems} />
|
|
75
|
+
<NavbarColorModeToggle className={styles.colorModeToggle} />
|
|
76
|
+
{autoAddSearchBar && <SearchBar />}
|
|
77
|
+
</>
|
|
78
|
+
}
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
@@ -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
|
+
/*
|
|
9
|
+
Hide color mode toggle in small viewports
|
|
10
|
+
*/
|
|
11
|
+
@media (max-width: 996px) {
|
|
12
|
+
.colorModeToggle {
|
|
13
|
+
display: none;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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, {type ComponentProps} from 'react';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import NavbarMobileSidebar from '@theme/Navbar/MobileSidebar';
|
|
11
|
+
import type {Props} from '@theme/Navbar/Layout';
|
|
12
|
+
import {
|
|
13
|
+
useThemeConfig,
|
|
14
|
+
useHideableNavbar,
|
|
15
|
+
useNavbarMobileSidebar,
|
|
16
|
+
} from '@docusaurus/theme-common';
|
|
17
|
+
|
|
18
|
+
import styles from './styles.module.css';
|
|
19
|
+
|
|
20
|
+
function NavbarBackdrop(props: ComponentProps<'div'>) {
|
|
21
|
+
return (
|
|
22
|
+
<div
|
|
23
|
+
role="presentation"
|
|
24
|
+
{...props}
|
|
25
|
+
className={clsx('navbar-sidebar__backdrop', props.className)}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default function NavbarLayout({children}: Props): JSX.Element {
|
|
31
|
+
const {
|
|
32
|
+
navbar: {hideOnScroll, style},
|
|
33
|
+
} = useThemeConfig();
|
|
34
|
+
const mobileSidebar = useNavbarMobileSidebar();
|
|
35
|
+
const {navbarRef, isNavbarVisible} = useHideableNavbar(hideOnScroll);
|
|
36
|
+
return (
|
|
37
|
+
<nav
|
|
38
|
+
ref={navbarRef}
|
|
39
|
+
className={clsx(
|
|
40
|
+
'navbar',
|
|
41
|
+
'navbar--fixed-top',
|
|
42
|
+
hideOnScroll && [
|
|
43
|
+
styles.navbarHideable,
|
|
44
|
+
!isNavbarVisible && styles.navbarHidden,
|
|
45
|
+
],
|
|
46
|
+
{
|
|
47
|
+
'navbar--dark': style === 'dark',
|
|
48
|
+
'navbar--primary': style === 'primary',
|
|
49
|
+
'navbar-sidebar--show': mobileSidebar.shown,
|
|
50
|
+
},
|
|
51
|
+
)}>
|
|
52
|
+
{children}
|
|
53
|
+
<NavbarBackdrop onClick={mobileSidebar.toggle} />
|
|
54
|
+
<NavbarMobileSidebar />
|
|
55
|
+
</nav>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
@@ -5,15 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
/*
|
|
9
|
-
Hide toggle in small viewports
|
|
10
|
-
*/
|
|
11
|
-
@media (max-width: 996px) {
|
|
12
|
-
.toggle {
|
|
13
|
-
display: none;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
8
|
.navbarHideable {
|
|
18
9
|
transition: transform var(--ifm-transition-fast) ease;
|
|
19
10
|
}
|
|
@@ -21,7 +12,3 @@ Hide toggle in small viewports
|
|
|
21
12
|
.navbarHidden {
|
|
22
13
|
transform: translate3d(0, calc(-100% - 2px), 0);
|
|
23
14
|
}
|
|
24
|
-
|
|
25
|
-
.navbarSidebarToggle {
|
|
26
|
-
margin-right: 1rem;
|
|
27
|
-
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 Logo from '@theme/Logo';
|
|
10
|
+
|
|
11
|
+
export default function NavbarLogo(): JSX.Element {
|
|
12
|
+
return (
|
|
13
|
+
<Logo
|
|
14
|
+
className="navbar__brand"
|
|
15
|
+
imageClassName="navbar__logo"
|
|
16
|
+
titleClassName="navbar__title"
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
}
|