@brillout/docpress 0.15.13-commit-f0b224b → 0.15.13-commit-253f5e5

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 = {
@@ -77,6 +81,8 @@ function Layout({ children }: { children: React.ReactNode }) {
77
81
  // We don't add `container` to `body` nor `html` beacuse in Firefox it breaks the `position: fixed` of <MenuModal>
78
82
  // https://stackoverflow.com/questions/74601420/css-container-inline-size-and-fixed-child
79
83
  container: 'container-viewport / inline-size',
84
+ maxWidth: bodyMaxWidth,
85
+ margin: 'auto',
80
86
  }}
81
87
  >
82
88
  <MenuModal isTopNav={isLandingPage} />
@@ -108,14 +114,22 @@ function LayoutDocsPage({ children }: { children: React.ReactNode }) {
108
114
  <PageContent>{children}</PageContent>
109
115
  </div>
110
116
  <Style>{css`
117
+ @container container-viewport (max-width: ${viewDesktopLarge - 1}px) {
118
+ #nav-left {
119
+ flex-grow: 1;
120
+ min-width: ${navLeftWidthMin + blockMargin}px;
121
+ }
122
+ }
111
123
  @container container-viewport (min-width: ${viewDesktopLarge}px) {
112
124
  .low-prio-grow {
113
125
  flex-grow: 1;
114
126
  }
115
- #navigation-container {
116
- width: ${navLeftWidthMax}px !important;
127
+ #nav-left {
128
+ min-width: ${navLeftWidthMax + blockMargin}px;
117
129
  }
118
- }`}</Style>
130
+ }
131
+
132
+ `}</Style>
119
133
  </>
120
134
  )
121
135
  }
@@ -140,7 +154,8 @@ function PageContent({ children }: { children: React.ReactNode }) {
140
154
  <div
141
155
  className="page-wrapper low-prio-grow"
142
156
  style={{
143
- // Avoid overflow, see https://stackoverflow.com/questions/36230944/prevent-flex-items-from-overflowing-a-container/66689926#66689926
157
+ // We must set min-width to avoid layout overflow on mobile/desktop view.
158
+ // https://stackoverflow.com/questions/36230944/prevent-flex-items-from-overflowing-a-container/66689926#66689926
144
159
  minWidth: 0,
145
160
  ...ifDocPage({
146
161
  backgroundColor: 'var(--bg-color)',
@@ -180,9 +195,16 @@ function NavLeft() {
180
195
  id="nav-left"
181
196
  className="link-hover-animation"
182
197
  style={{
198
+ /* TODO
183
199
  flexGrow: 1,
184
- borderRight: 'var(--block-margin) solid white',
200
+ */
201
+ borderRight: 'var(--block-margin) solid var(--background-color)',
185
202
  zIndex: 1,
203
+ // We must set min-width to avoid layout overflow when the text of a navigation item exceeds the available width.
204
+ // https://stackoverflow.com/questions/36230944/prevent-flex-items-from-overflowing-a-container/66689926#66689926
205
+ // TODO: remove
206
+ // minWidth: navLeftWidthMin + blockMargin,
207
+ // maxWidth: navLeftWidthMax,
186
208
  }}
187
209
  >
188
210
  <div
@@ -195,8 +217,10 @@ function NavLeft() {
195
217
  <div
196
218
  style={{
197
219
  backgroundColor: 'var(--bg-color)',
220
+ /* TODO: remove?
198
221
  display: 'flex',
199
222
  justifyContent: 'flex-end',
223
+ */
200
224
  }}
201
225
  >
202
226
  <div
@@ -208,7 +232,6 @@ function NavLeft() {
208
232
  overscrollBehavior: 'contain',
209
233
  paddingBottom: 40,
210
234
  minWidth: navLeftWidthMin,
211
- maxWidth: navLeftWidthMax,
212
235
  width: '100%',
213
236
  }}
214
237
  >
@@ -298,10 +321,11 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
298
321
  <div
299
322
  className={cls(['nav-head link-hover-animation', isNavLeft && 'is-nav-left', !!navMaxWidth && 'has-max-width'])}
300
323
  style={{
301
- display: 'flex',
302
- justifyContent: isNavLeft ? 'flex-end' : 'center',
324
+ // TODO: remove?
325
+ // display: 'flex',
326
+ // justifyContent: isNavLeft ? 'flex-end' : 'center',
303
327
  backgroundColor: 'var(--bg-color)',
304
- borderBottom: 'var(--block-margin) solid white',
328
+ borderBottom: 'var(--block-margin) solid var(--background-color)',
305
329
  position: 'relative',
306
330
  }}
307
331
  >
@@ -311,8 +335,9 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
311
335
  // DON'T REMOVE this container: it's needed for the `cqw` values
312
336
  container: 'container-nav-head / inline-size',
313
337
  width: '100%',
314
- minWidth: isNavLeft && navLeftWidthMin,
315
- maxWidth: isNavLeft && navLeftWidthMax,
338
+ // TODO
339
+ // minWidth: isNavLeft && navLeftWidthMin,
340
+ // maxWidth: isNavLeft && navLeftWidthMax,
316
341
  }}
317
342
  >
318
343
  <div
@@ -343,6 +368,12 @@ function getStyleNav() {
343
368
 
344
369
  // Mobile
345
370
  style += css`
371
+ /* TODO: move */
372
+ .nav-item {
373
+ box-sizing: content-box;
374
+ max-width: ${navLeftWidthMax}px;
375
+ }
376
+
346
377
  @media(max-width: ${viewMobile}px) {
347
378
  .nav-head:not(.is-nav-left) {
348
379
  .nav-head-menu-toggle {
@@ -397,6 +428,9 @@ function getStyleNav() {
397
428
  }
398
429
  }
399
430
  }
431
+ .page-wrapper {
432
+ min-width: ${mainViewWidthMax}px !important;
433
+ }
400
434
  }
401
435
  `
402
436
 
@@ -488,7 +522,7 @@ function NavHeadLeftFullWidthBackground() {
488
522
  left: 0,
489
523
  top: 0,
490
524
  boxSizing: 'content-box',
491
- borderBottom: 'var(--block-margin) solid white',
525
+ borderBottom: 'var(--block-margin) solid var(--background-color)',
492
526
  }}
493
527
  />
494
528
  <Style>{
@@ -539,6 +573,7 @@ function NavHeadLogo({ isNavLeft }: { isNavLeft?: true }) {
539
573
 
540
574
  return (
541
575
  <a
576
+ className="nav-head-logo"
542
577
  style={{
543
578
  display: 'flex',
544
579
  alignItems: 'center',
@@ -550,8 +585,10 @@ function NavHeadLogo({ isNavLeft }: { isNavLeft?: true }) {
550
585
  paddingRight: 'var(--padding-side)',
551
586
  }
552
587
  : {
588
+ /* TODO
553
589
  paddingLeft: 15,
554
590
  marginLeft: -10,
591
+ */
555
592
  }),
556
593
  }}
557
594
  href="/"
package/MenuModal.tsx CHANGED
@@ -3,7 +3,7 @@ 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'
@@ -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: 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-f0b224b",
3
+ "version": "0.15.13-commit-253f5e5",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",