@brillout/docpress 0.8.1 → 0.8.2

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
@@ -203,6 +203,7 @@ function NavTop() {
203
203
  return (
204
204
  <div
205
205
  id="top-navigation"
206
+ className="link-hover-animation"
206
207
  style={{
207
208
  position: 'relative',
208
209
  display: 'flex',
@@ -252,6 +253,7 @@ function NavLeft() {
252
253
  <>
253
254
  <div
254
255
  id="nav-left"
256
+ className="link-hover-animation"
255
257
  style={{
256
258
  flexGrow: 1,
257
259
  borderRight: 'var(--block-margin) solid white',
@@ -307,14 +309,14 @@ function NavigationHeader({
307
309
  }: { headerHeight: number; headerPadding: number; style?: React.CSSProperties }) {
308
310
  const pageContext = usePageContext()
309
311
  const iconSize = headerHeight - 2 * headerPadding
310
- //*
311
- const { projectName } = pageContext.meta
312
+ /*
313
+ const {projectName} = pageContext.meta
312
314
  /*/
313
315
  const projectName = 'Vike'
314
316
  //*/
315
317
  const isProjectNameShort = projectName.length <= 4
316
318
  const childrenStyle: React.CSSProperties = {
317
- flexGrow: 1,
319
+ justifyContent: 'center',
318
320
  fontSize: isProjectNameShort ? '4.8cqw' : '4.5cqw',
319
321
  ['--icon-padding']: '1.8cqw',
320
322
  }
@@ -344,8 +346,11 @@ function NavigationHeader({
344
346
  textDecoration: 'none',
345
347
  height: '100%',
346
348
  padding: `${headerPadding}px 0`,
347
- paddingLeft: 4,
349
+ paddingLeft: 4 + 10,
350
+ marginLeft: -10,
348
351
  ...childrenStyle,
352
+ justifyContent: 'flex-start',
353
+ flexGrow: 0.5,
349
354
  }}
350
355
  href="/"
351
356
  >
@@ -373,12 +378,14 @@ function NavigationHeader({
373
378
  style={{
374
379
  //
375
380
  ...childrenStyle,
381
+ flexGrow: 0.5,
376
382
  }}
377
383
  />
378
384
  <MenuLink
379
385
  style={{
380
386
  //
381
387
  ...childrenStyle,
388
+ flexGrow: 1,
382
389
  }}
383
390
  />
384
391
  </div>
@@ -386,10 +393,10 @@ function NavigationHeader({
386
393
  )
387
394
  }
388
395
 
389
- type PropsDiv = React.HTMLProps<HTMLDivElement>
390
- function MenuLink(props: PropsDiv) {
396
+ type PropsAnchor = React.HTMLProps<HTMLAnchorElement>
397
+ function MenuLink(props: PropsAnchor) {
391
398
  return (
392
- <div
399
+ <a
393
400
  {...props}
394
401
  style={{
395
402
  height: '100%',
@@ -410,14 +417,14 @@ function MenuLink(props: PropsDiv) {
410
417
  >
411
418
  <MenuIcon />
412
419
  Menu
413
- </div>
420
+ </a>
414
421
  )
415
422
  }
416
423
  function MenuIcon() {
417
424
  return (
418
425
  <svg
419
426
  style={{ marginRight: 'calc(var(--icon-padding) + 2px)', lineHeight: 0, width: '1.3em' }}
420
- className="decolorize-7"
427
+ className="decolorize-6"
421
428
  viewBox="0 0 448 512"
422
429
  >
423
430
  <path
package/Links.tsx CHANGED
@@ -27,6 +27,7 @@ function Links({ style }: { style?: React.CSSProperties }) {
27
27
  alignItems: 'center',
28
28
  paddingTop: 0,
29
29
  justifyContent: 'left',
30
+ height: '100%',
30
31
  ...style,
31
32
  }}
32
33
  >
@@ -47,20 +48,28 @@ function ChangelogButton() {
47
48
  return (
48
49
  <a
49
50
  href={`${projectInfo.githubRepository}/blob/main/CHANGELOG.md`}
50
- className="button colorize-on-hover"
51
+ className="colorize-on-hover"
51
52
  style={{
52
53
  display: 'flex',
53
54
  alignItems: 'center',
54
- padding: '1px 7px',
55
- marginLeft: 5,
56
- fontSize: '0.97em',
57
- color: 'inherit',
55
+ padding: 10,
56
+ height: '100%',
58
57
  }}
59
58
  >
60
- <span id="version-number" className="decolorize-7">
61
- v{projectInfo.projectVersion}
62
- </span>
63
- <img className="decolorize-6" src={iconChangelog} height={16} style={{ marginLeft: 5 }} />
59
+ <div
60
+ className="button"
61
+ style={{
62
+ display: 'flex',
63
+ alignItems: 'center',
64
+ padding: '2px 10px',
65
+ fontSize: '0.97em',
66
+ }}
67
+ >
68
+ <span id="version-number" className="decolorize-7">
69
+ v{projectInfo.projectVersion}
70
+ </span>
71
+ <img className="decolorize-6" src={iconChangelog} height={16} style={{ marginLeft: 6 }} />
72
+ </div>
64
73
  </a>
65
74
  )
66
75
  }
@@ -69,11 +78,11 @@ function LinkIcon({ className, icon, href, style }: { className: string; icon: s
69
78
  return (
70
79
  <>
71
80
  <a
72
- className={'colorize-on-hover ' + className}
81
+ className="colorize-on-hover"
73
82
  href={href}
74
- style={{ padding: 5, display: 'inline-block', lineHeight: 0 }}
83
+ style={{ padding: 5, display: 'inline-flex', lineHeight: 0, height: '100%', alignItems: 'center' }}
75
84
  >
76
- <img src={icon} height="20" style={style} />
85
+ <img className={className} src={icon} height="20" style={style} />
77
86
  </a>
78
87
  </>
79
88
  )
package/MenuModal.tsx CHANGED
@@ -20,6 +20,7 @@ function MenuModal() {
20
20
  <style>{getStyle()}</style>
21
21
  <div
22
22
  id="menu-modal"
23
+ className="link-hover-animation"
23
24
  style={{
24
25
  position: 'fixed',
25
26
  width: '100%',
@@ -59,11 +60,9 @@ function LinksBottom() {
59
60
  style={{
60
61
  display: 'flex',
61
62
  justifyContent: 'center',
62
- paddingTop: 10,
63
- paddingBottom: 40,
64
63
  }}
65
64
  >
66
- <Links />
65
+ <Links style={{ height: 70 }} />
67
66
  </div>
68
67
  )
69
68
  }
@@ -87,9 +86,9 @@ html.menu-modal-show {
87
86
 
88
87
  function CloseButton() {
89
88
  return (
90
- <a
89
+ <div
91
90
  onClick={toggleMenuModal}
92
- style={{ position: 'fixed', top: 11, right: 11, zIndex: 10 }}
91
+ style={{ position: 'fixed', top: 0, right: 0, zIndex: 10, padding: 11 }}
93
92
  aria-label={hotkeyMenuClose}
94
93
  data-balloon-pos="left"
95
94
  data-balloon-blunt
@@ -115,7 +114,7 @@ function CloseButton() {
115
114
  strokeWidth=".11719"
116
115
  />
117
116
  </svg>
118
- </a>
117
+ </div>
119
118
  )
120
119
  }
121
120
 
package/css/button.css CHANGED
@@ -1,5 +1,5 @@
1
1
  button,
2
- a.button {
2
+ .button {
3
3
  background-color: #fafafa;
4
4
  border: 1px solid #aaa;
5
5
  border-radius: 5px;
@@ -1,9 +1,7 @@
1
- .colorize-on-hover,
2
1
  .colorize-on-hover [class^='decolorize-'],
3
2
  .colorize-on-hover [class*=' decolorize-'] {
4
3
  transition: filter 0.3s ease-in-out;
5
4
  }
6
- .colorize-on-hover:hover,
7
5
  .colorize-on-hover:hover [class^='decolorize-'],
8
6
  .colorize-on-hover:hover [class*=' decolorize-'] {
9
7
  filter: grayscale(0) opacity(1) !important;
@@ -22,8 +20,14 @@
22
20
  filter: grayscale(1) opacity(0.4);
23
21
  }
24
22
 
25
- /*
26
- * Twitter opacity(0.7): #ababab > #868686
27
- * == Following computation does NOT work ==
28
- * Discord opacity(0.7): #6c6c6c > (0.7 * (#fff - #ababab) = #868686 = x * (#fff - #6c6c6c) <=> x = 0.7 * ((#fff - #ababab) / (#fff - #6c6c6c)) = 0.7 * ((255 - 171) / (255 - 108)) = 0.4)
29
- */
23
+ .link-hover-animation a {
24
+ transition: all 0.3s ease-in-out !important;
25
+ transition-property: color, background-color !important;
26
+ }
27
+ .link-hover-animation a:hover {
28
+ color: black !important;
29
+ background-color: var(--active-color);
30
+ }
31
+ body {
32
+ --active-color: rgba(0, 0, 0, 0.03);
33
+ }
package/css/link.css CHANGED
@@ -1,17 +1,9 @@
1
- /*
2
- :root {
3
- --link-color: #4747ff;
4
- }
5
- */
6
-
7
1
  a {
8
- /*
9
- color: inherit;
10
- color: var(--link-color);
11
- */
12
- color: #4747ff;
13
2
  text-decoration: none;
14
3
  }
4
+ a[href]:not(.nav-item) {
5
+ color: #4747ff;
6
+ }
15
7
  a > button {
16
8
  color: var(--color-text);
17
9
  }
@@ -70,7 +70,10 @@ function NavItemComponent(_a) {
70
70
  */
71
71
  ].join(' '));
72
72
  }
73
- return (React.createElement("a", { className: [
73
+ var props = {
74
+ href: (_b = navItem.url) !== null && _b !== void 0 ? _b : undefined,
75
+ children: titleInNavJsx,
76
+ className: [
74
77
  'nav-item',
75
78
  'nav-item-level-' + navItem.level,
76
79
  navItem.url && navItem.isActive && ' is-active',
@@ -78,7 +81,14 @@ function NavItemComponent(_a) {
78
81
  navItem.isLastOfItsKind && 'nav-item-last-of-its-kind',
79
82
  ]
80
83
  .filter(Boolean)
81
- .join(' '), href: (_b = navItem.url) !== null && _b !== void 0 ? _b : undefined }, titleInNavJsx));
84
+ .join(' '),
85
+ };
86
+ if (navItem.level === 2 || navItem.level === 3) {
87
+ return React.createElement("a", __assign({}, props));
88
+ }
89
+ else {
90
+ return React.createElement("span", __assign({}, props));
91
+ }
82
92
  }
83
93
  function groupByColumnLayout(navItems) {
84
94
  var navItemsColumnLayout = [];
@@ -3,10 +3,10 @@ export { SearchLink }
3
3
  import React from 'react'
4
4
  import { openDocsearchModal } from './toggleDocsearchModal'
5
5
 
6
- type PropsDiv = React.HTMLProps<HTMLDivElement>
7
- function SearchLink(props: PropsDiv) {
6
+ type PropsAnchor = React.HTMLProps<HTMLAnchorElement>
7
+ function SearchLink(props: PropsAnchor) {
8
8
  return (
9
- <div
9
+ <a
10
10
  {...props}
11
11
  style={{
12
12
  height: '100%',
@@ -27,14 +27,14 @@ function SearchLink(props: PropsDiv) {
27
27
  >
28
28
  <SearchIcon />
29
29
  Search
30
- </div>
30
+ </a>
31
31
  )
32
32
  }
33
33
  function SearchIcon() {
34
34
  return (
35
35
  <svg
36
36
  style={{ marginRight: 'var(--icon-padding)', lineHeight: 0, width: '1.3em' }}
37
- className="decolorize-6"
37
+ className="decolorize-7"
38
38
  viewBox="0 0 20 20"
39
39
  >
40
40
  <path
@@ -5,32 +5,27 @@ import { closeMenuModal, toggleMenuModal } from './MenuModal'
5
5
 
6
6
  function initKeyBindings() {
7
7
  window.addEventListener(
8
- // Cannot use `keyup`: https://stackoverflow.com/questions/66595035/how-to-detect-escape-key-if-search-bar-of-browser-is-open/66600548#66600548
9
8
  'keydown',
10
9
  (ev) => {
11
- if (ev.key === 'Escape') {
10
+ const key = (ev.key || '').toLowerCase()
11
+
12
+ if (key === 'escape') {
12
13
  closeDocsearchModal()
13
14
  closeMenuModal()
14
- return
15
15
  }
16
16
 
17
- const key = (ev.key || '').toLowerCase()
18
- const isCtrl = ev.metaKey || ev.ctrlKey
19
- if (isCtrl && key === 'm') {
20
- ev.preventDefault()
17
+ if (key === 'm' && ev.ctrlKey) {
21
18
  closeDocsearchModal()
22
19
  toggleMenuModal()
23
- return
24
20
  }
25
21
 
26
- // Replicate https://github.com/algolia/docsearch/blob/90f3c6aabbc324fe49e9a1dfe0906fcd4d90f27b/packages/docsearch-react/src/useDocSearchKeyboardEvents.ts#L45-L49
27
- if ((isCtrl && key === 'k') || (key === '/' && !isEditingContent(ev))) {
28
- ev.preventDefault()
22
+ // Replicates docsearch keybinding
23
+ // https://github.com/algolia/docsearch/blob/90f3c6aabbc324fe49e9a1dfe0906fcd4d90f27b/packages/docsearch-react/src/useDocSearchKeyboardEvents.ts#L45-L49
24
+ if ((key === 'k' && (ev.ctrlKey || ev.metaKey)) || (key === '/' && !isEditingContent(ev))) {
29
25
  closeMenuModal()
30
- return
31
26
  }
32
27
  },
33
- false,
28
+ { passive: true },
34
29
  )
35
30
  }
36
31
  function isEditingContent(event: KeyboardEvent): boolean {
@@ -3,7 +3,6 @@
3
3
  white-space: nowrap;
4
4
  overflow-x: hidden;
5
5
  --padding-left-global: 9px;
6
- --padding-left-additional: 0px;
7
6
  }
8
7
  .nav-item code {
9
8
  font-size: 0.9em;
@@ -53,49 +52,45 @@
53
52
  text-decoration: none;
54
53
  --padding: 5px;
55
54
 
56
- /* #ededed === rgb(237, 237, 237)
57
- * #f5f5f5 === rgb(245, 245, 245)
58
- * 1 - (237 / 245) === 0.03265306122
59
- background-color: #ededed;
60
- */
61
- background-color: rgba(0,0,0, 0.03265306122);
62
55
  padding: var(--padding) 0;
63
- padding-left: calc(var(--padding-left-global) + var(--padding-left-additional));
56
+ padding-left: calc(var(--padding-left-global) + 6px);
64
57
  }
65
58
  #menu-modal .nav-item-level-3 {
66
59
  border-right: 4px solid #eee;
67
60
  }
68
- .nav-item {
69
- /*
70
- --shadow-size: 14px;
71
- --shadow-color: rgba(0, 0, 0, 0.09);
72
- */
73
- --shadow-size: 7px;
61
+ .nav-item-level-3 {
62
+ --shadow-size: 9px;
74
63
  --shadow-color: rgba(0, 0, 0, 0.11);
75
64
  --shadow-size-minus: calc(-1 * var(--shadow-size));
76
65
  --shadow-top: inset 0px var(--shadow-size) var(--shadow-size) var(--shadow-size-minus) var(--shadow-color);
77
66
  --shadow-bottom: inset 0px var(--shadow-size-minus) var(--shadow-size) var(--shadow-size-minus) var(--shadow-color);
67
+ --box-shadow-left: inset var(--shadow-size-minus) 0px var(--shadow-size) var(--shadow-size-minus) var(--shadow-color);
68
+ --box-shadow-right: inset var(--shadow-size) 0px var(--shadow-size) var(--shadow-size-minus) var(--shadow-color);
78
69
  --box-shadow-top: 0 0;
79
70
  --box-shadow-bottom: 0 0;
80
- box-shadow: var(--box-shadow-top), var(--box-shadow-bottom);
71
+ box-shadow: var(--box-shadow-top), var(--box-shadow-bottom), var(--box-shadow-left), var(--box-shadow-right);
81
72
  }
82
73
  .nav-item-level-3.nav-item-first-of-its-kind {
83
- padding-top: calc(var(--padding) * 1.8);
74
+ padding-top: 10px;
84
75
  --box-shadow-top: var(--shadow-top);
85
76
  }
86
77
  .nav-item-level-3.nav-item-last-of-its-kind {
87
- padding-bottom: calc(var(--padding) * 1.8);
78
+ padding-bottom: 10px;
88
79
  --box-shadow-bottom: var(--shadow-bottom);
89
80
  }
90
81
  .nav-item-level-2,
91
82
  .nav-item-level-3 {
92
83
  position: relative;
93
84
  }
94
- .nav-item-level-2.is-active {
95
- /* #ededed === rgb(237, 237, 237)
96
- * #f5f5f5 === rgb(245, 245, 245)
97
- * 1 - (237 / 245) === 0.03265306122
98
- background-color: #ededed;
99
- */
100
- background-color: rgba(0,0,0, 0.03265306122);
85
+
86
+ .nav-item-level-3::before,
87
+ .nav-item-level-2.is-active::before {
88
+ background-color: var(--active-color);
89
+ position: absolute;
90
+ height: 100%;
91
+ width: 100%;
92
+ top: 0;
93
+ left: 0;
94
+ z-index: 1;
95
+ content: "";
101
96
  }
@@ -92,8 +92,10 @@ function NavItemComponent({
92
92
  navItem: NavItemComputed
93
93
  }) {
94
94
  assert([1, 2, 3, 4].includes(navItem.level), navItem)
95
+
95
96
  const titleJsx = parseTitle(navItem.title)
96
97
  const titleInNavJsx = parseTitle(navItem.titleInNav)
98
+
97
99
  if (navItem.level === 1 || navItem.level === 4) {
98
100
  assert(navItem.url === undefined)
99
101
  } else {
@@ -109,23 +111,28 @@ function NavItemComponent({
109
111
  ].join(' '),
110
112
  )
111
113
  }
112
- return (
113
- <a
114
- className={[
115
- 'nav-item',
116
- 'nav-item-level-' + navItem.level,
117
- navItem.url && navItem.isActive && ' is-active',
118
- navItem.isFirstOfItsKind && 'nav-item-first-of-its-kind',
119
- navItem.isLastOfItsKind && 'nav-item-last-of-its-kind',
120
- ]
121
- .filter(Boolean)
122
- .join(' ')}
123
- href={navItem.url ?? undefined}
124
- >
125
- {/* <span className="nav-item-text">{titleInNavJsx}</span> */}
126
- {titleInNavJsx}
127
- </a>
128
- )
114
+
115
+ const props: PropsAnchor & PropsSpan = {
116
+ href: navItem.url ?? undefined,
117
+ children: titleInNavJsx,
118
+ className: [
119
+ 'nav-item',
120
+ 'nav-item-level-' + navItem.level,
121
+ navItem.url && navItem.isActive && ' is-active',
122
+ navItem.isFirstOfItsKind && 'nav-item-first-of-its-kind',
123
+ navItem.isLastOfItsKind && 'nav-item-last-of-its-kind',
124
+ ]
125
+ .filter(Boolean)
126
+ .join(' '),
127
+ }
128
+ type PropsAnchor = React.HTMLProps<HTMLAnchorElement>
129
+ type PropsSpan = React.HTMLProps<HTMLSpanElement>
130
+
131
+ if (navItem.level === 2 || navItem.level === 3) {
132
+ return <a {...props} />
133
+ } else {
134
+ return <span {...props} />
135
+ }
129
136
  }
130
137
 
131
138
  type NavItemsColumnEntry = NavItemComputed & { navItemChilds: NavItemComputed[] }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",