@brillout/docpress 0.15.12 → 0.15.13-commit-ffe283f
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/ExternalLinks.tsx +32 -10
- package/Layout.tsx +190 -160
- package/MenuModal/NavigationWithColumnLayout.tsx +18 -11
- package/MenuModal/toggleMenuModal.ts +2 -2
- package/MenuModal.tsx +4 -4
- package/NavItemComponent.tsx +15 -1
- package/determineNavItemsColumnLayout.spec.ts +518 -0
- package/determineNavItemsColumnLayout.ts +11 -10
- package/dist/NavItemComponent.d.ts +24 -2
- package/dist/determineNavItemsColumnLayout.js +10 -9
- package/dist/types/Config.d.ts +1 -0
- package/docsearch/SearchLink.tsx +5 -1
- package/icons/coin.svg +38 -0
- package/icons/index.ts +2 -0
- package/icons/loudspeaker.svg +1 -0
- package/package.json +1 -1
- package/types/Config.ts +1 -0
package/ExternalLinks.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import '@docsearch/css'
|
|
|
13
13
|
|
|
14
14
|
function ExternalLinks(props: { style?: React.CSSProperties }) {
|
|
15
15
|
const pageContext = usePageContext()
|
|
16
|
-
const { github, discord, bluesky, linkedin, i18n, twitter } = pageContext.globalContext.config.docpress
|
|
16
|
+
const { github, discord, bluesky, linkedin, i18n, twitter, changelog } = pageContext.globalContext.config.docpress
|
|
17
17
|
const iconI18n = !i18n ? null : (
|
|
18
18
|
<LinkIcon
|
|
19
19
|
className="decolorize-4"
|
|
@@ -31,6 +31,7 @@ function ExternalLinks(props: { style?: React.CSSProperties }) {
|
|
|
31
31
|
...props.style,
|
|
32
32
|
}}
|
|
33
33
|
>
|
|
34
|
+
<LinkIcon className="decolorize-4" icon={iconGithub} href={github} iconSizeBoost={1} />
|
|
34
35
|
{iconI18n}
|
|
35
36
|
{discord && <LinkIcon className="decolorize-6" icon={iconDiscord} href={discord} />}
|
|
36
37
|
{twitter && <LinkIcon className="decolorize-4" icon={iconTwitter} href={`https://x.com/${twitter.slice(1)}`} />}
|
|
@@ -38,8 +39,7 @@ function ExternalLinks(props: { style?: React.CSSProperties }) {
|
|
|
38
39
|
{linkedin && (
|
|
39
40
|
<LinkIcon className="decolorize-6" icon={iconLinkedin} href={`https://www.linkedin.com/company/${linkedin}`} />
|
|
40
41
|
)}
|
|
41
|
-
|
|
42
|
-
<ChangelogButton />
|
|
42
|
+
{changelog !== false && <ChangelogButton />}
|
|
43
43
|
</div>
|
|
44
44
|
)
|
|
45
45
|
}
|
|
@@ -54,7 +54,7 @@ function ChangelogButton() {
|
|
|
54
54
|
style={{
|
|
55
55
|
display: 'flex',
|
|
56
56
|
alignItems: 'center',
|
|
57
|
-
padding: '0
|
|
57
|
+
padding: '0 3px',
|
|
58
58
|
height: '100%',
|
|
59
59
|
}}
|
|
60
60
|
>
|
|
@@ -63,28 +63,50 @@ function ChangelogButton() {
|
|
|
63
63
|
style={{
|
|
64
64
|
display: 'flex',
|
|
65
65
|
alignItems: 'center',
|
|
66
|
-
|
|
66
|
+
paddingLeft: 8,
|
|
67
|
+
paddingRight: 8,
|
|
68
|
+
paddingTop: 4,
|
|
69
|
+
paddingBottom: 5,
|
|
67
70
|
fontSize: '0.97em',
|
|
71
|
+
lineHeight: 0,
|
|
68
72
|
}}
|
|
69
73
|
>
|
|
70
|
-
<span
|
|
74
|
+
<span
|
|
75
|
+
id="version-number"
|
|
76
|
+
className="decolorize-7"
|
|
77
|
+
style={{
|
|
78
|
+
position: 'relative',
|
|
79
|
+
top: 1,
|
|
80
|
+
}}
|
|
81
|
+
>
|
|
71
82
|
v{version}
|
|
72
83
|
</span>
|
|
73
|
-
<img
|
|
84
|
+
<img
|
|
85
|
+
className="decolorize-6"
|
|
86
|
+
src={iconChangelog}
|
|
87
|
+
height={16}
|
|
88
|
+
style={{ marginLeft: 6, position: 'relative', top: 1 }}
|
|
89
|
+
/>
|
|
74
90
|
</div>
|
|
75
91
|
</a>
|
|
76
92
|
)
|
|
77
93
|
}
|
|
78
94
|
|
|
79
|
-
function LinkIcon({
|
|
95
|
+
function LinkIcon({
|
|
96
|
+
className,
|
|
97
|
+
icon,
|
|
98
|
+
href,
|
|
99
|
+
style,
|
|
100
|
+
iconSizeBoost = 0,
|
|
101
|
+
}: { className: string; icon: string; href: string; style?: any; iconSizeBoost?: number }) {
|
|
80
102
|
return (
|
|
81
103
|
<>
|
|
82
104
|
<a
|
|
83
105
|
className="colorize-on-hover"
|
|
84
106
|
href={href}
|
|
85
|
-
style={{ padding:
|
|
107
|
+
style={{ padding: 3, display: 'inline-flex', lineHeight: 0, height: '100%', alignItems: 'center' }}
|
|
86
108
|
>
|
|
87
|
-
<img className={className} src={icon} height=
|
|
109
|
+
<img className={className} src={icon} height={18 + iconSizeBoost} style={style} />
|
|
88
110
|
</a>
|
|
89
111
|
</>
|
|
90
112
|
)
|
package/Layout.tsx
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
export { Layout }
|
|
2
2
|
export { MenuToggle }
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { viewDesktop }
|
|
4
|
+
export { viewTablet }
|
|
5
5
|
export { navLeftWidthMin }
|
|
6
6
|
export { navLeftWidthMax }
|
|
7
7
|
export { unexpandNav }
|
|
8
8
|
export { blockMargin }
|
|
9
9
|
|
|
10
|
+
// - We use `@container container-viewport` instead of @media because @media doesn't consider the scrollbar width.
|
|
11
|
+
// - We use --padding-side because we cannot set a fixed max-width on the <NavHead> container .nav-head-content — DocPress doesn't know how many extra <NavHead> elements the user adds using the +docpress.topNavigation setting.
|
|
12
|
+
|
|
10
13
|
import React from 'react'
|
|
11
14
|
import { getNavItemsWithComputed, NavItem, NavItemComponent } from './NavItemComponent'
|
|
12
15
|
import { parseMarkdownMini } from './parseMarkdownMini'
|
|
@@ -23,17 +26,18 @@ import { Style } from './utils/Style'
|
|
|
23
26
|
import { cls } from './utils/cls'
|
|
24
27
|
import { iconBooks } from './icons'
|
|
25
28
|
import { EditLink } from './EditLink'
|
|
29
|
+
import type { PageContext } from 'vike/types'
|
|
26
30
|
|
|
27
31
|
const blockMargin = 3
|
|
28
32
|
const mainViewPadding = 20
|
|
29
|
-
const
|
|
30
|
-
const
|
|
33
|
+
const mainViewWidthMaxInner = 800
|
|
34
|
+
const mainViewWidthMax = (mainViewWidthMaxInner + mainViewPadding * 2) as 840 // 840 = 800 + 20 * 2
|
|
31
35
|
const navLeftWidthMin = 300
|
|
32
36
|
const navLeftWidthMax = 370
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
+
const viewMobile = 450
|
|
38
|
+
const viewTablet = 1000
|
|
39
|
+
const viewDesktop = (mainViewWidthMax + navLeftWidthMin) as 1140 // 1140 = 840 + 300
|
|
40
|
+
const viewDesktopLarge = (mainViewWidthMax + navLeftWidthMax + blockMargin) as 1213 // 1213 = 840 + 370 + 3
|
|
37
41
|
|
|
38
42
|
// Avoid whitespace at the bottom of pages with almost no content
|
|
39
43
|
const whitespaceBuster1: React.CSSProperties = {
|
|
@@ -61,38 +65,29 @@ function Layout({ children }: { children: React.ReactNode }) {
|
|
|
61
65
|
style={{
|
|
62
66
|
['--bg-color']: '#f5f5f5',
|
|
63
67
|
['--block-margin']: `${blockMargin}px`,
|
|
64
|
-
['--icon-text-padding']: '8px',
|
|
65
68
|
// ['--nav-head-height']: `${isLandingPage ? 70 : 63}px`,
|
|
66
69
|
['--nav-head-height']: `63px`,
|
|
70
|
+
['--main-view-padding']: `${mainViewPadding}px`,
|
|
71
|
+
// We don't add `container` to `body` nor `html` beacuse in Firefox it breaks the `position: fixed` of <MenuModal>
|
|
72
|
+
// https://stackoverflow.com/questions/74601420/css-container-inline-size-and-fixed-child
|
|
73
|
+
container: 'container-viewport / inline-size',
|
|
67
74
|
}}
|
|
68
75
|
>
|
|
69
76
|
<MenuModal isTopNav={isLandingPage} />
|
|
70
|
-
<div
|
|
71
|
-
className={isLandingPage ? '' : 'doc-page'}
|
|
72
|
-
style={{
|
|
73
|
-
// We don't add `container` to `body` nor `html` beacuse in Firefox it breaks the `position: fixed` of <MenuModal>
|
|
74
|
-
// https://stackoverflow.com/questions/74601420/css-container-inline-size-and-fixed-child
|
|
75
|
-
container: 'container-viewport / inline-size',
|
|
76
|
-
...whitespaceBuster1,
|
|
77
|
-
}}
|
|
78
|
-
>
|
|
77
|
+
<div className={isLandingPage ? '' : 'doc-page'} style={whitespaceBuster1}>
|
|
79
78
|
<NavHead />
|
|
80
79
|
{content}
|
|
81
80
|
</div>
|
|
82
81
|
{/* Early toggling, to avoid layout jumps */}
|
|
83
82
|
<script dangerouslySetInnerHTML={{ __html: initializeJsToggle_SSR }}></script>
|
|
83
|
+
<Style>{getStyleNav()}</Style>
|
|
84
84
|
</div>
|
|
85
85
|
)
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
function LayoutDocsPage({ children }: { children: React.ReactNode }) {
|
|
89
|
-
const pageContext = usePageContext()
|
|
90
|
-
const hideNavLeftAlways =
|
|
91
|
-
pageContext.resolved.pageDesign?.hideMenuLeft ||
|
|
92
|
-
(pageContext.resolved.navItemsDetached && pageContext.resolved.navItemsDetached.length <= 1)
|
|
93
89
|
return (
|
|
94
90
|
<>
|
|
95
|
-
<Style>{getStyle()}</Style>
|
|
96
91
|
<div style={{ display: 'flex', ...whitespaceBuster2 }}>
|
|
97
92
|
<NavLeft />
|
|
98
93
|
<div
|
|
@@ -102,52 +97,18 @@ function LayoutDocsPage({ children }: { children: React.ReactNode }) {
|
|
|
102
97
|
/>
|
|
103
98
|
<PageContent>{children}</PageContent>
|
|
104
99
|
</div>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
function getStyle() {
|
|
108
|
-
let style = css`
|
|
109
|
-
@container container-viewport (min-width: ${containerQueryExtraSpace}px) {
|
|
100
|
+
<Style>{css`
|
|
101
|
+
@container container-viewport (min-width: ${viewDesktopLarge}px) {
|
|
110
102
|
.low-prio-grow {
|
|
111
103
|
flex-grow: 1;
|
|
112
104
|
}
|
|
113
105
|
#navigation-container {
|
|
114
106
|
width: ${navLeftWidthMax}px !important;
|
|
115
107
|
}
|
|
116
|
-
}`
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
display: none;
|
|
120
|
-
}
|
|
121
|
-
.page-wrapper {
|
|
122
|
-
--main-view-padding: 10px !important;
|
|
123
|
-
flex-grow: 1;
|
|
124
|
-
align-items: center;
|
|
125
|
-
}
|
|
126
|
-
.page-content {
|
|
127
|
-
margin: auto;
|
|
128
|
-
}
|
|
129
|
-
#menu-modal-wrapper {
|
|
130
|
-
position: absolute !important;
|
|
131
|
-
}
|
|
132
|
-
`
|
|
133
|
-
if (!hideNavLeftAlways) {
|
|
134
|
-
navLeftHidden = css`
|
|
135
|
-
@container container-viewport (max-width: ${containerQueryMobileLayout - 1}px) {
|
|
136
|
-
${navLeftHidden}
|
|
137
|
-
}
|
|
138
|
-
@container container-viewport (min-width: ${containerQueryMobileLayout}px) {
|
|
139
|
-
.nav-head-full-width {
|
|
140
|
-
display: none !important;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
`
|
|
144
|
-
}
|
|
145
|
-
style += navLeftHidden
|
|
146
|
-
|
|
147
|
-
return style
|
|
148
|
-
}
|
|
108
|
+
}`}</Style>
|
|
109
|
+
</>
|
|
110
|
+
)
|
|
149
111
|
}
|
|
150
|
-
|
|
151
112
|
function LayoutLandingPage({ children }: { children: React.ReactNode }) {
|
|
152
113
|
return (
|
|
153
114
|
<>
|
|
@@ -164,7 +125,7 @@ function PageContent({ children }: { children: React.ReactNode }) {
|
|
|
164
125
|
const { globalNote } = pageContext.globalContext.config.docpress
|
|
165
126
|
*/
|
|
166
127
|
const ifDocPage = (style: React.CSSProperties) => (isLandingPage ? {} : style)
|
|
167
|
-
const contentMaxWidth = pageContext.resolved.pageDesign?.contentMaxWidth ??
|
|
128
|
+
const contentMaxWidth = pageContext.resolved.pageDesign?.contentMaxWidth ?? mainViewWidthMaxInner
|
|
168
129
|
return (
|
|
169
130
|
<div
|
|
170
131
|
className="page-wrapper low-prio-grow"
|
|
@@ -180,8 +141,6 @@ function PageContent({ children }: { children: React.ReactNode }) {
|
|
|
180
141
|
<div
|
|
181
142
|
className="page-content"
|
|
182
143
|
style={{
|
|
183
|
-
// Also define --main-view-padding for landing page because it's used by <Contributors> and <Sponsors>
|
|
184
|
-
['--main-view-padding']: `${mainViewPadding}px`,
|
|
185
144
|
...ifDocPage({
|
|
186
145
|
width: `calc(${contentMaxWidth}px + 2 * var(--main-view-padding))`,
|
|
187
146
|
maxWidth: '100%',
|
|
@@ -222,7 +181,7 @@ function NavLeft() {
|
|
|
222
181
|
top: 0,
|
|
223
182
|
}}
|
|
224
183
|
>
|
|
225
|
-
<NavHead isNavLeft={true} />
|
|
184
|
+
{!isNavLeftAlwaysHidden(pageContext) && <NavHead isNavLeft={true} />}
|
|
226
185
|
<div
|
|
227
186
|
style={{
|
|
228
187
|
backgroundColor: 'var(--bg-color)',
|
|
@@ -275,37 +234,48 @@ function NavigationContent(props: {
|
|
|
275
234
|
)
|
|
276
235
|
}
|
|
277
236
|
|
|
237
|
+
function isNavLeftAlwaysHidden(pageContext: PageContext) {
|
|
238
|
+
const { isLandingPage, navItemsDetached, pageDesign } = pageContext.resolved
|
|
239
|
+
return isLandingPage || pageDesign?.hideMenuLeft || (navItemsDetached && navItemsDetached.length <= 1)
|
|
240
|
+
}
|
|
241
|
+
|
|
278
242
|
const menuLinkStyle: React.CSSProperties = {
|
|
279
243
|
height: '100%',
|
|
280
244
|
padding: '0 var(--padding-side)',
|
|
281
245
|
justifyContent: 'center',
|
|
282
246
|
}
|
|
283
247
|
|
|
248
|
+
// Two <NavHead> instances are rendered:
|
|
249
|
+
// - The left-side <NavHead> shown on documentation pages on desktop
|
|
250
|
+
// - The top <NavHead> shown otherwise
|
|
284
251
|
function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
285
252
|
const pageContext = usePageContext()
|
|
286
|
-
const { isLandingPage } = pageContext.resolved
|
|
287
253
|
const { navMaxWidth, name, algolia } = pageContext.globalContext.config.docpress
|
|
254
|
+
const hideNavHeadLogo = pageContext.resolved.isLandingPage && !navMaxWidth
|
|
288
255
|
|
|
289
|
-
const
|
|
256
|
+
const navHeadSecondary = (
|
|
290
257
|
<div
|
|
291
|
-
className={
|
|
258
|
+
className={cls([
|
|
259
|
+
'nav-head-secondary',
|
|
260
|
+
isNavLeft && 'show-on-nav-hover add-transition',
|
|
261
|
+
!!navMaxWidth && 'has-max-width',
|
|
262
|
+
])}
|
|
292
263
|
style={{
|
|
293
264
|
padding: 0,
|
|
294
265
|
display: 'flex',
|
|
295
266
|
height: '100%',
|
|
296
|
-
...(
|
|
297
|
-
? {
|
|
298
|
-
: {
|
|
267
|
+
...(isNavLeft
|
|
268
|
+
? {
|
|
299
269
|
position: 'absolute',
|
|
300
270
|
left: '100%',
|
|
301
271
|
top: 0,
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
272
|
+
width: mainViewWidthMax, // guaranteed real estate
|
|
273
|
+
}
|
|
274
|
+
: {}),
|
|
305
275
|
}}
|
|
306
276
|
>
|
|
307
277
|
{pageContext.globalContext.config.docpress.topNavigation}
|
|
308
|
-
|
|
278
|
+
<div className="desktop-grow" style={{ display: 'none' }} />
|
|
309
279
|
<ExternalLinks
|
|
310
280
|
style={{
|
|
311
281
|
display: 'inline-flex',
|
|
@@ -319,7 +289,7 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
|
319
289
|
|
|
320
290
|
return (
|
|
321
291
|
<div
|
|
322
|
-
className={cls(['nav-head
|
|
292
|
+
className={cls(['nav-head', isNavLeft && 'is-nav-left', 'link-hover-animation'])}
|
|
323
293
|
style={{
|
|
324
294
|
display: 'flex',
|
|
325
295
|
justifyContent: isNavLeft ? 'flex-end' : 'center',
|
|
@@ -328,9 +298,10 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
|
328
298
|
position: 'relative',
|
|
329
299
|
}}
|
|
330
300
|
>
|
|
331
|
-
{isNavLeft && <
|
|
301
|
+
{isNavLeft && <NavHeadLeftFullWidthBackground />}
|
|
332
302
|
<div
|
|
333
303
|
style={{
|
|
304
|
+
// DON'T REMOVE this container: it's needed for the `cqw` values
|
|
334
305
|
container: 'container-nav-head / inline-size',
|
|
335
306
|
width: '100%',
|
|
336
307
|
minWidth: isNavLeft && navLeftWidthMin,
|
|
@@ -344,107 +315,160 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
|
344
315
|
maxWidth: navMaxWidth,
|
|
345
316
|
margin: 'auto',
|
|
346
317
|
height: 'var(--nav-head-height)',
|
|
347
|
-
fontSize: `min(
|
|
318
|
+
fontSize: `min(14.2px, ${isProjectNameShort(name) ? '4.8cqw' : '4.5cqw'})`,
|
|
348
319
|
color: '#666',
|
|
349
|
-
['--icon-text-padding']: 'min(8px, 1.8cqw)',
|
|
350
320
|
display: 'flex',
|
|
351
321
|
justifyContent: 'center',
|
|
352
322
|
}}
|
|
353
323
|
>
|
|
354
|
-
<
|
|
355
|
-
|
|
356
|
-
{algolia && <SearchLink className="
|
|
357
|
-
<MenuToggleMain className="
|
|
358
|
-
{
|
|
324
|
+
{!hideNavHeadLogo && <NavHeadLogo />}
|
|
325
|
+
<div className="desktop-grow" style={{ display: 'none' }} />
|
|
326
|
+
{algolia && <SearchLink className="always-shown" style={menuLinkStyle} />}
|
|
327
|
+
<MenuToggleMain className="always-shown nav-head-menu-toggle" style={menuLinkStyle} />
|
|
328
|
+
{navHeadSecondary}
|
|
359
329
|
</div>
|
|
360
330
|
</div>
|
|
361
|
-
<Style>{getStyle()}</Style>
|
|
362
331
|
</div>
|
|
363
332
|
)
|
|
333
|
+
}
|
|
334
|
+
function getStyleNav() {
|
|
335
|
+
const pageContext = usePageContext()
|
|
364
336
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
337
|
+
let style = ''
|
|
338
|
+
|
|
339
|
+
// Mobile
|
|
340
|
+
style += css`
|
|
341
|
+
@container container-viewport (max-width: ${viewMobile}px) {
|
|
342
|
+
.nav-head:not(.is-nav-left) {
|
|
343
|
+
.nav-head-logo {
|
|
344
|
+
always-shown: flex-start !important;
|
|
345
|
+
padding-left: var(--main-view-padding);
|
|
346
|
+
}
|
|
347
|
+
.nav-head-menu-toggle {
|
|
348
|
+
justify-content: flex-end !important;
|
|
349
|
+
padding-right: var(--main-view-padding) !important;
|
|
350
|
+
}
|
|
351
|
+
.nav-head-content {
|
|
352
|
+
--icon-text-padding: min(8px, 1.3cqw);
|
|
353
|
+
& > * {
|
|
354
|
+
flex-grow: 1;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
370
357
|
}
|
|
371
|
-
|
|
372
|
-
|
|
358
|
+
}`
|
|
359
|
+
|
|
360
|
+
// Mobile + tablet
|
|
361
|
+
style += css`
|
|
362
|
+
@container container-viewport (max-width: ${viewTablet}px) {
|
|
363
|
+
.nav-head:not(.is-nav-left) {
|
|
364
|
+
.nav-head-secondary {
|
|
365
|
+
display: none !important;
|
|
366
|
+
}
|
|
373
367
|
}
|
|
374
|
-
|
|
375
|
-
|
|
368
|
+
}`
|
|
369
|
+
|
|
370
|
+
// Tablet
|
|
371
|
+
style += css`
|
|
372
|
+
@container container-viewport (max-width: ${viewTablet}px) and (min-width: ${viewMobile + 1}px) {
|
|
373
|
+
.nav-head:not(.is-nav-left) {
|
|
374
|
+
.nav-head-content {
|
|
375
|
+
--icon-text-padding: 8px;
|
|
376
|
+
--padding-side: 20px;
|
|
377
|
+
}
|
|
378
|
+
.nav-head-logo {
|
|
379
|
+
padding: 0 var(--padding-side);
|
|
380
|
+
}
|
|
376
381
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
382
|
+
}`
|
|
383
|
+
|
|
384
|
+
// Desktop small + desktop
|
|
385
|
+
style += css`
|
|
386
|
+
@container container-viewport (min-width: ${viewTablet + 1}px) {
|
|
387
|
+
.nav-head:not(.is-nav-left) {
|
|
388
|
+
.nav-head-content {
|
|
389
|
+
--icon-text-padding: min(8px, 0.5cqw);
|
|
390
|
+
--padding-side: min(20px, 1.3cqw);
|
|
391
|
+
}
|
|
392
|
+
.nav-head-logo {
|
|
393
|
+
padding: 0 var(--padding-side);
|
|
394
|
+
}
|
|
395
|
+
&.has-max-width {
|
|
396
|
+
.desktop-grow {
|
|
397
|
+
display: block;
|
|
398
|
+
}
|
|
399
|
+
.desktop-grow,
|
|
400
|
+
.nav-head-secondary {
|
|
401
|
+
flex-grow: 1;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
381
404
|
}
|
|
382
405
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
406
|
+
`
|
|
407
|
+
|
|
408
|
+
// Desktop
|
|
409
|
+
if (!isNavLeftAlwaysHidden(pageContext)) {
|
|
410
|
+
style += css`
|
|
411
|
+
@container container-viewport (min-width: ${viewDesktop}px) {
|
|
412
|
+
.nav-head:not(.is-nav-left) {
|
|
413
|
+
display: none !important;
|
|
386
414
|
}
|
|
387
|
-
.nav-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
415
|
+
.nav-head.is-nav-left {
|
|
416
|
+
.nav-head-content {
|
|
417
|
+
--icon-text-padding: min(8px, 7 * (1cqw - 2.5px));
|
|
418
|
+
& > :not(.always-shown) {
|
|
419
|
+
--padding-side: min(24px, 27 * (1cqw - 2.5px));
|
|
420
|
+
}
|
|
421
|
+
& > * {
|
|
422
|
+
flex-grow: 0.5;
|
|
423
|
+
}
|
|
424
|
+
& > .nav-head-menu-toggle {
|
|
425
|
+
flex-grow: 1;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
.nav-head-logo {
|
|
429
|
+
padding-left: 15px;
|
|
430
|
+
margin-left: -15px;
|
|
431
|
+
}
|
|
391
432
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
433
|
+
.show-on-nav-hover {
|
|
434
|
+
opacity: 0;
|
|
435
|
+
transition-property: opacity;
|
|
436
|
+
pointer-events: none;
|
|
396
437
|
}
|
|
397
|
-
.nav
|
|
398
|
-
|
|
438
|
+
html:not(.unexpand-nav) {
|
|
439
|
+
& .nav-head.is-nav-left:hover .show-on-nav-hover,
|
|
440
|
+
&:has(.nav-head:hover) #menu-modal-wrapper.show-on-nav-hover,
|
|
441
|
+
&.menu-modal-show .nav-head.is-nav-left .show-on-nav-hover,
|
|
442
|
+
&.menu-modal-show #menu-modal-wrapper.show-on-nav-hover {
|
|
443
|
+
opacity: 1;
|
|
444
|
+
pointer-events: all;
|
|
445
|
+
}
|
|
399
446
|
}
|
|
400
447
|
}
|
|
401
|
-
@container container-
|
|
402
|
-
|
|
403
|
-
|
|
448
|
+
@container container-viewport (max-width: ${viewDesktop - 1}px) {
|
|
449
|
+
#nav-left, #nav-left-margin {
|
|
450
|
+
display: none;
|
|
404
451
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
.hide-on-shrink {
|
|
408
|
-
display: none !important;
|
|
452
|
+
body {
|
|
453
|
+
--main-view-padding: 10px !important;
|
|
409
454
|
}
|
|
410
|
-
|
|
411
|
-
`
|
|
412
|
-
if (navMaxWidth) {
|
|
413
|
-
style += css`
|
|
414
|
-
@media(min-width: ${containerQueryMobileNav + 1}px) {
|
|
415
|
-
.desktop-grow {
|
|
455
|
+
.page-wrapper {
|
|
416
456
|
flex-grow: 1;
|
|
457
|
+
align-items: center;
|
|
417
458
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
@media(min-width: ${containerQueryMobileNav + 1}px) {
|
|
424
|
-
.nav-logo {
|
|
425
|
-
display: none !important;
|
|
459
|
+
.page-content {
|
|
460
|
+
margin: auto;
|
|
461
|
+
}
|
|
462
|
+
#menu-modal-wrapper {
|
|
463
|
+
position: absolute !important;
|
|
426
464
|
}
|
|
427
465
|
}
|
|
428
466
|
`
|
|
429
|
-
if (isNavLeft) {
|
|
430
|
-
style += css`
|
|
431
|
-
|
|
432
|
-
.show-on-nav-hover {
|
|
433
|
-
opacity: 0;
|
|
434
|
-
transition-property: opacity;
|
|
435
|
-
pointer-events: none;
|
|
436
|
-
}
|
|
437
|
-
html:not(.unexpand-nav) :has(.nav-head-top:hover) .show-on-nav-hover,
|
|
438
|
-
html:not(.unexpand-nav) :has(.show-on-nav-hover:hover) .show-on-nav-hover,
|
|
439
|
-
html:not(.unexpand-nav).menu-modal-show .show-on-nav-hover {
|
|
440
|
-
opacity: 1;
|
|
441
|
-
pointer-events: all;
|
|
442
|
-
}
|
|
443
|
-
`
|
|
444
|
-
}
|
|
445
|
-
return style
|
|
446
467
|
}
|
|
468
|
+
|
|
469
|
+
return style
|
|
447
470
|
}
|
|
471
|
+
|
|
448
472
|
function unexpandNav() {
|
|
449
473
|
document.documentElement.classList.add('unexpand-nav')
|
|
450
474
|
// Using setTimeout() because requestAnimationFrame() doesn't delay enough
|
|
@@ -453,11 +477,11 @@ function unexpandNav() {
|
|
|
453
477
|
}, 1000)
|
|
454
478
|
}
|
|
455
479
|
|
|
456
|
-
function
|
|
480
|
+
function NavHeadLeftFullWidthBackground() {
|
|
457
481
|
return (
|
|
458
482
|
<>
|
|
459
483
|
<div
|
|
460
|
-
className="nav-bg show-on-nav-hover add-transition"
|
|
484
|
+
className="nav-head-bg show-on-nav-hover add-transition"
|
|
461
485
|
style={{
|
|
462
486
|
height: '100%',
|
|
463
487
|
zIndex: -1,
|
|
@@ -473,7 +497,7 @@ function NavHeaderLeftFullWidthBackground() {
|
|
|
473
497
|
// (min-width: 0px) => trick to always apply => @container seems to always require a condition
|
|
474
498
|
css`
|
|
475
499
|
@container container-viewport (min-width: 0px) {
|
|
476
|
-
.nav-bg {
|
|
500
|
+
.nav-head-bg {
|
|
477
501
|
width: 100cqw;
|
|
478
502
|
}
|
|
479
503
|
}
|
|
@@ -483,7 +507,7 @@ function NavHeaderLeftFullWidthBackground() {
|
|
|
483
507
|
)
|
|
484
508
|
}
|
|
485
509
|
|
|
486
|
-
function
|
|
510
|
+
function NavHeadLogo({ className }: { className?: string }) {
|
|
487
511
|
const pageContext = usePageContext()
|
|
488
512
|
|
|
489
513
|
const { navLogo } = pageContext.globalContext.config.docpress
|
|
@@ -517,7 +541,7 @@ function NavLogo({ className }: { className: string }) {
|
|
|
517
541
|
|
|
518
542
|
return (
|
|
519
543
|
<a
|
|
520
|
-
className={cls(['nav-logo', className])}
|
|
544
|
+
className={cls(['nav-head-logo', className])}
|
|
521
545
|
style={{
|
|
522
546
|
display: 'flex',
|
|
523
547
|
alignItems: 'center',
|
|
@@ -554,12 +578,12 @@ function MenuToggleMain(props: PropsDiv) {
|
|
|
554
578
|
<MenuIcon /> Menu
|
|
555
579
|
</span>
|
|
556
580
|
<Style>{css`
|
|
557
|
-
@
|
|
581
|
+
@container container-viewport (max-width: ${viewTablet}px) {
|
|
558
582
|
.text-docs, .caret-icon {
|
|
559
583
|
display: none !important;
|
|
560
584
|
}
|
|
561
585
|
}
|
|
562
|
-
@
|
|
586
|
+
@container container-viewport (min-width: ${viewTablet + 1}px) {
|
|
563
587
|
.text-menu {
|
|
564
588
|
display: none;
|
|
565
589
|
}
|
|
@@ -588,10 +612,12 @@ function MenuToggle({ menuId, ...props }: PropsDiv & { menuId: number }) {
|
|
|
588
612
|
}}
|
|
589
613
|
onMouseEnter={() => {
|
|
590
614
|
if (onMouseIgnore) return
|
|
615
|
+
if (isMobileNav()) return
|
|
591
616
|
openMenuModal(menuId)
|
|
592
617
|
}}
|
|
593
618
|
onMouseLeave={() => {
|
|
594
619
|
if (onMouseIgnore) return
|
|
620
|
+
if (isMobileNav()) return
|
|
595
621
|
coseMenuModalOnMouseLeave(menuId)
|
|
596
622
|
}}
|
|
597
623
|
onTouchStart={() => {
|
|
@@ -605,11 +631,11 @@ function MenuToggle({ menuId, ...props }: PropsDiv & { menuId: number }) {
|
|
|
605
631
|
<CaretIcon
|
|
606
632
|
style={{
|
|
607
633
|
width: 11,
|
|
608
|
-
marginLeft:
|
|
634
|
+
marginLeft: 'calc(var(--icon-text-padding) - 1px)',
|
|
609
635
|
flexShrink: 0,
|
|
610
636
|
color: '#888',
|
|
611
637
|
position: 'relative',
|
|
612
|
-
top:
|
|
638
|
+
top: 1,
|
|
613
639
|
}}
|
|
614
640
|
/>
|
|
615
641
|
</div>
|
|
@@ -687,7 +713,7 @@ function DocsIcon() {
|
|
|
687
713
|
<img
|
|
688
714
|
src={iconBooks}
|
|
689
715
|
width={18}
|
|
690
|
-
style={{ marginRight: 'calc(var(--icon-text-padding) + 2px)' }}
|
|
716
|
+
style={{ marginRight: 'calc(var(--icon-text-padding) + 2px)', position: 'relative', top: 2 }}
|
|
691
717
|
className="decolorize-5"
|
|
692
718
|
/>
|
|
693
719
|
)
|
|
@@ -706,3 +732,7 @@ function MenuIcon() {
|
|
|
706
732
|
</svg>
|
|
707
733
|
)
|
|
708
734
|
}
|
|
735
|
+
|
|
736
|
+
function isMobileNav() {
|
|
737
|
+
return window.innerWidth <= viewTablet
|
|
738
|
+
}
|