@brillout/docpress 0.15.13-commit-ffe283f → 0.15.13-commit-9b3f898

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 CHANGED
@@ -26,7 +26,6 @@ import { Style } from './utils/Style'
26
26
  import { cls } from './utils/cls'
27
27
  import { iconBooks } from './icons'
28
28
  import { EditLink } from './EditLink'
29
- import type { PageContext } from 'vike/types'
30
29
 
31
30
  const blockMargin = 3
32
31
  const mainViewPadding = 20
@@ -89,12 +88,16 @@ function LayoutDocsPage({ children }: { children: React.ReactNode }) {
89
88
  return (
90
89
  <>
91
90
  <div style={{ display: 'flex', ...whitespaceBuster2 }}>
92
- <NavLeft />
93
- <div
94
- id="nav-left-margin"
95
- className="low-prio-grow"
96
- style={{ width: 0, maxWidth: 50, background: 'var(--bg-color)' }}
97
- />
91
+ {!isNavLeftAlwaysHidden() && (
92
+ <>
93
+ <NavLeft />
94
+ <div
95
+ id="nav-left-margin"
96
+ className="low-prio-grow"
97
+ style={{ width: 0, maxWidth: 50, background: 'var(--bg-color)' }}
98
+ />
99
+ </>
100
+ )}
98
101
  <PageContent>{children}</PageContent>
99
102
  </div>
100
103
  <Style>{css`
@@ -181,7 +184,7 @@ function NavLeft() {
181
184
  top: 0,
182
185
  }}
183
186
  >
184
- {!isNavLeftAlwaysHidden(pageContext) && <NavHead isNavLeft={true} />}
187
+ <NavHead isNavLeft={true} />
185
188
  <div
186
189
  style={{
187
190
  backgroundColor: 'var(--bg-color)',
@@ -234,7 +237,8 @@ function NavigationContent(props: {
234
237
  )
235
238
  }
236
239
 
237
- function isNavLeftAlwaysHidden(pageContext: PageContext) {
240
+ function isNavLeftAlwaysHidden() {
241
+ const pageContext = usePageContext()
238
242
  const { isLandingPage, navItemsDetached, pageDesign } = pageContext.resolved
239
243
  return isLandingPage || pageDesign?.hideMenuLeft || (navItemsDetached && navItemsDetached.length <= 1)
240
244
  }
@@ -255,11 +259,7 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
255
259
 
256
260
  const navHeadSecondary = (
257
261
  <div
258
- className={cls([
259
- 'nav-head-secondary',
260
- isNavLeft && 'show-on-nav-hover add-transition',
261
- !!navMaxWidth && 'has-max-width',
262
- ])}
262
+ className={cls(['nav-head-secondary', isNavLeft && 'show-on-nav-hover add-transition'])}
263
263
  style={{
264
264
  padding: 0,
265
265
  display: 'flex',
@@ -289,7 +289,7 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
289
289
 
290
290
  return (
291
291
  <div
292
- className={cls(['nav-head', isNavLeft && 'is-nav-left', 'link-hover-animation'])}
292
+ className={cls(['nav-head link-hover-animation', isNavLeft && 'is-nav-left', !!navMaxWidth && 'has-max-width'])}
293
293
  style={{
294
294
  display: 'flex',
295
295
  justifyContent: isNavLeft ? 'flex-end' : 'center',
@@ -332,8 +332,6 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
332
332
  )
333
333
  }
334
334
  function getStyleNav() {
335
- const pageContext = usePageContext()
336
-
337
335
  let style = ''
338
336
 
339
337
  // Mobile
@@ -394,7 +392,7 @@ function getStyleNav() {
394
392
  }
395
393
  &.has-max-width {
396
394
  .desktop-grow {
397
- display: block;
395
+ display: block !important;
398
396
  }
399
397
  .desktop-grow,
400
398
  .nav-head-secondary {
@@ -406,7 +404,7 @@ function getStyleNav() {
406
404
  `
407
405
 
408
406
  // Desktop
409
- if (!isNavLeftAlwaysHidden(pageContext)) {
407
+ if (!isNavLeftAlwaysHidden()) {
410
408
  style += css`
411
409
  @container container-viewport (min-width: ${viewDesktop}px) {
412
410
  .nav-head:not(.is-nav-left) {
@@ -452,22 +450,29 @@ function getStyleNav() {
452
450
  body {
453
451
  --main-view-padding: 10px !important;
454
452
  }
455
- .page-wrapper {
456
- flex-grow: 1;
457
- align-items: center;
458
- }
459
- .page-content {
460
- margin: auto;
461
- }
462
- #menu-modal-wrapper {
463
- position: absolute !important;
464
- }
453
+ ${getStyleNavLeftHidden()}
465
454
  }
466
455
  `
456
+ } else {
457
+ style += getStyleNavLeftHidden()
467
458
  }
468
459
 
469
460
  return style
470
461
  }
462
+ function getStyleNavLeftHidden() {
463
+ return css`
464
+ .page-wrapper {
465
+ flex-grow: 1;
466
+ align-items: center;
467
+ }
468
+ .page-content {
469
+ margin: auto;
470
+ }
471
+ #menu-modal-wrapper {
472
+ position: absolute !important;
473
+ }
474
+ `
475
+ }
471
476
 
472
477
  function unexpandNav() {
473
478
  document.documentElement.classList.add('unexpand-nav')
@@ -23,7 +23,16 @@ function NavigationWithColumnLayout(props: { navItems: NavItem[] }) {
23
23
  window.addEventListener('resize', throttle(updateviewportwidth, 300), { passive: true })
24
24
  })
25
25
  const navItemsByColumnLayouts = getNavItemsByColumnLayouts(navItemsWithComputed, viewportWidth)
26
+ const columnWidthBase = navLeftWidthMax + 20
26
27
  const maxColumns = Math.max(...navItemsByColumnLayouts.map((layout) => layout.columns.length), 1)
28
+ const widthMax = maxColumns * columnWidthBase
29
+ const getColumnsWrapperStyle = (columnLayout: NavItemsByColumnLayout) => {
30
+ const widthColumn = columnLayout.columns.length * columnWidthBase
31
+ return {
32
+ width: Math.max(700, widthColumn),
33
+ maxWidth: `min(100%, ${widthMax}px)`,
34
+ }
35
+ }
27
36
  return (
28
37
  <>
29
38
  <Style>{getStyle()}</Style>
@@ -41,7 +50,7 @@ function NavigationWithColumnLayout(props: { navItems: NavItem[] }) {
41
50
  >
42
51
  {columnLayout.isFullWidthCategory ? (
43
52
  <div style={{ marginTop: 0 }}>
44
- <ColumnsWrapper numberOfColumns={maxColumns}>
53
+ <ColumnsWrapper style={getColumnsWrapperStyle(columnLayout)}>
45
54
  <Collapsible
46
55
  head={(onClick) => <NavItemComponent navItem={columnLayout.navItemLevel1} onClick={onClick} />}
47
56
  disabled={maxColumns > 1}
@@ -62,7 +71,7 @@ function NavigationWithColumnLayout(props: { navItems: NavItem[] }) {
62
71
  </ColumnsWrapper>
63
72
  </div>
64
73
  ) : (
65
- <ColumnsWrapper numberOfColumns={maxColumns}>
74
+ <ColumnsWrapper style={getColumnsWrapperStyle(columnLayout)}>
66
75
  <ColumnsLayout>
67
76
  {columnLayout.columns.map((column, j) => (
68
77
  <Column key={j}>
@@ -166,14 +175,14 @@ function Column({ children }: { children: React.ReactNode }) {
166
175
  </div>
167
176
  )
168
177
  }
169
- function ColumnsWrapper({ children, numberOfColumns }: { children: React.ReactNode; numberOfColumns: number }) {
178
+ function ColumnsWrapper({ children, style }: { children: React.ReactNode; style: React.CSSProperties }) {
170
179
  return (
171
180
  <div
181
+ className="columns-wrapper"
172
182
  style={{
173
- width: numberOfColumns * (navLeftWidthMax + 20),
174
- maxWidth: '100%',
175
183
  paddingLeft: 3,
176
184
  margin: 'auto',
185
+ ...style,
177
186
  }}
178
187
  >
179
188
  {children}
package/MenuModal.tsx CHANGED
@@ -132,6 +132,9 @@ function getStyle() {
132
132
  .show-only-on-desktop {
133
133
  display: none !important;
134
134
  }
135
+ .columns-wrapper {
136
+ width: 100% !important;
137
+ }
135
138
  }
136
139
 
137
140
  ${/* Hide same-page headings navigation */ ''}
@@ -28,7 +28,9 @@ function installSectionUrlHashs() {
28
28
  }
29
29
 
30
30
  function assertNavLink(urlHash: string, heading: HTMLHeadingElement) {
31
- const navigationEl = document.querySelector('#nav-left .navigation-content')!
31
+ const navigationContainerEl = document.querySelector('#nav-left')
32
+ if (!navigationContainerEl) return
33
+ const navigationEl = navigationContainerEl.querySelector('.navigation-content')!
32
34
  {
33
35
  const { pathname } = window.location
34
36
  const parentNavLinkMatch = Array.from(navigationEl.querySelectorAll(`a[href="${pathname}"]`))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.15.13-commit-ffe283f",
3
+ "version": "0.15.13-commit-9b3f898",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",