@brillout/docpress 0.8.1 → 0.8.3

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%',
@@ -403,21 +410,18 @@ function MenuLink(props: PropsDiv) {
403
410
  ev.preventDefault()
404
411
  toggleMenuModal()
405
412
  }}
406
- aria-label={hotkeyMenuOpen}
407
- data-balloon-pos="left"
408
- data-balloon-blunt
409
- data-balloon-nofocus
413
+ aria-label={'Ctrl\xa0+\xa0M'}
410
414
  >
411
415
  <MenuIcon />
412
416
  Menu
413
- </div>
417
+ </a>
414
418
  )
415
419
  }
416
420
  function MenuIcon() {
417
421
  return (
418
422
  <svg
419
423
  style={{ marginRight: 'calc(var(--icon-padding) + 2px)', lineHeight: 0, width: '1.3em' }}
420
- className="decolorize-7"
424
+ className="decolorize-6"
421
425
  viewBox="0 0 448 512"
422
426
  >
423
427
  <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
@@ -1,8 +1,6 @@
1
1
  export { MenuModal }
2
2
  export { toggleMenuModal }
3
3
  export { closeMenuModal }
4
- export { hotkeyMenuOpen }
5
- export { hotkeyMenuClose }
6
4
 
7
5
  import React from 'react'
8
6
  import { usePageContext } from './renderer/usePageContext'
@@ -11,15 +9,13 @@ import { css } from './utils/css'
11
9
  import { containerQueryMobile } from './Layout'
12
10
  import { Links } from './Links'
13
11
 
14
- const hotkeyMenuOpen = 'Ctrl + M'
15
- const hotkeyMenuClose = 'Ctrl+M or Escape'
16
-
17
12
  function MenuModal() {
18
13
  return (
19
14
  <>
20
15
  <style>{getStyle()}</style>
21
16
  <div
22
17
  id="menu-modal"
18
+ className="link-hover-animation"
23
19
  style={{
24
20
  position: 'fixed',
25
21
  width: '100%',
@@ -59,11 +55,9 @@ function LinksBottom() {
59
55
  style={{
60
56
  display: 'flex',
61
57
  justifyContent: 'center',
62
- paddingTop: 10,
63
- paddingBottom: 40,
64
58
  }}
65
59
  >
66
- <Links />
60
+ <Links style={{ height: 70 }} />
67
61
  </div>
68
62
  )
69
63
  }
@@ -87,13 +81,11 @@ html.menu-modal-show {
87
81
 
88
82
  function CloseButton() {
89
83
  return (
90
- <a
84
+ <div
91
85
  onClick={toggleMenuModal}
92
- style={{ position: 'fixed', top: 11, right: 11, zIndex: 10 }}
93
- aria-label={hotkeyMenuClose}
94
- data-balloon-pos="left"
95
- data-balloon-blunt
96
- data-balloon-nofocus
86
+ style={{ position: 'fixed', top: 0, right: 0, zIndex: 10, padding: 11, cursor: 'pointer' }}
87
+ aria-label={'Escape\nCtrl\xa0+\xa0M'}
88
+ data-label-shift
97
89
  >
98
90
  <svg width="48.855" height="48.855" version="1.1" viewBox="0 0 22.901 22.901" xmlns="http://www.w3.org/2000/svg">
99
91
  <circle
@@ -115,7 +107,7 @@ function CloseButton() {
115
107
  strokeWidth=".11719"
116
108
  />
117
109
  </svg>
118
- </a>
110
+ </div>
119
111
  )
120
112
  }
121
113
 
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/font.css CHANGED
@@ -1,5 +1,7 @@
1
+ @import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
2
+
1
3
  body {
2
- font-family: 'Inter';
4
+ font-family: 'Inter', sans-serif;
3
5
  }
4
6
  button {
5
7
  font-family: inherit;
@@ -9,17 +11,3 @@ body {
9
11
  color: var(--color-text);
10
12
  line-height: 1.5;
11
13
  }
12
-
13
- @font-face {
14
- font-family: 'Inter';
15
- font-weight: 100 900;
16
- font-stretch: 75% 125%;
17
- font-style: oblique 0deg 12deg;
18
- src: url('./Inter-Var.ttf') format('truetype-variations');
19
- }
20
-
21
- em,
22
- i {
23
- font-variation-settings: 'slnt' -10;
24
- font-style: normal;
25
- }
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
  }
package/css/tooltip.css CHANGED
@@ -1,11 +1,23 @@
1
- @import 'balloon-css';
2
-
3
- :root {
4
- --balloon-color: #444;
5
- --balloon-move: 2px;
6
- --balloon-font-size: 14px;
7
- --balloon-border-radius: 5px;
1
+ [aria-label] {
2
+ position: relative;
8
3
  }
9
- [aria-label][data-balloon-pos]:after {
10
- font-family: 'Inter';
4
+ [aria-label]:hover::before {
5
+ font-family: monospace;
6
+ font-size: 12px;
7
+ content: attr(aria-label);
8
+ position: absolute;
9
+ top: 100%;
10
+ left: 50%;
11
+ transform: translate(-50%, 0);
12
+ margin-top: 5px;
13
+ background: #fdfdfd;
14
+ padding: 3px 10px;
15
+ box-shadow: rgb(0 0 0 / 8%) 2px 4px 7px 0px;
16
+ border-radius: 5px;
17
+ color: #333;
18
+ letter-spacing: -0.02em;
19
+ border: 1px solid #e3e3e3;
20
+ }
21
+ [data-label-shift]::before {
22
+ margin-left: -10px;
11
23
  }
@@ -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%',
@@ -20,21 +20,18 @@ function SearchLink(props: PropsDiv) {
20
20
  ev.preventDefault()
21
21
  openDocsearchModal()
22
22
  }}
23
- aria-label="Ctrl + K"
24
- data-balloon-pos="left"
25
- data-balloon-blunt
26
- data-balloon-nofocus
23
+ aria-label={'Ctrl\xa0+\xa0K'}
27
24
  >
28
25
  <SearchIcon />
29
26
  Search
30
- </div>
27
+ </a>
31
28
  )
32
29
  }
33
30
  function SearchIcon() {
34
31
  return (
35
32
  <svg
36
33
  style={{ marginRight: 'var(--icon-padding)', lineHeight: 0, width: '1.3em' }}
37
- className="decolorize-6"
34
+ className="decolorize-7"
38
35
  viewBox="0 0 20 20"
39
36
  >
40
37
  <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.3",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",
@@ -11,7 +11,6 @@
11
11
  "@mdx-js/rollup": "3.0.1",
12
12
  "@shikijs/transformers": "1.2.0",
13
13
  "@vitejs/plugin-react-swc": "^3.3.2",
14
- "balloon-css": "1.2.0",
15
14
  "rehype-pretty-code": "0.13.0",
16
15
  "remark-gfm": "4.0.0",
17
16
  "shiki": "1.2.0",
package/css/Inter-Var.ttf DELETED
Binary file