@brillout/docpress 0.7.9 → 0.7.10-commit-776b1fc
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/+config.ts +2 -10
- package/Layout.tsx +397 -67
- package/{navigation/NavigationHeader.tsx → Links.tsx} +6 -57
- package/MenuModal.tsx +146 -0
- package/autoScrollNav.ts +4 -5
- package/components/CodeBlockTransformer.tsx +0 -2
- package/components/Note.css +4 -4
- package/components/Note.tsx +0 -2
- package/components/Supporters.tsx +1 -0
- package/config/resolveHeadingsData.ts +20 -23
- package/config/resolvePageContext.ts +11 -1
- package/css/code/block.css +5 -5
- package/css/code/inline.css +1 -1
- package/css/code.css +9 -5
- package/css/index.css +0 -4
- package/css/reset.css +0 -6
- package/dist/+config.d.ts +1 -13
- package/dist/+config.js +0 -3
- package/dist/components/CodeBlockTransformer.d.ts +1 -0
- package/dist/components/CodeBlockTransformer.js +1 -0
- package/dist/components/Note.d.ts +1 -0
- package/dist/components/Note.js +1 -0
- package/dist/components/Supporters.js +1 -0
- package/dist/config/resolveHeadingsData.d.ts +5 -8
- package/dist/config/resolveHeadingsData.js +20 -22
- package/dist/config/resolvePageContext.d.ts +5 -7
- package/dist/config/resolvePageContext.js +2 -1
- package/dist/navigation/Navigation.d.ts +12 -11
- package/dist/navigation/Navigation.js +75 -73
- package/dist/renderer/getStyleColumnLayout.d.ts +7 -0
- package/dist/renderer/getStyleColumnLayout.js +167 -0
- package/dist/types/Heading.d.ts +2 -4
- package/dist/utils/client.d.ts +1 -0
- package/dist/utils/client.js +1 -0
- package/dist/utils/css.d.ts +1 -0
- package/dist/utils/css.js +27 -0
- package/dist/utils/getGlobalObject.d.ts +1 -0
- package/dist/utils/getGlobalObject.js +9 -0
- package/docsearch/DocSearchInstall.tsx +23 -0
- package/docsearch/SearchLink.tsx +48 -0
- package/docsearch/closeDocsearchModal.ts +29 -0
- package/initKeyBindings.ts +41 -0
- package/installSectionUrlHashs.ts +6 -5
- package/navigation/Navigation.css +101 -3
- package/navigation/Navigation.tsx +109 -124
- package/package.json +1 -8
- package/renderer/getPageContextCurrent.ts +16 -0
- package/renderer/getPageElement.tsx +19 -7
- package/renderer/getStyleColumnLayout.ts +187 -0
- package/renderer/onRenderClient.tsx +20 -24
- package/renderer/onRenderHtml.tsx +4 -0
- package/types/Heading.ts +2 -5
- package/types.d.ts +8 -0
- package/utils/client.ts +1 -0
- package/utils/css.ts +26 -0
- package/utils/getGlobalObject.ts +11 -0
- package/Layout.css +0 -63
- package/MobileHeader.tsx +0 -70
- package/algolia/DocSearch.css +0 -28
- package/components/FeatureList/FeatureList.client.ts +0 -60
- package/components/FeatureList/FeatureList.css +0 -119
- package/components/FeatureList/FeatureList.tsx +0 -114
- package/components/FeatureList/chevron.svg +0 -7
- package/css/block-design.css +0 -4
- package/dist/autoScrollNav.d.ts +0 -3
- package/dist/autoScrollNav.js +0 -36
- package/dist/components/Algolia/Hit.d.ts +0 -4
- package/dist/components/Algolia/Hit.js +0 -30
- package/dist/components/Algolia/SelectIcon.d.ts +0 -2
- package/dist/components/Algolia/SelectIcon.js +0 -7
- package/dist/components/Algolia/Snippet.d.ts +0 -13
- package/dist/components/Algolia/Snippet.js +0 -37
- package/dist/components/Algolia/SourceIcon.d.ts +0 -4
- package/dist/components/Algolia/SourceIcon.js +0 -23
- package/dist/components/Algolia/types.d.ts +0 -79
- package/dist/components/Algolia/types.js +0 -1
- package/dist/navigation/NavigationHeader.d.ts +0 -8
- package/dist/navigation/NavigationHeader.js +0 -75
- package/dist/navigation/navigation-fullscreen/NavigationFullscreenButton.d.ts +0 -6
- package/dist/navigation/navigation-fullscreen/NavigationFullscreenButton.js +0 -23
- package/dist/navigation/navigation-fullscreen/hotkeyLabel.d.ts +0 -1
- package/dist/navigation/navigation-fullscreen/hotkeyLabel.js +0 -1
- package/navigation/Navigation-highlight.css +0 -41
- package/navigation/Navigation-items.css +0 -119
- package/navigation/Navigation-layout.css +0 -127
- package/navigation/initMobileNavigation.ts +0 -23
- package/navigation/initPressKit.ts +0 -19
- package/navigation/navigation-fullscreen/NavigationFullscreenButton.css +0 -32
- package/navigation/navigation-fullscreen/NavigationFullscreenButton.tsx +0 -47
- package/navigation/navigation-fullscreen/chevron.svg +0 -1
- package/navigation/navigation-fullscreen/close.svg +0 -4
- package/navigation/navigation-fullscreen/hotkeyLabel.ts +0 -1
- package/navigation/navigation-fullscreen/initNavigationFullscreen.ts +0 -147
package/+config.ts
CHANGED
|
@@ -12,13 +12,11 @@ export default {
|
|
|
12
12
|
hydrationCanBeAborted: true,
|
|
13
13
|
passToClient: ['pageContextResolved'],
|
|
14
14
|
meta: {
|
|
15
|
-
NavHeader: {
|
|
16
|
-
env: { client: true, server: true },
|
|
17
|
-
},
|
|
18
15
|
Layout: {
|
|
19
16
|
env: { client: true, server: true },
|
|
20
17
|
},
|
|
21
18
|
},
|
|
19
|
+
|
|
22
20
|
prefetch: {
|
|
23
21
|
staticAssets: 'hover',
|
|
24
22
|
pageContext: Infinity,
|
|
@@ -33,13 +31,7 @@ declare global {
|
|
|
33
31
|
exports: Exports
|
|
34
32
|
}
|
|
35
33
|
interface Config {
|
|
36
|
-
Layout?: ReactComponent | ImportString
|
|
37
|
-
NavHeader?: {
|
|
38
|
-
NavHeader: ReactComponent
|
|
39
|
-
navHeaderWrapperStyle?: React.CSSProperties
|
|
40
|
-
NavHeaderMobile: ReactComponent
|
|
41
|
-
navHeaderMobileWrapperStyle?: React.CSSProperties
|
|
42
|
-
}
|
|
34
|
+
Layout?: ReactComponent | null | ImportString
|
|
43
35
|
}
|
|
44
36
|
}
|
|
45
37
|
}
|
package/Layout.tsx
CHANGED
|
@@ -1,99 +1,429 @@
|
|
|
1
1
|
export { Layout }
|
|
2
|
+
export { containerQueryMobile }
|
|
2
3
|
|
|
3
4
|
import React from 'react'
|
|
4
|
-
import {
|
|
5
|
-
import { MobileHeader } from './MobileHeader'
|
|
5
|
+
import { NavigationContent } from './navigation/Navigation'
|
|
6
6
|
import { EditPageNote } from './components/EditPageNote'
|
|
7
|
-
import './Layout.css'
|
|
8
|
-
import { NavigationFullscreenButton } from './navigation/navigation-fullscreen/NavigationFullscreenButton'
|
|
9
7
|
import { parseTitle } from './parseTitle'
|
|
10
|
-
import { usePageContext
|
|
11
|
-
import { Links } from './
|
|
12
|
-
import {
|
|
8
|
+
import { usePageContext } from './renderer/usePageContext'
|
|
9
|
+
import { Links } from './Links'
|
|
10
|
+
import { hotkeyMenuOpen, toggleMenuModal } from './MenuModal'
|
|
11
|
+
import { MenuModal } from './MenuModal'
|
|
12
|
+
import { autoScrollNav_SSR } from './autoScrollNav'
|
|
13
|
+
import { SearchLink } from './docsearch/SearchLink'
|
|
14
|
+
import { navigate } from 'vike/client/router'
|
|
15
|
+
import { css } from './utils/css'
|
|
16
|
+
|
|
17
|
+
const mainViewWidthMax = 800
|
|
18
|
+
const mainViewPadding = 20
|
|
19
|
+
const navWidthMax = 370
|
|
20
|
+
const navWidthMin = 300
|
|
21
|
+
const navWidth = {
|
|
22
|
+
minWidth: navWidthMin,
|
|
23
|
+
maxWidth: navWidthMax,
|
|
24
|
+
width: '100%',
|
|
25
|
+
}
|
|
26
|
+
const blockMargin = 3
|
|
27
|
+
const mainViewMax = mainViewWidthMax + mainViewPadding * 2
|
|
28
|
+
const containerQuerySpacing = mainViewMax + navWidthMax + blockMargin
|
|
29
|
+
const containerQueryMobile = mainViewMax + navWidthMin
|
|
30
|
+
|
|
31
|
+
// Avoid blank whitespace at the bottom of the page with almost no content
|
|
32
|
+
const blankBuster1: React.CSSProperties = {
|
|
33
|
+
minHeight: '100vh',
|
|
34
|
+
display: 'flex',
|
|
35
|
+
flexDirection: 'column',
|
|
36
|
+
}
|
|
37
|
+
const blankBuster2: React.CSSProperties = {
|
|
38
|
+
flexGrow: 1,
|
|
39
|
+
}
|
|
13
40
|
|
|
14
41
|
function Layout({ children }: { children: React.ReactNode }) {
|
|
15
42
|
const pageContext = usePageContext()
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
43
|
+
const { isLandingPage } = pageContext
|
|
44
|
+
|
|
45
|
+
let content: JSX.Element
|
|
46
|
+
if (isLandingPage) {
|
|
47
|
+
content = <LayoutLandingPage>{children}</LayoutLandingPage>
|
|
48
|
+
} else {
|
|
49
|
+
content = <LayoutDocsPage>{children}</LayoutDocsPage>
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
<div
|
|
55
|
+
className={isLandingPage ? '' : 'doc-page'}
|
|
56
|
+
style={{
|
|
57
|
+
['--bg-color']: '#f5f5f7',
|
|
58
|
+
['--block-margin']: `${blockMargin}px`,
|
|
59
|
+
['--icon-padding']: '8px',
|
|
60
|
+
...blankBuster1,
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
{content}
|
|
64
|
+
<MenuModal />
|
|
65
|
+
</div>
|
|
66
|
+
<style>{css`body { container-type: inline-size; }`}</style>
|
|
67
|
+
</>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function LayoutDocsPage({ children }: { children: React.ReactNode }) {
|
|
72
|
+
const pageContext = usePageContext()
|
|
73
|
+
const hideNavLeftAlways = pageContext.navItems.length <= 1
|
|
74
|
+
return (
|
|
75
|
+
<>
|
|
76
|
+
<style>{getStyle()}</style>
|
|
77
|
+
<NavMobile />
|
|
78
|
+
<div style={{ display: 'flex', ...blankBuster2 }}>
|
|
79
|
+
<NavLeft />
|
|
80
|
+
<div className="low-prio-grow" style={{ width: 0, maxWidth: 50, background: 'var(--bg-color)' }} />
|
|
81
|
+
<PageContent>{children}</PageContent>
|
|
82
|
+
</div>
|
|
83
|
+
</>
|
|
84
|
+
)
|
|
85
|
+
function getStyle() {
|
|
86
|
+
let style = css`
|
|
87
|
+
@container(min-width: ${containerQuerySpacing}px) {
|
|
88
|
+
.low-prio-grow {
|
|
89
|
+
flex-grow: 1;
|
|
90
|
+
}
|
|
91
|
+
#navigation-container {
|
|
92
|
+
width: ${navWidthMax}px !important;
|
|
93
|
+
}
|
|
94
|
+
}`
|
|
95
|
+
let navLeftHide = css`
|
|
96
|
+
#nav-left {
|
|
97
|
+
display: none;
|
|
98
|
+
}
|
|
99
|
+
.page-wrapper {
|
|
100
|
+
--main-view-padding: 10px !important;
|
|
101
|
+
flex-grow: 1;
|
|
102
|
+
align-items: center;
|
|
103
|
+
}
|
|
104
|
+
.page-content {
|
|
105
|
+
margin: auto;
|
|
106
|
+
}
|
|
107
|
+
`
|
|
108
|
+
if (!hideNavLeftAlways) {
|
|
109
|
+
navLeftHide = css`
|
|
110
|
+
@container(max-width: ${containerQueryMobile - 1}px) {
|
|
111
|
+
${navLeftHide}
|
|
112
|
+
}
|
|
113
|
+
@container(min-width: ${containerQueryMobile}px) {
|
|
114
|
+
#nav-mobile {
|
|
115
|
+
display: none !important;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
`
|
|
119
|
+
}
|
|
120
|
+
style += navLeftHide
|
|
121
|
+
|
|
122
|
+
return style
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function LayoutLandingPage({ children }: { children: React.ReactNode }) {
|
|
127
|
+
const mobile = 800
|
|
128
|
+
return (
|
|
129
|
+
<>
|
|
130
|
+
<style>{getStyle()}</style>
|
|
131
|
+
<NavTop />
|
|
132
|
+
<NavMobile />
|
|
133
|
+
<PageContent>{children}</PageContent>
|
|
134
|
+
</>
|
|
135
|
+
)
|
|
136
|
+
function getStyle() {
|
|
137
|
+
return css`
|
|
138
|
+
@container(min-width: ${mobile}px) {
|
|
139
|
+
#nav-mobile {
|
|
140
|
+
display: none !important;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
@container(max-width: ${mobile - 1}px) {
|
|
144
|
+
#top-navigation {
|
|
145
|
+
display: none !important;
|
|
146
|
+
}
|
|
147
|
+
`
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function PageContent({ children }: { children: React.ReactNode }) {
|
|
152
|
+
const pageContext = usePageContext()
|
|
153
|
+
const { isLandingPage, pageTitle } = pageContext
|
|
19
154
|
const pageTitleParsed = pageTitle && parseTitle(pageTitle)
|
|
20
155
|
const { globalNote } = pageContext.config
|
|
21
|
-
const
|
|
156
|
+
const ifDocPage = (style: React.CSSProperties) => (isLandingPage ? {} : style)
|
|
157
|
+
return (
|
|
158
|
+
<div
|
|
159
|
+
className="page-wrapper low-prio-grow"
|
|
160
|
+
style={{
|
|
161
|
+
// Avoid overflow, see https://stackoverflow.com/questions/36230944/prevent-flex-items-from-overflowing-a-container/66689926#66689926
|
|
162
|
+
minWidth: 0,
|
|
163
|
+
...ifDocPage({
|
|
164
|
+
backgroundColor: 'var(--bg-color)',
|
|
165
|
+
paddingBottom: 50,
|
|
166
|
+
}),
|
|
167
|
+
}}
|
|
168
|
+
>
|
|
169
|
+
<div
|
|
170
|
+
className="page-content"
|
|
171
|
+
style={{
|
|
172
|
+
// Also define --main-view-padding for landing page because it's used by <Contributors> and <Sponsors>
|
|
173
|
+
['--main-view-padding']: `${mainViewPadding}px`,
|
|
174
|
+
...ifDocPage({
|
|
175
|
+
width: `calc(${mainViewWidthMax}px + 2 * var(--main-view-padding))`,
|
|
176
|
+
maxWidth: '100%',
|
|
177
|
+
padding: '20px var(--main-view-padding)',
|
|
178
|
+
}),
|
|
179
|
+
}}
|
|
180
|
+
>
|
|
181
|
+
{globalNote}
|
|
182
|
+
{pageTitleParsed && <h1 id={`${pageContext.urlPathname.replace('/', '')}`}>{pageTitleParsed}</h1>}
|
|
183
|
+
{children}
|
|
184
|
+
{!isLandingPage && <EditPageNote pageContext={pageContext} />}
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function NavMobile() {
|
|
191
|
+
return (
|
|
192
|
+
<div id="nav-mobile">
|
|
193
|
+
<NavigationHeader headerHeight={50} headerPadding={10} style={{ justifyContent: 'center' }} />
|
|
194
|
+
</div>
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function NavTop() {
|
|
199
|
+
const pageContext = usePageContext()
|
|
200
|
+
const { topNavigationList, topNavigationStyle } = pageContext
|
|
201
|
+
const paddingSize = 35
|
|
202
|
+
const padding = `0 ${paddingSize}px`
|
|
203
|
+
return (
|
|
204
|
+
<div
|
|
205
|
+
id="top-navigation"
|
|
206
|
+
style={{
|
|
207
|
+
position: 'relative',
|
|
208
|
+
display: 'flex',
|
|
209
|
+
alignItems: 'center',
|
|
210
|
+
justifyContent: 'center',
|
|
211
|
+
textDecoration: 'none',
|
|
212
|
+
marginBottom: 'var(--block-margin)',
|
|
213
|
+
backgroundColor: 'var(--bg-color)',
|
|
214
|
+
fontSize: '1.06em',
|
|
215
|
+
color: '#666',
|
|
216
|
+
...topNavigationStyle,
|
|
217
|
+
}}
|
|
218
|
+
>
|
|
219
|
+
<div style={{ display: 'flex', alignItems: 'center', height: 70 }}>
|
|
220
|
+
{topNavigationList.map(({ title, url }) => (
|
|
221
|
+
<a
|
|
222
|
+
href={url!}
|
|
223
|
+
key={url}
|
|
224
|
+
style={{
|
|
225
|
+
color: 'inherit',
|
|
226
|
+
height: '100%',
|
|
227
|
+
display: 'inline-flex',
|
|
228
|
+
alignItems: 'center',
|
|
229
|
+
justifyContent: 'center',
|
|
230
|
+
cursor: 'pointer',
|
|
231
|
+
padding,
|
|
232
|
+
marginRight: 7,
|
|
233
|
+
}}
|
|
234
|
+
>
|
|
235
|
+
{title}
|
|
236
|
+
</a>
|
|
237
|
+
))}
|
|
238
|
+
<SearchLink style={{ padding }} />
|
|
239
|
+
<MenuLink style={{ padding }} />
|
|
240
|
+
<Links style={{ display: 'inline-flex', padding, marginLeft: -8 }} />
|
|
241
|
+
</div>
|
|
242
|
+
</div>
|
|
243
|
+
)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function NavLeft() {
|
|
247
|
+
const pageContext = usePageContext()
|
|
248
|
+
const { navItems, navItemsAll, isDetachedPage } = pageContext
|
|
249
|
+
const headerHeight = 60
|
|
250
|
+
const headerPadding = 10
|
|
22
251
|
return (
|
|
23
252
|
<>
|
|
24
|
-
|
|
253
|
+
<div
|
|
254
|
+
id="nav-left"
|
|
255
|
+
style={{
|
|
256
|
+
flexGrow: 1,
|
|
257
|
+
borderRight: 'var(--block-margin) solid white',
|
|
258
|
+
}}
|
|
259
|
+
>
|
|
25
260
|
<div
|
|
26
|
-
id="top-navigation"
|
|
27
261
|
style={{
|
|
28
|
-
position: '
|
|
29
|
-
|
|
30
|
-
color: 'inherit',
|
|
31
|
-
alignItems: 'center',
|
|
32
|
-
justifyContent: noSideNavigation === 'no-logo' ? 'center' : 'space-between',
|
|
33
|
-
textDecoration: 'none',
|
|
34
|
-
marginBottom: 'var(--block-margin)',
|
|
35
|
-
backgroundColor: 'var(--bg-color)',
|
|
36
|
-
...topNavigationStyle,
|
|
262
|
+
position: 'sticky',
|
|
263
|
+
top: 0,
|
|
37
264
|
}}
|
|
38
265
|
>
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
<div className="page-wrapper">
|
|
67
|
-
<div className="page-container">
|
|
68
|
-
<MobileHeader />
|
|
69
|
-
<div className="page-content">
|
|
70
|
-
{globalNote}
|
|
71
|
-
{pageTitleParsed && <h1 id={`${navigationData.currentUrl.replace('/', '')}`}>{pageTitleParsed}</h1>}
|
|
72
|
-
{children}
|
|
73
|
-
{!isLandingPage && <EditPageNote pageContext={pageContext} />}
|
|
266
|
+
<NavigationHeader {...{ headerHeight, headerPadding }} />
|
|
267
|
+
<div
|
|
268
|
+
style={{
|
|
269
|
+
backgroundColor: 'var(--bg-color)',
|
|
270
|
+
display: 'flex',
|
|
271
|
+
justifyContent: 'flex-end',
|
|
272
|
+
}}
|
|
273
|
+
>
|
|
274
|
+
<div
|
|
275
|
+
id="navigation-container"
|
|
276
|
+
style={{
|
|
277
|
+
top: 0,
|
|
278
|
+
height: `calc(100vh - ${headerHeight}px - var(--block-margin))`,
|
|
279
|
+
overflowY: 'auto',
|
|
280
|
+
overscrollBehavior: 'contain',
|
|
281
|
+
paddingBottom: 40,
|
|
282
|
+
...navWidth,
|
|
283
|
+
}}
|
|
284
|
+
>
|
|
285
|
+
{
|
|
286
|
+
// TODO/refactor: simplify?
|
|
287
|
+
isDetachedPage ? (
|
|
288
|
+
<NavigationContent navItems={navItems} />
|
|
289
|
+
) : (
|
|
290
|
+
<NavigationContent navItems={navItemsAll} showOnlyRelevant={true} />
|
|
291
|
+
)
|
|
292
|
+
}
|
|
74
293
|
</div>
|
|
75
294
|
</div>
|
|
76
|
-
<NavigationMask />
|
|
77
295
|
</div>
|
|
78
296
|
</div>
|
|
297
|
+
{/* Early scrolling, to avoid flashing */}
|
|
298
|
+
<script dangerouslySetInnerHTML={{ __html: autoScrollNav_SSR }}></script>
|
|
79
299
|
</>
|
|
80
300
|
)
|
|
81
301
|
}
|
|
82
302
|
|
|
83
|
-
function
|
|
303
|
+
function NavigationHeader({
|
|
304
|
+
headerHeight,
|
|
305
|
+
headerPadding,
|
|
306
|
+
style,
|
|
307
|
+
}: { headerHeight: number; headerPadding: number; style?: React.CSSProperties }) {
|
|
308
|
+
const pageContext = usePageContext()
|
|
309
|
+
const iconSize = headerHeight - 2 * headerPadding
|
|
310
|
+
//*
|
|
311
|
+
const { projectName } = pageContext.meta
|
|
312
|
+
/*/
|
|
313
|
+
const projectName = 'Vike'
|
|
314
|
+
//*/
|
|
315
|
+
const isProjectNameShort = projectName.length <= 4
|
|
316
|
+
const childrenStyle: React.CSSProperties = {
|
|
317
|
+
flexGrow: 1,
|
|
318
|
+
fontSize: isProjectNameShort ? '4.8cqw' : '4.5cqw',
|
|
319
|
+
['--icon-padding']: '1.8cqw',
|
|
320
|
+
}
|
|
321
|
+
return (
|
|
322
|
+
<div
|
|
323
|
+
style={{
|
|
324
|
+
backgroundColor: 'var(--bg-color)',
|
|
325
|
+
display: 'flex',
|
|
326
|
+
justifyContent: 'flex-end',
|
|
327
|
+
borderBottom: 'var(--block-margin) solid white',
|
|
328
|
+
...style,
|
|
329
|
+
}}
|
|
330
|
+
>
|
|
331
|
+
<div
|
|
332
|
+
style={{
|
|
333
|
+
display: 'flex',
|
|
334
|
+
height: headerHeight,
|
|
335
|
+
containerType: 'inline-size',
|
|
336
|
+
...navWidth,
|
|
337
|
+
}}
|
|
338
|
+
>
|
|
339
|
+
<a
|
|
340
|
+
style={{
|
|
341
|
+
display: 'flex',
|
|
342
|
+
alignItems: 'center',
|
|
343
|
+
color: 'inherit',
|
|
344
|
+
textDecoration: 'none',
|
|
345
|
+
height: '100%',
|
|
346
|
+
padding: `${headerPadding}px 0`,
|
|
347
|
+
paddingLeft: 4,
|
|
348
|
+
...childrenStyle,
|
|
349
|
+
}}
|
|
350
|
+
href="/"
|
|
351
|
+
>
|
|
352
|
+
<img
|
|
353
|
+
src={pageContext.meta.faviconUrl}
|
|
354
|
+
height={iconSize}
|
|
355
|
+
width={iconSize}
|
|
356
|
+
onContextMenu={(ev) => {
|
|
357
|
+
if (!pageContext.config.pressKit) return // no /press page
|
|
358
|
+
if (window.location.pathname === '/press') return
|
|
359
|
+
ev.preventDefault()
|
|
360
|
+
navigate('/press#logo')
|
|
361
|
+
}}
|
|
362
|
+
/>
|
|
363
|
+
<span
|
|
364
|
+
style={{
|
|
365
|
+
marginLeft: `calc(var(--icon-padding) + 2px)`,
|
|
366
|
+
fontSize: isProjectNameShort ? '1.7em' : '1.3em',
|
|
367
|
+
}}
|
|
368
|
+
>
|
|
369
|
+
{projectName}
|
|
370
|
+
</span>
|
|
371
|
+
</a>
|
|
372
|
+
<SearchLink
|
|
373
|
+
style={{
|
|
374
|
+
//
|
|
375
|
+
...childrenStyle,
|
|
376
|
+
}}
|
|
377
|
+
/>
|
|
378
|
+
<MenuLink
|
|
379
|
+
style={{
|
|
380
|
+
//
|
|
381
|
+
...childrenStyle,
|
|
382
|
+
}}
|
|
383
|
+
/>
|
|
384
|
+
</div>
|
|
385
|
+
</div>
|
|
386
|
+
)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
type PropsDiv = React.HTMLProps<HTMLDivElement>
|
|
390
|
+
function MenuLink(props: PropsDiv) {
|
|
84
391
|
return (
|
|
85
|
-
<
|
|
392
|
+
<div
|
|
393
|
+
{...props}
|
|
86
394
|
style={{
|
|
87
395
|
height: '100%',
|
|
88
|
-
display: '
|
|
396
|
+
display: 'flex',
|
|
89
397
|
alignItems: 'center',
|
|
90
|
-
justifyContent: 'center',
|
|
91
|
-
padding: '20px 10px',
|
|
92
398
|
cursor: 'pointer',
|
|
93
|
-
|
|
94
|
-
fontSize: '1.06em',
|
|
399
|
+
...props.style,
|
|
95
400
|
}}
|
|
96
|
-
|
|
97
|
-
|
|
401
|
+
className="colorize-on-hover"
|
|
402
|
+
onClick={(ev) => {
|
|
403
|
+
ev.preventDefault()
|
|
404
|
+
toggleMenuModal()
|
|
405
|
+
}}
|
|
406
|
+
aria-label={hotkeyMenuOpen}
|
|
407
|
+
data-balloon-pos="left"
|
|
408
|
+
data-balloon-blunt
|
|
409
|
+
data-balloon-nofocus
|
|
410
|
+
>
|
|
411
|
+
<MenuIcon />
|
|
412
|
+
Menu
|
|
413
|
+
</div>
|
|
414
|
+
)
|
|
415
|
+
}
|
|
416
|
+
function MenuIcon() {
|
|
417
|
+
return (
|
|
418
|
+
<svg
|
|
419
|
+
style={{ marginRight: 'calc(var(--icon-padding) + 2px)', lineHeight: 0, width: '1.3em' }}
|
|
420
|
+
className="decolorize-7"
|
|
421
|
+
viewBox="0 0 448 512"
|
|
422
|
+
>
|
|
423
|
+
<path
|
|
424
|
+
fill="currentColor"
|
|
425
|
+
d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"
|
|
426
|
+
></path>
|
|
427
|
+
</svg>
|
|
98
428
|
)
|
|
99
429
|
}
|
|
@@ -1,53 +1,14 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import iconGithub from '
|
|
3
|
-
import iconTwitter from '
|
|
4
|
-
import iconDiscord from '
|
|
5
|
-
import iconChangelog from '
|
|
6
|
-
import iconLanguages from '
|
|
7
|
-
import { usePageContext
|
|
8
|
-
import { DocSearch } from '@docsearch/react'
|
|
9
|
-
import { Hit } from '../components/Algolia/Hit'
|
|
2
|
+
import iconGithub from './icons/github.svg'
|
|
3
|
+
import iconTwitter from './icons/twitter.svg'
|
|
4
|
+
import iconDiscord from './icons/discord.svg'
|
|
5
|
+
import iconChangelog from './icons/changelog.svg'
|
|
6
|
+
import iconLanguages from './icons/languages.svg'
|
|
7
|
+
import { usePageContext } from './renderer/usePageContext'
|
|
10
8
|
import '@docsearch/css'
|
|
11
9
|
|
|
12
|
-
export { NavigationHeader }
|
|
13
10
|
export { Links }
|
|
14
11
|
|
|
15
|
-
function NavigationHeader() {
|
|
16
|
-
const pageContext = usePageContext()
|
|
17
|
-
const pageContext2 = usePageContext2()
|
|
18
|
-
const { NavHeader } = pageContext2.config.NavHeader!
|
|
19
|
-
return (
|
|
20
|
-
<div
|
|
21
|
-
id="navigation-header"
|
|
22
|
-
className={pageContext.config.pressKit && 'press-kit'}
|
|
23
|
-
style={{
|
|
24
|
-
display: 'flex',
|
|
25
|
-
flexDirection: 'column',
|
|
26
|
-
alignItems: 'center',
|
|
27
|
-
marginBottom: -5,
|
|
28
|
-
}}
|
|
29
|
-
>
|
|
30
|
-
<a
|
|
31
|
-
id="navigation-header-logo"
|
|
32
|
-
style={{
|
|
33
|
-
display: 'flex',
|
|
34
|
-
alignItems: 'center',
|
|
35
|
-
color: 'inherit',
|
|
36
|
-
justifyContent: 'left',
|
|
37
|
-
textDecoration: 'none',
|
|
38
|
-
paddingTop: 12,
|
|
39
|
-
paddingBottom: 7,
|
|
40
|
-
...pageContext2.config.NavHeader?.navHeaderWrapperStyle,
|
|
41
|
-
}}
|
|
42
|
-
href="/"
|
|
43
|
-
>
|
|
44
|
-
<NavHeader />
|
|
45
|
-
</a>
|
|
46
|
-
<Links />
|
|
47
|
-
</div>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
12
|
function Links({ style }: { style?: React.CSSProperties }) {
|
|
52
13
|
const pageContext = usePageContext()
|
|
53
14
|
const { projectInfo, i18n } = pageContext.config
|
|
@@ -59,7 +20,6 @@ function Links({ style }: { style?: React.CSSProperties }) {
|
|
|
59
20
|
style={{ height: 21, position: 'relative', top: 0, left: 0 }}
|
|
60
21
|
/>
|
|
61
22
|
)
|
|
62
|
-
const { algolia } = pageContext.meta
|
|
63
23
|
return (
|
|
64
24
|
<div
|
|
65
25
|
style={{
|
|
@@ -70,17 +30,6 @@ function Links({ style }: { style?: React.CSSProperties }) {
|
|
|
70
30
|
...style,
|
|
71
31
|
}}
|
|
72
32
|
>
|
|
73
|
-
{algolia && (
|
|
74
|
-
<div className="decolorize-6 colorize-on-hover">
|
|
75
|
-
<DocSearch
|
|
76
|
-
appId={algolia.appId}
|
|
77
|
-
indexName={algolia.indexName}
|
|
78
|
-
apiKey={algolia.apiKey}
|
|
79
|
-
insights={true}
|
|
80
|
-
hitComponent={Hit}
|
|
81
|
-
/>
|
|
82
|
-
</div>
|
|
83
|
-
)}
|
|
84
33
|
{iconI18n}
|
|
85
34
|
{projectInfo.discordInvite && (
|
|
86
35
|
<LinkIcon className="decolorize-6" icon={iconDiscord} href={projectInfo.discordInvite} />
|