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