@brillout/docpress 0.8.14 → 0.8.16
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/Layout.tsx +256 -179
- package/MenuModal.tsx +54 -46
- package/{Links.tsx → NavSecondaryContent.tsx} +5 -8
- package/components/HorizontalLine.tsx +4 -3
- package/components/Note.tsx +6 -2
- package/config/resolveHeadingsData.ts +7 -10
- package/css/code/block.css +5 -5
- package/css/code/inline.css +1 -1
- package/css/colorize-on-hover.css +2 -2
- package/dist/Layout.d.ts +10 -6
- package/dist/Layout.js +167 -122
- package/dist/MenuModal.d.ts +2 -0
- package/dist/MenuModal.js +46 -46
- package/dist/{Links.d.ts → NavSecondaryContent.d.ts} +3 -2
- package/dist/{Links.js → NavSecondaryContent.js} +5 -7
- package/dist/components/HorizontalLine.d.ts +1 -1
- package/dist/components/HorizontalLine.js +3 -2
- package/dist/components/Note.js +4 -3
- package/dist/config/resolveHeadingsData.d.ts +3 -4
- package/dist/config/resolveHeadingsData.js +5 -8
- package/dist/config/resolvePageContext.d.ts +2 -3
- package/dist/docsearch/SearchLink.js +1 -1
- package/dist/navigation/Collapsible.d.ts +10 -0
- package/dist/navigation/Collapsible.js +35 -0
- package/dist/navigation/Navigation.d.ts +0 -3
- package/dist/navigation/Navigation.js +106 -55
- package/dist/renderer/determineNavItemsColumnLayout.d.ts +3 -0
- package/dist/renderer/{determineColumnEntries.js → determineNavItemsColumnLayout.js} +34 -28
- package/dist/renderer/usePageContext.d.ts +2 -2
- package/dist/renderer/usePageContext.js +2 -4
- package/dist/utils/Style.d.ts +5 -0
- package/dist/utils/Style.js +6 -0
- package/dist/utils/cls.d.ts +3 -0
- package/dist/utils/cls.js +5 -0
- package/dist/utils/throttle.d.ts +1 -0
- package/dist/utils/throttle.js +14 -0
- package/docsearch/SearchLink.tsx +1 -1
- package/global.d.ts +1 -1
- package/navigation/Collapsible.css +11 -0
- package/navigation/Collapsible.tsx +64 -0
- package/navigation/Navigation.css +12 -6
- package/navigation/Navigation.tsx +191 -80
- package/package.json +1 -1
- package/renderer/{determineColumnEntries.ts → determineNavItemsColumnLayout.ts} +35 -29
- package/renderer/initOnNavigation.ts +37 -0
- package/renderer/onRenderClient.tsx +2 -0
- package/renderer/usePageContext.tsx +2 -5
- package/utils/Style.tsx +7 -0
- package/utils/cls.ts +8 -0
- package/utils/throttle.ts +10 -0
- package/dist/renderer/determineColumnEntries.d.ts +0 -3
package/Layout.tsx
CHANGED
|
@@ -1,35 +1,38 @@
|
|
|
1
1
|
export { Layout }
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
2
|
+
export { containerQueryMobileLayout }
|
|
3
|
+
export { containerQueryMobileMenu }
|
|
4
|
+
export { navLeftWidthMin }
|
|
5
|
+
export { navLeftWidthMax }
|
|
6
|
+
export { unexpandNav }
|
|
5
7
|
|
|
6
8
|
import React from 'react'
|
|
7
9
|
import { NavigationContent } from './navigation/Navigation'
|
|
8
10
|
import { EditPageNote } from './components/EditPageNote'
|
|
9
11
|
import { parseTitle } from './parseTitle'
|
|
10
12
|
import { usePageContext, usePageContext2 } from './renderer/usePageContext'
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
+
import { NavSecondaryContent } from './NavSecondaryContent'
|
|
14
|
+
import { closeMenuModalWithDelay, openMenuModal, toggleMenuModal } from './MenuModal'
|
|
13
15
|
import { MenuModal } from './MenuModal'
|
|
14
16
|
import { autoScrollNav_SSR } from './autoScrollNav'
|
|
15
17
|
import { SearchLink } from './docsearch/SearchLink'
|
|
16
18
|
import { navigate } from 'vike/client/router'
|
|
17
19
|
import { css } from './utils/css'
|
|
18
20
|
import { PassThrough } from './utils/PassTrough'
|
|
21
|
+
import { Style } from './utils/Style'
|
|
22
|
+
import { cls } from './utils/cls'
|
|
19
23
|
|
|
20
|
-
const mainViewWidthMax = 800
|
|
21
|
-
const mainViewPadding = 20
|
|
22
|
-
const navWidthMax = 370
|
|
23
|
-
const navWidthMin = 300
|
|
24
|
-
const navWidth = {
|
|
25
|
-
minWidth: navWidthMin,
|
|
26
|
-
maxWidth: navWidthMax,
|
|
27
|
-
width: '100%',
|
|
28
|
-
}
|
|
29
24
|
const blockMargin = 3
|
|
25
|
+
const mainViewPadding = 20
|
|
26
|
+
const mainViewWidthMax = 800
|
|
27
|
+
const navLeftWidthMax = 370
|
|
28
|
+
const navLeftWidthMin = 300
|
|
29
|
+
// 840 = 800 + 20 * 2
|
|
30
30
|
const mainViewMax = mainViewWidthMax + mainViewPadding * 2
|
|
31
|
-
const
|
|
32
|
-
|
|
31
|
+
const containerQueryMobileMenu = 1000
|
|
32
|
+
// 1143 = 840 + 300
|
|
33
|
+
const containerQueryMobileLayout = mainViewMax + navLeftWidthMin
|
|
34
|
+
// 1213 = 840 + 370 + 3
|
|
35
|
+
const containerQueryExtraSpace = mainViewMax + navLeftWidthMax + blockMargin
|
|
33
36
|
|
|
34
37
|
// Avoid whitespace at the bottom of pages with almost no content
|
|
35
38
|
const whitespaceBuster1: React.CSSProperties = {
|
|
@@ -58,7 +61,7 @@ function Layout({ children }: { children: React.ReactNode }) {
|
|
|
58
61
|
['--bg-color']: '#f5f5f7',
|
|
59
62
|
['--block-margin']: `${blockMargin}px`,
|
|
60
63
|
['--icon-text-padding']: '8px',
|
|
61
|
-
['--
|
|
64
|
+
['--nav-head-height']: `${isLandingPage ? 70 : 60}px`,
|
|
62
65
|
}}
|
|
63
66
|
>
|
|
64
67
|
<MenuModal isTopNav={isLandingPage} />
|
|
@@ -67,10 +70,11 @@ function Layout({ children }: { children: React.ReactNode }) {
|
|
|
67
70
|
style={{
|
|
68
71
|
// We don't add `container` to `body` nor `html` beacuse in Firefox it breaks the `position: fixed` of <MenuModal>
|
|
69
72
|
// https://stackoverflow.com/questions/74601420/css-container-inline-size-and-fixed-child
|
|
70
|
-
|
|
73
|
+
container: 'container-viewport / inline-size',
|
|
71
74
|
...whitespaceBuster1,
|
|
72
75
|
}}
|
|
73
76
|
>
|
|
77
|
+
<NavHead />
|
|
74
78
|
{content}
|
|
75
79
|
</div>
|
|
76
80
|
</div>
|
|
@@ -79,11 +83,10 @@ function Layout({ children }: { children: React.ReactNode }) {
|
|
|
79
83
|
|
|
80
84
|
function LayoutDocsPage({ children }: { children: React.ReactNode }) {
|
|
81
85
|
const pageContext = usePageContext()
|
|
82
|
-
const hideNavLeftAlways = pageContext.
|
|
86
|
+
const hideNavLeftAlways = pageContext.navItemsDetached && pageContext.navItemsDetached.length <= 1
|
|
83
87
|
return (
|
|
84
88
|
<>
|
|
85
89
|
<style>{getStyle()}</style>
|
|
86
|
-
<NavMobile />
|
|
87
90
|
<div style={{ display: 'flex', ...whitespaceBuster2 }}>
|
|
88
91
|
<NavLeft />
|
|
89
92
|
<div className="low-prio-grow" style={{ width: 0, maxWidth: 50, background: 'var(--bg-color)' }} />
|
|
@@ -93,12 +96,12 @@ function LayoutDocsPage({ children }: { children: React.ReactNode }) {
|
|
|
93
96
|
)
|
|
94
97
|
function getStyle() {
|
|
95
98
|
let style = css`
|
|
96
|
-
@container(min-width: ${
|
|
99
|
+
@container container-viewport (min-width: ${containerQueryExtraSpace}px) {
|
|
97
100
|
.low-prio-grow {
|
|
98
101
|
flex-grow: 1;
|
|
99
102
|
}
|
|
100
103
|
#navigation-container {
|
|
101
|
-
width: ${
|
|
104
|
+
width: ${navLeftWidthMax}px !important;
|
|
102
105
|
}
|
|
103
106
|
}`
|
|
104
107
|
let navLeftHide = css`
|
|
@@ -119,11 +122,11 @@ function LayoutDocsPage({ children }: { children: React.ReactNode }) {
|
|
|
119
122
|
`
|
|
120
123
|
if (!hideNavLeftAlways) {
|
|
121
124
|
navLeftHide = css`
|
|
122
|
-
@container(max-width: ${
|
|
125
|
+
@container container-viewport (max-width: ${containerQueryMobileLayout - 1}px) {
|
|
123
126
|
${navLeftHide}
|
|
124
127
|
}
|
|
125
|
-
@container(min-width: ${
|
|
126
|
-
|
|
128
|
+
@container container-viewport (min-width: ${containerQueryMobileLayout}px) {
|
|
129
|
+
.nav-head-top {
|
|
127
130
|
display: none !important;
|
|
128
131
|
}
|
|
129
132
|
}
|
|
@@ -136,28 +139,11 @@ function LayoutDocsPage({ children }: { children: React.ReactNode }) {
|
|
|
136
139
|
}
|
|
137
140
|
|
|
138
141
|
function LayoutLandingPage({ children }: { children: React.ReactNode }) {
|
|
139
|
-
const mobile = 800
|
|
140
142
|
return (
|
|
141
143
|
<>
|
|
142
|
-
<style>{getStyle()}</style>
|
|
143
|
-
<NavTop />
|
|
144
|
-
<NavMobile />
|
|
145
144
|
<PageContent>{children}</PageContent>
|
|
146
145
|
</>
|
|
147
146
|
)
|
|
148
|
-
function getStyle() {
|
|
149
|
-
return css`
|
|
150
|
-
@container(min-width: ${mobile}px) {
|
|
151
|
-
#nav-mobile {
|
|
152
|
-
display: none !important;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
@container(max-width: ${mobile - 1}px) {
|
|
156
|
-
#top-navigation {
|
|
157
|
-
display: none !important;
|
|
158
|
-
}
|
|
159
|
-
`
|
|
160
|
-
}
|
|
161
147
|
}
|
|
162
148
|
|
|
163
149
|
function PageContent({ children }: { children: React.ReactNode }) {
|
|
@@ -199,50 +185,9 @@ function PageContent({ children }: { children: React.ReactNode }) {
|
|
|
199
185
|
)
|
|
200
186
|
}
|
|
201
187
|
|
|
202
|
-
function NavMobile() {
|
|
203
|
-
return (
|
|
204
|
-
<div id="nav-mobile">
|
|
205
|
-
<NavigationHeader iconSize={40} paddingLeft={12} style={{ justifyContent: 'center' }} />
|
|
206
|
-
</div>
|
|
207
|
-
)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function NavTop() {
|
|
211
|
-
const pageContext2 = usePageContext2()
|
|
212
|
-
const paddingSize = 35
|
|
213
|
-
const padding = `0 ${paddingSize}px`
|
|
214
|
-
const TopNavigation = pageContext2.config.TopNavigation || PassThrough
|
|
215
|
-
return (
|
|
216
|
-
<div
|
|
217
|
-
id="top-navigation"
|
|
218
|
-
className="link-hover-animation"
|
|
219
|
-
style={{
|
|
220
|
-
position: 'relative',
|
|
221
|
-
display: 'flex',
|
|
222
|
-
alignItems: 'center',
|
|
223
|
-
justifyContent: 'center',
|
|
224
|
-
textDecoration: 'none',
|
|
225
|
-
marginBottom: 'var(--block-margin)',
|
|
226
|
-
backgroundColor: 'var(--bg-color)',
|
|
227
|
-
['--padding-side']: `${paddingSize}px`,
|
|
228
|
-
fontSize: '1.06em',
|
|
229
|
-
color: '#666',
|
|
230
|
-
}}
|
|
231
|
-
>
|
|
232
|
-
<div style={{ display: 'flex', alignItems: 'center', height: 70 }}>
|
|
233
|
-
<TopNavigation />
|
|
234
|
-
<SearchLink style={{ padding }} />
|
|
235
|
-
<MenuLink style={{ padding }} />
|
|
236
|
-
<Links style={{ display: 'inline-flex', padding, marginLeft: -8 }} />
|
|
237
|
-
</div>
|
|
238
|
-
</div>
|
|
239
|
-
)
|
|
240
|
-
}
|
|
241
|
-
|
|
242
188
|
function NavLeft() {
|
|
243
189
|
const pageContext = usePageContext()
|
|
244
|
-
const {
|
|
245
|
-
const headerHeight = 60
|
|
190
|
+
const { navItemsAll, navItemsDetached } = pageContext
|
|
246
191
|
return (
|
|
247
192
|
<>
|
|
248
193
|
<div
|
|
@@ -251,6 +196,7 @@ function NavLeft() {
|
|
|
251
196
|
style={{
|
|
252
197
|
flexGrow: 1,
|
|
253
198
|
borderRight: 'var(--block-margin) solid white',
|
|
199
|
+
zIndex: 1,
|
|
254
200
|
}}
|
|
255
201
|
>
|
|
256
202
|
<div
|
|
@@ -259,7 +205,7 @@ function NavLeft() {
|
|
|
259
205
|
top: 0,
|
|
260
206
|
}}
|
|
261
207
|
>
|
|
262
|
-
<
|
|
208
|
+
<NavHead isNavLeft={true} />
|
|
263
209
|
<div
|
|
264
210
|
style={{
|
|
265
211
|
backgroundColor: 'var(--bg-color)',
|
|
@@ -271,21 +217,20 @@ function NavLeft() {
|
|
|
271
217
|
id="navigation-container"
|
|
272
218
|
style={{
|
|
273
219
|
top: 0,
|
|
274
|
-
height: `calc(100vh -
|
|
220
|
+
height: `calc(100vh - var(--nav-head-height) - var(--block-margin))`,
|
|
275
221
|
overflowY: 'auto',
|
|
276
222
|
overscrollBehavior: 'contain',
|
|
277
223
|
paddingBottom: 40,
|
|
278
|
-
|
|
224
|
+
minWidth: navLeftWidthMin,
|
|
225
|
+
maxWidth: navLeftWidthMax,
|
|
226
|
+
width: '100%',
|
|
279
227
|
}}
|
|
280
228
|
>
|
|
281
|
-
{
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
<NavigationContent navItems={navItemsAll} showOnlyRelevant={true} />
|
|
287
|
-
)
|
|
288
|
-
}
|
|
229
|
+
{navItemsDetached ? (
|
|
230
|
+
<NavigationContent navItems={navItemsDetached} />
|
|
231
|
+
) : (
|
|
232
|
+
<NavigationContent navItems={navItemsAll} showOnlyRelevant={true} />
|
|
233
|
+
)}
|
|
289
234
|
</div>
|
|
290
235
|
</div>
|
|
291
236
|
</div>
|
|
@@ -296,109 +241,234 @@ function NavLeft() {
|
|
|
296
241
|
)
|
|
297
242
|
}
|
|
298
243
|
|
|
299
|
-
function
|
|
300
|
-
iconSize,
|
|
301
|
-
style,
|
|
302
|
-
paddingLeft,
|
|
303
|
-
}: { iconSize: number; paddingLeft: number; style?: React.CSSProperties }) {
|
|
244
|
+
function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
304
245
|
const pageContext = usePageContext()
|
|
305
|
-
|
|
246
|
+
const pageContext2 = usePageContext2()
|
|
306
247
|
const { projectName } = pageContext.meta
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
248
|
+
const { isLandingPage } = pageContext
|
|
249
|
+
|
|
250
|
+
const linkStyle: React.CSSProperties = {
|
|
251
|
+
height: '100%',
|
|
252
|
+
padding: '0 var(--padding-side)',
|
|
312
253
|
justifyContent: 'center',
|
|
313
|
-
fontSize: isProjectNameShort ? '4.8cqw' : '4.5cqw',
|
|
314
|
-
['--icon-text-padding']: '1.8cqw',
|
|
315
254
|
}
|
|
316
|
-
|
|
255
|
+
|
|
256
|
+
const TopNavigation = pageContext2.config.TopNavigation || PassThrough
|
|
257
|
+
const navSecondaryContent = (
|
|
258
|
+
<div
|
|
259
|
+
className={isNavLeft ? 'show-on-nav-hover add-transition' : 'hide-on-shrink'}
|
|
260
|
+
style={{
|
|
261
|
+
padding: 0,
|
|
262
|
+
display: 'flex',
|
|
263
|
+
height: '100%',
|
|
264
|
+
...(!isNavLeft
|
|
265
|
+
? {}
|
|
266
|
+
: {
|
|
267
|
+
position: 'absolute',
|
|
268
|
+
left: '100%',
|
|
269
|
+
top: 0,
|
|
270
|
+
paddingLeft: 'var(--block-margin)',
|
|
271
|
+
'--padding-side': '20px',
|
|
272
|
+
width: mainViewMax, // guaranteed real estate
|
|
273
|
+
}),
|
|
274
|
+
}}
|
|
275
|
+
>
|
|
276
|
+
<TopNavigation />
|
|
277
|
+
<NavSecondaryContent
|
|
278
|
+
style={{
|
|
279
|
+
display: 'inline-flex',
|
|
280
|
+
fontSize: '1.06em',
|
|
281
|
+
padding: '0 var(--padding-side)',
|
|
282
|
+
marginLeft: -8,
|
|
283
|
+
}}
|
|
284
|
+
/>
|
|
285
|
+
</div>
|
|
286
|
+
)
|
|
287
|
+
|
|
317
288
|
return (
|
|
318
289
|
<div
|
|
290
|
+
className={cls(['nav-head-full-width', !isNavLeft && 'nav-head-top', 'link-hover-animation'])}
|
|
319
291
|
style={{
|
|
320
|
-
backgroundColor: 'var(--bg-color)',
|
|
321
292
|
display: 'flex',
|
|
322
|
-
justifyContent: 'flex-end',
|
|
293
|
+
justifyContent: isNavLeft ? 'flex-end' : 'center',
|
|
294
|
+
backgroundColor: 'var(--bg-color)',
|
|
323
295
|
borderBottom: 'var(--block-margin) solid white',
|
|
324
|
-
|
|
296
|
+
position: 'relative',
|
|
325
297
|
}}
|
|
326
298
|
>
|
|
299
|
+
{isNavLeft && <NavHeaderLeftFullWidthBackground />}
|
|
327
300
|
<div
|
|
328
301
|
style={{
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
...navWidth,
|
|
302
|
+
container: 'container-nav-head / inline-size',
|
|
303
|
+
width: '100%',
|
|
304
|
+
minWidth: isNavLeft && navLeftWidthMin,
|
|
305
|
+
maxWidth: isNavLeft && navLeftWidthMax,
|
|
334
306
|
}}
|
|
335
307
|
>
|
|
336
|
-
<
|
|
308
|
+
<div
|
|
309
|
+
className="nav-head-content"
|
|
337
310
|
style={{
|
|
311
|
+
width: '100%',
|
|
312
|
+
height: 'var(--nav-head-height)',
|
|
313
|
+
fontSize: `min(16.96px, ${isProjectNameShort(projectName) ? '4.8cqw' : '4.5cqw'})`,
|
|
314
|
+
color: '#666',
|
|
315
|
+
['--icon-text-padding']: 'min(8px, 1.8cqw)',
|
|
338
316
|
display: 'flex',
|
|
339
|
-
|
|
340
|
-
color: 'inherit',
|
|
341
|
-
textDecoration: 'none',
|
|
342
|
-
height: '100%',
|
|
343
|
-
paddingLeft: paddingLeft + marginLeft * -1,
|
|
344
|
-
marginLeft: marginLeft,
|
|
345
|
-
...childrenStyle,
|
|
346
|
-
justifyContent: 'flex-start',
|
|
347
|
-
flexGrow: 0.5,
|
|
317
|
+
justifyContent: 'center',
|
|
348
318
|
}}
|
|
349
|
-
href="/"
|
|
350
319
|
>
|
|
351
|
-
<
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
if (!pageContext.config.pressKit) return // no /press page
|
|
357
|
-
if (window.location.pathname === '/press') return
|
|
358
|
-
ev.preventDefault()
|
|
359
|
-
navigate('/press#logo')
|
|
360
|
-
}}
|
|
361
|
-
/>
|
|
362
|
-
<span
|
|
363
|
-
style={{
|
|
364
|
-
marginLeft: `calc(var(--icon-text-padding) + 2px)`,
|
|
365
|
-
fontSize: isProjectNameShort ? '1.65em' : '1.3em',
|
|
366
|
-
}}
|
|
367
|
-
>
|
|
368
|
-
{projectName}
|
|
369
|
-
</span>
|
|
370
|
-
</a>
|
|
371
|
-
<SearchLink
|
|
372
|
-
style={{
|
|
373
|
-
//
|
|
374
|
-
...childrenStyle,
|
|
375
|
-
flexGrow: 0.5,
|
|
376
|
-
}}
|
|
377
|
-
/>
|
|
378
|
-
<MenuLink
|
|
379
|
-
style={{
|
|
380
|
-
//
|
|
381
|
-
...childrenStyle,
|
|
382
|
-
flexGrow: 1,
|
|
383
|
-
}}
|
|
384
|
-
/>
|
|
320
|
+
<NavLogo className="grow-half" />
|
|
321
|
+
<SearchLink className="grow-half" style={linkStyle} />
|
|
322
|
+
<MenuLink className="grow-full" style={linkStyle} />
|
|
323
|
+
{navSecondaryContent}
|
|
324
|
+
</div>
|
|
385
325
|
</div>
|
|
326
|
+
{getStyle()}
|
|
386
327
|
</div>
|
|
387
328
|
)
|
|
329
|
+
|
|
330
|
+
function getStyle() {
|
|
331
|
+
let style = css`
|
|
332
|
+
@container container-nav-head (max-width: 550px) {
|
|
333
|
+
.grow-full {
|
|
334
|
+
flex-grow: 1;
|
|
335
|
+
}
|
|
336
|
+
.grow-half {
|
|
337
|
+
flex-grow: 0.5;
|
|
338
|
+
}
|
|
339
|
+
.nav-head-content {
|
|
340
|
+
--padding-side: 0px;
|
|
341
|
+
}
|
|
342
|
+
.nav-logo {
|
|
343
|
+
padding-left: 15px;
|
|
344
|
+
margin-left: -10px;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
@container container-nav-head (min-width: 501px) {
|
|
348
|
+
.nav-head-content {
|
|
349
|
+
--padding-side: 35px;
|
|
350
|
+
}
|
|
351
|
+
.nav-logo {
|
|
352
|
+
padding: 0 var(--padding-side);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
@media(max-width: ${containerQueryMobileMenu}px) {
|
|
356
|
+
.hide-on-shrink {
|
|
357
|
+
display: none !important;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
`
|
|
361
|
+
if (isLandingPage)
|
|
362
|
+
style += css`
|
|
363
|
+
@media(min-width: ${containerQueryMobileMenu + 1}px) {
|
|
364
|
+
.nav-logo {
|
|
365
|
+
display: none !important;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
`
|
|
369
|
+
if (isNavLeft) {
|
|
370
|
+
style += css`
|
|
371
|
+
|
|
372
|
+
.show-on-nav-hover {
|
|
373
|
+
opacity: 0;
|
|
374
|
+
transition-property: opacity;
|
|
375
|
+
pointer-events: none;
|
|
376
|
+
}
|
|
377
|
+
html:not(.unexpand-nav) :has(.nav-head-full-width:hover) .show-on-nav-hover,
|
|
378
|
+
html:not(.unexpand-nav) :has(.show-on-nav-hover:hover) .show-on-nav-hover,
|
|
379
|
+
html:not(.unexpand-nav).menu-modal-show .show-on-nav-hover {
|
|
380
|
+
opacity: 1;
|
|
381
|
+
pointer-events: all;
|
|
382
|
+
}
|
|
383
|
+
`
|
|
384
|
+
}
|
|
385
|
+
return <Style>{style}</Style>
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
function unexpandNav() {
|
|
389
|
+
document.documentElement.classList.add('unexpand-nav')
|
|
390
|
+
// Using setTimeout() because requestAnimationFrame() doesn't delay enough
|
|
391
|
+
setTimeout(() => {
|
|
392
|
+
document.documentElement.classList.remove('unexpand-nav')
|
|
393
|
+
}, 1000)
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function NavHeaderLeftFullWidthBackground() {
|
|
397
|
+
return (
|
|
398
|
+
<div
|
|
399
|
+
className="show-on-nav-hover add-transition"
|
|
400
|
+
style={{
|
|
401
|
+
height: '100%',
|
|
402
|
+
width: '100vw',
|
|
403
|
+
zIndex: -1,
|
|
404
|
+
background: 'var(--bg-color)',
|
|
405
|
+
position: 'absolute',
|
|
406
|
+
left: 0,
|
|
407
|
+
top: 0,
|
|
408
|
+
boxSizing: 'content-box',
|
|
409
|
+
borderBottom: 'var(--block-margin) solid white',
|
|
410
|
+
}}
|
|
411
|
+
/>
|
|
412
|
+
)
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function NavLogo({ className }: { className: string }) {
|
|
416
|
+
const pageContext = usePageContext()
|
|
417
|
+
const iconSize = 39
|
|
418
|
+
const { projectName } = pageContext.meta
|
|
419
|
+
return (
|
|
420
|
+
<a
|
|
421
|
+
className={cls(['nav-logo', className])}
|
|
422
|
+
style={{
|
|
423
|
+
display: 'flex',
|
|
424
|
+
alignItems: 'center',
|
|
425
|
+
color: 'inherit',
|
|
426
|
+
height: '100%',
|
|
427
|
+
justifyContent: 'flex-start',
|
|
428
|
+
}}
|
|
429
|
+
href="/"
|
|
430
|
+
>
|
|
431
|
+
<img
|
|
432
|
+
src={pageContext.meta.faviconUrl}
|
|
433
|
+
height={iconSize}
|
|
434
|
+
width={iconSize}
|
|
435
|
+
onContextMenu={(ev) => {
|
|
436
|
+
if (!pageContext.config.pressKit) return // no /press page
|
|
437
|
+
if (window.location.pathname === '/press') return
|
|
438
|
+
ev.preventDefault()
|
|
439
|
+
navigate('/press#logo')
|
|
440
|
+
}}
|
|
441
|
+
/>
|
|
442
|
+
<span
|
|
443
|
+
style={{
|
|
444
|
+
marginLeft: `calc(var(--icon-text-padding) + 2px)`,
|
|
445
|
+
fontSize: isProjectNameShort(projectName) ? '1.65em' : '1.3em',
|
|
446
|
+
}}
|
|
447
|
+
>
|
|
448
|
+
{projectName}
|
|
449
|
+
</span>
|
|
450
|
+
</a>
|
|
451
|
+
)
|
|
452
|
+
}
|
|
453
|
+
function isProjectNameShort(projectName: string) {
|
|
454
|
+
return projectName.length <= 4
|
|
388
455
|
}
|
|
389
456
|
|
|
390
457
|
let onMouseIgnore: ReturnType<typeof setTimeout> | undefined
|
|
391
|
-
|
|
458
|
+
type PropsDiv = React.HTMLProps<HTMLDivElement>
|
|
459
|
+
function MenuLink(props: PropsDiv) {
|
|
392
460
|
return (
|
|
393
461
|
<div
|
|
462
|
+
{...props}
|
|
394
463
|
style={{
|
|
395
464
|
height: '100%',
|
|
396
465
|
display: 'flex',
|
|
397
466
|
alignItems: 'center',
|
|
398
467
|
cursor: 'default',
|
|
399
|
-
|
|
468
|
+
userSelect: 'none',
|
|
469
|
+
...props.style,
|
|
400
470
|
}}
|
|
401
|
-
className=
|
|
471
|
+
className={['colorize-on-hover menu-toggle', props.className].filter(Boolean).join(' ')}
|
|
402
472
|
onClick={(ev) => {
|
|
403
473
|
ev.preventDefault()
|
|
404
474
|
toggleMenuModal()
|
|
@@ -409,7 +479,7 @@ function MenuLink({ style }: { style: React.CSSProperties }) {
|
|
|
409
479
|
}}
|
|
410
480
|
onMouseLeave={() => {
|
|
411
481
|
if (onMouseIgnore) return
|
|
412
|
-
|
|
482
|
+
closeMenuModalWithDelay(100)
|
|
413
483
|
}}
|
|
414
484
|
onTouchStart={() => {
|
|
415
485
|
onMouseIgnore = setTimeout(() => {
|
|
@@ -417,26 +487,38 @@ function MenuLink({ style }: { style: React.CSSProperties }) {
|
|
|
417
487
|
}, 1000)
|
|
418
488
|
}}
|
|
419
489
|
>
|
|
420
|
-
<
|
|
421
|
-
|
|
490
|
+
<span className="text-docs">
|
|
491
|
+
<DocsIcon /> Docs
|
|
492
|
+
</span>
|
|
493
|
+
<span className="text-menu">
|
|
494
|
+
<MenuIcon /> Menu
|
|
495
|
+
</span>
|
|
496
|
+
<Style>{css`
|
|
497
|
+
@media(max-width: ${containerQueryMobileMenu}px) {
|
|
498
|
+
.text-docs {
|
|
499
|
+
display: none;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
@media(min-width: ${containerQueryMobileMenu + 1}px) {
|
|
503
|
+
.text-menu {
|
|
504
|
+
display: none;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
`}</Style>
|
|
422
508
|
</div>
|
|
423
509
|
)
|
|
424
510
|
}
|
|
425
511
|
function DocsIcon() {
|
|
426
512
|
return (
|
|
427
|
-
<span
|
|
428
|
-
style={{ marginRight: 'calc(var(--icon-text-padding) + 2px)', lineHeight: 0, width: '1.3em' }}
|
|
429
|
-
className="decolorize-6"
|
|
430
|
-
>
|
|
513
|
+
<span style={{ marginRight: 'calc(var(--icon-text-padding) + 2px)' }} className="decolorize-6">
|
|
431
514
|
📚
|
|
432
515
|
</span>
|
|
433
516
|
)
|
|
434
517
|
}
|
|
435
|
-
/* TODO/now: use for mobile
|
|
436
518
|
function MenuIcon() {
|
|
437
519
|
return (
|
|
438
520
|
<svg
|
|
439
|
-
style={{ marginRight: 'calc(var(--icon-text-padding) + 2px)',
|
|
521
|
+
style={{ marginRight: 'calc(var(--icon-text-padding) + 2px)', verticalAlign: 'top', width: '1.3em' }}
|
|
440
522
|
className="decolorize-6"
|
|
441
523
|
viewBox="0 0 448 512"
|
|
442
524
|
>
|
|
@@ -447,8 +529,3 @@ function MenuIcon() {
|
|
|
447
529
|
</svg>
|
|
448
530
|
)
|
|
449
531
|
}
|
|
450
|
-
*/
|
|
451
|
-
|
|
452
|
-
function Style({ children }: { children: string }) {
|
|
453
|
-
return <style dangerouslySetInnerHTML={{ __html: children }} />
|
|
454
|
-
}
|