@brillout/docpress 0.15.13-commit-2b0e889 → 0.15.13-commit-29258f0

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/EditLink.tsx CHANGED
@@ -12,18 +12,7 @@ function EditLink({
12
12
  }: { className?: string; style: React.CSSProperties; verbose?: boolean }) {
13
13
  const pageContext = usePageContext()
14
14
  const iconSize = 13
15
- const icon = (
16
- <img
17
- src={iconPencil}
18
- width={iconSize}
19
- height={iconSize}
20
- style={{
21
- marginRight: 6,
22
- position: 'relative',
23
- top: -1,
24
- }}
25
- />
26
- )
15
+ const icon = <img src={iconPencil} width={iconSize} height={iconSize} style={{ marginRight: 6 }} />
27
16
  const { urlPathname } = pageContext
28
17
  const fsPath = urlPathname === '/' ? '/index/+Page.tsx' : `${urlPathname}/+Page.mdx`
29
18
  const docsDir = pageContext.globalContext.config.docpress.docsDir ?? 'docs'
@@ -35,20 +24,21 @@ function EditLink({
35
24
  style={{
36
25
  display: 'inline-flex',
37
26
  alignItems: 'center',
38
- paddingTop: 4,
39
- paddingBottom: 1,
27
+ paddingTop: 7,
28
+ paddingBottom: 7,
40
29
  paddingLeft: 8,
41
- paddingRight: 8,
30
+ paddingRight: 7,
42
31
  border: '1px solid #e0e0e0',
43
32
  borderRadius: 7,
44
33
  fontSize: '0.91em',
45
34
  color: '#6c6c6c',
46
35
  background: '#f8f8f8',
47
36
  letterSpacing: 0.4,
37
+ lineHeight: 0,
48
38
  ...style,
49
39
  }}
50
40
  >
51
- {icon} Edit{verbose ? ' this page' : ''}
41
+ {icon} Edit{verbose ? ' page' : ''}
52
42
  </a>
53
43
  )
54
44
  }
package/Layout.css ADDED
@@ -0,0 +1,9 @@
1
+ body {
2
+ background: var(--background-color);
3
+ /* TODO */
4
+ --background-color: #fbfbfb;
5
+ --background-color: #fcfcfc;
6
+ --background-color: white;
7
+ --background-color: #fefefe;
8
+ --background-color: #fdfdfd;
9
+ }
package/Layout.tsx CHANGED
@@ -4,6 +4,7 @@ export { viewDesktop }
4
4
  export { viewTablet }
5
5
  export { navLeftWidthMin }
6
6
  export { navLeftWidthMax }
7
+ export { bodyMaxWidth }
7
8
  export { unexpandNav }
8
9
  export { blockMargin }
9
10
 
@@ -33,8 +34,9 @@ import { Style } from './utils/Style'
33
34
  import { cls } from './utils/cls'
34
35
  import { iconBooks } from './icons'
35
36
  import { EditLink } from './EditLink'
37
+ import './Layout.css'
36
38
 
37
- const blockMargin = 3
39
+ const blockMargin = 4
38
40
  const mainViewPadding = 20
39
41
  const mainViewWidthMaxInner = 800
40
42
  const mainViewWidthMax = (mainViewWidthMaxInner + mainViewPadding * 2) as 840 // 840 = 800 + 20 * 2
@@ -42,8 +44,10 @@ const navLeftWidthMin = 300
42
44
  const navLeftWidthMax = 370
43
45
  const viewMobile = 450
44
46
  const viewTablet = 1016
45
- const viewDesktop = (mainViewWidthMax + navLeftWidthMin) as 1140 // 1140 = 840 + 300
46
- const viewDesktopLarge = (mainViewWidthMax + navLeftWidthMax + blockMargin) as 1213 // 1213 = 840 + 370 + 3
47
+ const viewDesktop = (mainViewWidthMax + navLeftWidthMin + blockMargin) as 1144 // 1140 = 840 + 300 + 4
48
+ const viewDesktopLarge = (mainViewWidthMax + navLeftWidthMax + blockMargin) as 1214 // 1214 = 840 + 370 + 4
49
+ // TODO
50
+ const bodyMaxWidth = 1300
47
51
 
48
52
  // Avoid whitespace at the bottom of pages with almost no content
49
53
  const whitespaceBuster1: React.CSSProperties = {
@@ -66,6 +70,7 @@ function Layout({ children }: { children: React.ReactNode }) {
66
70
  content = <LayoutDocsPage>{children}</LayoutDocsPage>
67
71
  }
68
72
 
73
+ const isNavLeftHidden = isNavLeftAlwaysHidden()
69
74
  return (
70
75
  <div
71
76
  style={{
@@ -77,9 +82,11 @@ function Layout({ children }: { children: React.ReactNode }) {
77
82
  // We don't add `container` to `body` nor `html` beacuse in Firefox it breaks the `position: fixed` of <MenuModal>
78
83
  // https://stackoverflow.com/questions/74601420/css-container-inline-size-and-fixed-child
79
84
  container: 'container-viewport / inline-size',
85
+ maxWidth: isNavLeftHidden ? undefined : bodyMaxWidth,
86
+ margin: 'auto',
80
87
  }}
81
88
  >
82
- <MenuModal isTopNav={isLandingPage} />
89
+ <MenuModal isTopNav={isLandingPage} isNavLeftHidden={isNavLeftHidden} />
83
90
  <div className={isLandingPage ? '' : 'doc-page'} style={whitespaceBuster1}>
84
91
  <NavHead />
85
92
  {content}
@@ -108,14 +115,22 @@ function LayoutDocsPage({ children }: { children: React.ReactNode }) {
108
115
  <PageContent>{children}</PageContent>
109
116
  </div>
110
117
  <Style>{css`
118
+ @container container-viewport (max-width: ${viewDesktopLarge - 1}px) {
119
+ #nav-left {
120
+ flex-grow: 1;
121
+ min-width: ${navLeftWidthMin + blockMargin}px;
122
+ }
123
+ }
111
124
  @container container-viewport (min-width: ${viewDesktopLarge}px) {
112
125
  .low-prio-grow {
113
126
  flex-grow: 1;
114
127
  }
115
- #navigation-container {
116
- width: ${navLeftWidthMax}px !important;
128
+ #nav-left {
129
+ min-width: ${navLeftWidthMax + blockMargin}px;
117
130
  }
118
- }`}</Style>
131
+ }
132
+
133
+ `}</Style>
119
134
  </>
120
135
  )
121
136
  }
@@ -181,12 +196,16 @@ function NavLeft() {
181
196
  id="nav-left"
182
197
  className="link-hover-animation"
183
198
  style={{
199
+ /* TODO
184
200
  flexGrow: 1,
185
- borderRight: 'var(--block-margin) solid white',
201
+ */
202
+ borderRight: 'var(--block-margin) solid var(--background-color)',
186
203
  zIndex: 1,
187
204
  // We must set min-width to avoid layout overflow when the text of a navigation item exceeds the available width.
188
205
  // https://stackoverflow.com/questions/36230944/prevent-flex-items-from-overflowing-a-container/66689926#66689926
189
- minWidth: navLeftWidthMin,
206
+ // TODO: remove
207
+ // minWidth: navLeftWidthMin + blockMargin,
208
+ // maxWidth: navLeftWidthMax,
190
209
  }}
191
210
  >
192
211
  <div
@@ -199,8 +218,10 @@ function NavLeft() {
199
218
  <div
200
219
  style={{
201
220
  backgroundColor: 'var(--bg-color)',
221
+ /* TODO: remove?
202
222
  display: 'flex',
203
223
  justifyContent: 'flex-end',
224
+ */
204
225
  }}
205
226
  >
206
227
  <div
@@ -212,7 +233,6 @@ function NavLeft() {
212
233
  overscrollBehavior: 'contain',
213
234
  paddingBottom: 40,
214
235
  minWidth: navLeftWidthMin,
215
- maxWidth: navLeftWidthMax,
216
236
  width: '100%',
217
237
  }}
218
238
  >
@@ -251,7 +271,7 @@ function NavigationContent(props: {
251
271
  function isNavLeftAlwaysHidden() {
252
272
  const pageContext = usePageContext()
253
273
  const { isLandingPage, navItemsDetached, pageDesign } = pageContext.resolved
254
- return isLandingPage || pageDesign?.hideMenuLeft || (navItemsDetached && navItemsDetached.length <= 1)
274
+ return isLandingPage || !!pageDesign?.hideMenuLeft || !!(navItemsDetached && navItemsDetached.length <= 1)
255
275
  }
256
276
 
257
277
  const menuLinkStyle: React.CSSProperties = {
@@ -302,10 +322,11 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
302
322
  <div
303
323
  className={cls(['nav-head link-hover-animation', isNavLeft && 'is-nav-left', !!navMaxWidth && 'has-max-width'])}
304
324
  style={{
305
- display: 'flex',
306
- justifyContent: isNavLeft ? 'flex-end' : 'center',
325
+ // TODO: remove?
326
+ // display: 'flex',
327
+ // justifyContent: isNavLeft ? 'flex-end' : 'center',
307
328
  backgroundColor: 'var(--bg-color)',
308
- borderBottom: 'var(--block-margin) solid white',
329
+ borderBottom: 'var(--block-margin) solid var(--background-color)',
309
330
  position: 'relative',
310
331
  }}
311
332
  >
@@ -315,8 +336,9 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
315
336
  // DON'T REMOVE this container: it's needed for the `cqw` values
316
337
  container: 'container-nav-head / inline-size',
317
338
  width: '100%',
318
- minWidth: isNavLeft && navLeftWidthMin,
319
- maxWidth: isNavLeft && navLeftWidthMax,
339
+ // TODO
340
+ // minWidth: isNavLeft && navLeftWidthMin,
341
+ // maxWidth: isNavLeft && navLeftWidthMax,
320
342
  }}
321
343
  >
322
344
  <div
@@ -347,6 +369,12 @@ function getStyleNav() {
347
369
 
348
370
  // Mobile
349
371
  style += css`
372
+ /* TODO: move */
373
+ .nav-item {
374
+ box-sizing: content-box;
375
+ max-width: ${navLeftWidthMax}px;
376
+ }
377
+
350
378
  @media(max-width: ${viewMobile}px) {
351
379
  .nav-head:not(.is-nav-left) {
352
380
  .nav-head-menu-toggle {
@@ -495,7 +523,7 @@ function NavHeadLeftFullWidthBackground() {
495
523
  left: 0,
496
524
  top: 0,
497
525
  boxSizing: 'content-box',
498
- borderBottom: 'var(--block-margin) solid white',
526
+ borderBottom: 'var(--block-margin) solid var(--background-color)',
499
527
  }}
500
528
  />
501
529
  <Style>{
@@ -546,6 +574,7 @@ function NavHeadLogo({ isNavLeft }: { isNavLeft?: true }) {
546
574
 
547
575
  return (
548
576
  <a
577
+ className="nav-head-logo"
549
578
  style={{
550
579
  display: 'flex',
551
580
  alignItems: 'center',
@@ -557,8 +586,10 @@ function NavHeadLogo({ isNavLeft }: { isNavLeft?: true }) {
557
586
  paddingRight: 'var(--padding-side)',
558
587
  }
559
588
  : {
589
+ /* TODO
560
590
  paddingLeft: 15,
561
591
  marginLeft: -10,
592
+ */
562
593
  }),
563
594
  }}
564
595
  href="/"
@@ -3,7 +3,7 @@ export { NavigationWithColumnLayout }
3
3
  import React, { useEffect, useState } from 'react'
4
4
  import { assert } from '../utils/server'
5
5
  import { getViewportWidth } from '../utils/getViewportWidth'
6
- import { viewTablet, navLeftWidthMax, navLeftWidthMin } from '../Layout'
6
+ import { viewTablet, navLeftWidthMax, navLeftWidthMin, bodyMaxWidth } from '../Layout'
7
7
  import { throttle } from '../utils/throttle'
8
8
  import { Collapsible } from './Collapsible'
9
9
  import { ColumnMap, getNavItemsWithComputed, NavItem, NavItemComponent, NavItemComputed } from '../NavItemComponent'
@@ -22,7 +22,8 @@ function NavigationWithColumnLayout(props: { navItems: NavItem[] }) {
22
22
  updateviewportwidth()
23
23
  window.addEventListener('resize', throttle(updateviewportwidth, 300), { passive: true })
24
24
  })
25
- const navItemsByColumnLayouts = getNavItemsByColumnLayouts(navItemsWithComputed, viewportWidth)
25
+ const availableWidth = viewportWidth && Math.min(viewportWidth, bodyMaxWidth)
26
+ const navItemsByColumnLayouts = getNavItemsByColumnLayouts(navItemsWithComputed, availableWidth)
26
27
  const columnWidthBase = navLeftWidthMax + 20
27
28
  const maxColumns = Math.max(...navItemsByColumnLayouts.map((layout) => layout.columns.length), 1)
28
29
  const widthMax = maxColumns * columnWidthBase
@@ -222,9 +223,9 @@ type NavItemsByColumnLayout =
222
223
  columns: { navItems: NavItemComputed[] }[]
223
224
  isFullWidthCategory: true
224
225
  }
225
- function getNavItemsByColumnLayouts(navItems: NavItemComputed[], viewportWidth: number = 0): NavItemsByColumnLayout[] {
226
+ function getNavItemsByColumnLayouts(navItems: NavItemComputed[], availableWidth: number = 0): NavItemsByColumnLayout[] {
226
227
  const navItemsByColumnEntries = getNavItemsByColumnEntries(navItems)
227
- const numberOfColumnsMax = Math.floor(viewportWidth / navLeftWidthMin) || 1
228
+ const numberOfColumnsMax = Math.floor(availableWidth / navLeftWidthMin) || 1
228
229
  const navItemsByColumnLayouts: NavItemsByColumnLayout[] = navItemsByColumnEntries.map(
229
230
  ({ columnEntries, isFullWidthCategory }) => {
230
231
  const numberOfColumns = Math.min(numberOfColumnsMax, columnEntries.length)
package/MenuModal.tsx CHANGED
@@ -3,14 +3,14 @@ export { MenuModal }
3
3
  import React from 'react'
4
4
  import { usePageContext } from './renderer/usePageContext'
5
5
  import { css } from './utils/css'
6
- import { viewDesktop, viewTablet } from './Layout'
6
+ import { bodyMaxWidth, viewDesktop, viewTablet } from './Layout'
7
7
  import { ExternalLinks } from './ExternalLinks'
8
8
  import { Style } from './utils/Style'
9
9
  import { NavigationWithColumnLayout } from './MenuModal/NavigationWithColumnLayout'
10
10
  import { closeMenuModal, closeMenuModalOnMouseLeave, keepMenuModalOpenOnMouseOver } from './MenuModal/toggleMenuModal'
11
11
  import { EditLink } from './EditLink'
12
12
 
13
- function MenuModal({ isTopNav }: { isTopNav: boolean }) {
13
+ function MenuModal({ isTopNav, isNavLeftHidden }: { isTopNav: boolean; isNavLeftHidden: boolean }) {
14
14
  return (
15
15
  <>
16
16
  <Style>{getStyle()}</Style>
@@ -21,11 +21,15 @@ function MenuModal({ isTopNav }: { isTopNav: boolean }) {
21
21
  position: isTopNav ? 'absolute' : 'fixed',
22
22
  width: '100%',
23
23
  top: 'var(--nav-head-height)',
24
- left: 0,
25
24
  zIndex: 199, // maximum value, because docsearch's modal has `z-index: 200`
26
25
  background: '#ededef',
27
26
  transitionProperty: 'opacity',
28
27
  transitionTimingFunction: 'ease',
28
+ maxWidth: isNavLeftHidden ? undefined : bodyMaxWidth,
29
+ // Horizontal align
30
+ // https://stackoverflow.com/questions/3157372/css-horizontal-centering-of-a-fixed-div/32694476#32694476
31
+ left: '50%',
32
+ transform: 'translateX(-50%)',
29
33
  }}
30
34
  onMouseOver={keepMenuModalOpenOnMouseOver}
31
35
  onMouseLeave={closeMenuModalOnMouseLeave}
@@ -66,7 +70,7 @@ function BorderBottom() {
66
70
  <div
67
71
  id="border-bottom"
68
72
  style={{
69
- background: '#fff',
73
+ background: 'var(--background-color)',
70
74
  height: 'var(--block-margin)',
71
75
  width: '100%',
72
76
  }}
@@ -91,6 +91,8 @@
91
91
  --box-shadow-top: 0 0;
92
92
  --box-shadow-bottom: 0 0;
93
93
  box-shadow: var(--box-shadow-top), var(--box-shadow-bottom), var(--box-shadow-left), var(--box-shadow-right);
94
+ box-shadow: var(--box-shadow-top), var(--box-shadow-right);
95
+ box-shadow: var(--box-shadow-top), var(--box-shadow-bottom);
94
96
  }
95
97
  .nav-item-level-3.nav-item-first-of-its-kind {
96
98
  padding-top: 10px;
@@ -105,14 +107,28 @@
105
107
  position: relative;
106
108
  }
107
109
 
108
- .nav-item-level-3::before,
109
- .nav-item-level-2.is-active::before {
110
- background-color: var(--active-color);
111
- position: absolute;
112
- height: 100%;
113
- width: 100%;
114
- top: 0;
115
- left: 0;
116
- z-index: 1;
117
- content: '';
110
+ /* TODO: remove
111
+ .nav-head-content {
112
+ border-left: 1px solid red;
113
+ }
114
+ .nav-item-level-1 {
115
+ border-left: 1px solid red;
116
+ }
117
+ .nav-item-level-3 {
118
+ border-left: 1px solid red;
119
+ }
120
+ */
121
+
122
+ #nav-left {
123
+ .nav-item-level-1 {
124
+ margin-left: min(25px, max(3px, 30 * (1vw - 12.7px) - 5px));
125
+ }
126
+ .nav-head-logo {
127
+ padding-left: min(25px, max(3px, 30 * (1vw - 12.7px) - 5px));
128
+ }
129
+ .nav-item-level-2,
130
+ .nav-item-level-3,
131
+ .nav-item-level-4 {
132
+ padding-left: min(30px, max(6px, 30 * (1vw - 12.7px)));
133
+ }
118
134
  }
@@ -68,7 +68,7 @@ function NavItemComponent({
68
68
  const icon = navItem.titleIcon && (
69
69
  <img
70
70
  src={navItem.titleIcon}
71
- style={{ height: iconSize, width: iconSize, marginRight: 8, marginLeft: 4, ...navItem.titleIconStyle }}
71
+ style={{ height: iconSize, width: iconSize, marginRight: 8, marginLeft: 2, ...navItem.titleIconStyle }}
72
72
  />
73
73
  )
74
74
 
@@ -106,7 +106,7 @@ function NavItemComponent({
106
106
  className: [
107
107
  'nav-item',
108
108
  'nav-item-level-' + navItem.level,
109
- navItem.url && navItem.isActive && ' is-active',
109
+ ((navItem.url && navItem.isActive) || navItem.level === 3) && ' is-active',
110
110
  navItem.isFirstOfItsKind && 'nav-item-first-of-its-kind',
111
111
  navItem.isLastOfItsKind && 'nav-item-last-of-its-kind',
112
112
  ]
@@ -7,9 +7,14 @@
7
7
  .colorize-on-hover:hover [class*=' decolorize-'] {
8
8
  filter: grayscale(0) opacity(1) !important;
9
9
  }
10
+ .is-active {
11
+ background-color: var(--active-color);
12
+ }
10
13
  .link-hover-animation a:hover {
11
- color: black !important;
12
14
  background-color: var(--active-color);
15
+ &.is-active {
16
+ background-color: var(--double-active-color);
17
+ }
13
18
  }
14
19
  }
15
20
 
@@ -46,5 +51,7 @@
46
51
  }
47
52
 
48
53
  body {
49
- --active-color: rgba(0, 0, 0, 0.03);
54
+ --active-color-value: 0.03;
55
+ --active-color: rgba(0, 0, 0, var(--active-color-value));
56
+ --double-active-color: rgba(0, 0, 0, calc(2 * var(--active-color-value)));
50
57
  }
@@ -9,7 +9,7 @@ function NavItemComponent({ navItem, onClick, }) {
9
9
  const titleJsx = parseMarkdownMini(navItem.title);
10
10
  const titleInNavJsx = parseMarkdownMini(navItem.titleInNav);
11
11
  const iconSize = 25;
12
- const icon = navItem.titleIcon && (React.createElement("img", { src: navItem.titleIcon, style: { height: iconSize, width: iconSize, marginRight: 8, marginLeft: 4, ...navItem.titleIconStyle } }));
12
+ const icon = navItem.titleIcon && (React.createElement("img", { src: navItem.titleIcon, style: { height: iconSize, width: iconSize, marginRight: 8, marginLeft: 2, ...navItem.titleIconStyle } }));
13
13
  if (navItem.level === 1 || navItem.level === 4) {
14
14
  assert(navItem.url === undefined);
15
15
  }
@@ -37,7 +37,7 @@ function NavItemComponent({ navItem, onClick, }) {
37
37
  className: [
38
38
  'nav-item',
39
39
  'nav-item-level-' + navItem.level,
40
- navItem.url && navItem.isActive && ' is-active',
40
+ ((navItem.url && navItem.isActive) || navItem.level === 3) && ' is-active',
41
41
  navItem.isFirstOfItsKind && 'nav-item-first-of-its-kind',
42
42
  navItem.isLastOfItsKind && 'nav-item-last-of-its-kind',
43
43
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.15.13-commit-2b0e889",
3
+ "version": "0.15.13-commit-29258f0",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",