@brillout/docpress 0.8.13 → 0.8.14

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
@@ -9,7 +9,7 @@ import { EditPageNote } from './components/EditPageNote'
9
9
  import { parseTitle } from './parseTitle'
10
10
  import { usePageContext, usePageContext2 } from './renderer/usePageContext'
11
11
  import { Links } from './Links'
12
- import { toggleMenuModal } from './MenuModal'
12
+ import { closeMenuModal, openMenuModal, toggleMenuModal } from './MenuModal'
13
13
  import { MenuModal } from './MenuModal'
14
14
  import { autoScrollNav_SSR } from './autoScrollNav'
15
15
  import { SearchLink } from './docsearch/SearchLink'
@@ -58,9 +58,10 @@ function Layout({ children }: { children: React.ReactNode }) {
58
58
  ['--bg-color']: '#f5f5f7',
59
59
  ['--block-margin']: `${blockMargin}px`,
60
60
  ['--icon-text-padding']: '8px',
61
+ ['--top-nav-height']: `${isLandingPage ? 70 : 60}px`,
61
62
  }}
62
63
  >
63
- <MenuModal />
64
+ <MenuModal isTopNav={isLandingPage} />
64
65
  <div
65
66
  className={isLandingPage ? '' : 'doc-page'}
66
67
  style={{
@@ -112,6 +113,9 @@ function LayoutDocsPage({ children }: { children: React.ReactNode }) {
112
113
  .page-content {
113
114
  margin: auto;
114
115
  }
116
+ #menu-modal {
117
+ position: absolute !important;
118
+ }
115
119
  `
116
120
  if (!hideNavLeftAlways) {
117
121
  navLeftHide = css`
@@ -198,7 +202,7 @@ function PageContent({ children }: { children: React.ReactNode }) {
198
202
  function NavMobile() {
199
203
  return (
200
204
  <div id="nav-mobile">
201
- <NavigationHeader headerHeight={70} iconSize={40} paddingLeft={12} style={{ justifyContent: 'center' }} />
205
+ <NavigationHeader iconSize={40} paddingLeft={12} style={{ justifyContent: 'center' }} />
202
206
  </div>
203
207
  )
204
208
  }
@@ -255,7 +259,7 @@ function NavLeft() {
255
259
  top: 0,
256
260
  }}
257
261
  >
258
- <NavigationHeader headerHeight={headerHeight} iconSize={39} paddingLeft={6} />
262
+ <NavigationHeader iconSize={39} paddingLeft={6} />
259
263
  <div
260
264
  style={{
261
265
  backgroundColor: 'var(--bg-color)',
@@ -293,11 +297,10 @@ function NavLeft() {
293
297
  }
294
298
 
295
299
  function NavigationHeader({
296
- headerHeight,
297
300
  iconSize,
298
301
  style,
299
302
  paddingLeft,
300
- }: { headerHeight: number; iconSize: number; paddingLeft: number; style?: React.CSSProperties }) {
303
+ }: { iconSize: number; paddingLeft: number; style?: React.CSSProperties }) {
301
304
  const pageContext = usePageContext()
302
305
  //*
303
306
  const { projectName } = pageContext.meta
@@ -324,8 +327,9 @@ function NavigationHeader({
324
327
  <div
325
328
  style={{
326
329
  display: 'flex',
327
- height: headerHeight,
330
+ height: 'var(--top-nav-height)',
328
331
  containerType: 'inline-size',
332
+ alignItems: 'center',
329
333
  ...navWidth,
330
334
  }}
331
335
  >
@@ -383,30 +387,52 @@ function NavigationHeader({
383
387
  )
384
388
  }
385
389
 
386
- type PropsAnchor = React.HTMLProps<HTMLAnchorElement>
387
- function MenuLink(props: PropsAnchor) {
390
+ let onMouseIgnore: ReturnType<typeof setTimeout> | undefined
391
+ function MenuLink({ style }: { style: React.CSSProperties }) {
388
392
  return (
389
- <a
390
- {...props}
393
+ <div
391
394
  style={{
392
395
  height: '100%',
393
396
  display: 'flex',
394
397
  alignItems: 'center',
395
- cursor: 'pointer',
396
- ...props.style,
398
+ cursor: 'default',
399
+ ...style,
397
400
  }}
398
- className="colorize-on-hover"
401
+ className="colorize-on-hover menu-toggle"
399
402
  onClick={(ev) => {
400
403
  ev.preventDefault()
401
404
  toggleMenuModal()
402
405
  }}
403
- aria-label={'Ctrl\xa0+\xa0M'}
406
+ onMouseOver={() => {
407
+ if (onMouseIgnore) return
408
+ openMenuModal()
409
+ }}
410
+ onMouseLeave={() => {
411
+ if (onMouseIgnore) return
412
+ closeMenuModal()
413
+ }}
414
+ onTouchStart={() => {
415
+ onMouseIgnore = setTimeout(() => {
416
+ onMouseIgnore = undefined
417
+ }, 1000)
418
+ }}
404
419
  >
405
- <MenuIcon />
406
- Menu
407
- </a>
420
+ <DocsIcon />
421
+ Docs
422
+ </div>
408
423
  )
409
424
  }
425
+ function DocsIcon() {
426
+ return (
427
+ <span
428
+ style={{ marginRight: 'calc(var(--icon-text-padding) + 2px)', lineHeight: 0, width: '1.3em' }}
429
+ className="decolorize-6"
430
+ >
431
+ 📚
432
+ </span>
433
+ )
434
+ }
435
+ /* TODO/now: use for mobile
410
436
  function MenuIcon() {
411
437
  return (
412
438
  <svg
@@ -421,3 +447,8 @@ function MenuIcon() {
421
447
  </svg>
422
448
  )
423
449
  }
450
+ */
451
+
452
+ function Style({ children }: { children: string }) {
453
+ return <style dangerouslySetInnerHTML={{ __html: children }} />
454
+ }
package/Links.tsx CHANGED
@@ -1,3 +1,6 @@
1
+ // TODO/refactor: rename
2
+ export { Links }
3
+
1
4
  import React from 'react'
2
5
  import iconGithub from './icons/github.svg'
3
6
  import iconTwitter from './icons/twitter.svg'
@@ -7,8 +10,6 @@ import iconLanguages from './icons/languages.svg'
7
10
  import { usePageContext } from './renderer/usePageContext'
8
11
  import '@docsearch/css'
9
12
 
10
- export { Links }
11
-
12
13
  function Links({ style }: { style?: React.CSSProperties }) {
13
14
  const pageContext = usePageContext()
14
15
  const { projectInfo, i18n } = pageContext.config
package/MenuModal.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  export { MenuModal }
2
2
  export { toggleMenuModal }
3
+ export { openMenuModal }
3
4
  export { closeMenuModal }
4
5
 
5
6
  import React from 'react'
@@ -13,46 +14,46 @@ import { getViewportWidth } from './utils/getViewportWidth'
13
14
 
14
15
  initCloseListeners()
15
16
 
16
- function MenuModal() {
17
+ function MenuModal({ isTopNav }: { isTopNav: boolean }) {
17
18
  return (
18
19
  <>
19
20
  <style>{getStyle()}</style>
20
21
  <div
21
22
  id="menu-modal"
22
- className="link-hover-animation"
23
+ className="link-hover-animation add-transition"
23
24
  style={{
24
- position: 'fixed',
25
+ position: isTopNav ? 'absolute' : 'fixed',
25
26
  width: '100%',
26
- /* Do this once Firefox supports `dvh`: https://caniuse.com/?search=dvh
27
- * - Then also replace all `vh` values with `dvh` values.
28
- * - https://stackoverflow.com/questions/37112218/css3-100vh-not-constant-in-mobile-browser/72245072#72245072
29
- height: '100dh',
30
- /*/
31
- height: '100vh',
32
- maxHeight: '100dvh',
33
- //*/
34
- top: 0,
27
+ height: 'calc(100vh - var(--top-nav-height))',
28
+ top: 'var(--top-nav-height)',
35
29
  left: 0,
36
30
  zIndex: 9999,
37
31
  overflow: 'scroll',
38
- background: '#eaeaea',
32
+ background: '#ededef',
33
+ transitionProperty: 'opacity',
39
34
  }}
35
+ onMouseOver={openMenuModal}
36
+ onMouseLeave={closeMenuModal}
40
37
  >
41
38
  <div
42
39
  style={{
43
40
  // Place <LinksBottom /> to the bottom
44
41
  display: 'flex',
45
42
  flexDirection: 'column',
46
- minHeight: '100dvh',
43
+ minHeight: 'calc(100vh - var(--top-nav-height))',
47
44
  justifyContent: 'space-between',
48
45
  // We don't set `container` to parent beacuse of a Chrome bug (showing a blank <MenuModal>)
49
46
  containerType: 'inline-size',
50
47
  }}
51
48
  >
52
49
  <Nav />
50
+ {/* TODO/now: use for mobile
53
51
  <LinksBottom />
52
+ */}
54
53
  </div>
54
+ {/* TODO/now: use for mobile
55
55
  <CloseButton />
56
+ */}
56
57
  </div>
57
58
  </>
58
59
  )
@@ -78,7 +79,8 @@ function LinksBottom() {
78
79
  function getStyle() {
79
80
  return css`
80
81
  html:not(.menu-modal-show) #menu-modal {
81
- display: none;
82
+ opacity: 0;
83
+ pointer-events: none;
82
84
  }
83
85
  // disable scroll of main view
84
86
  html.menu-modal-show {
@@ -142,6 +144,9 @@ function autoScroll() {
142
144
  inline: 'start',
143
145
  })
144
146
  }
147
+ function openMenuModal() {
148
+ document.documentElement.classList.add('menu-modal-show')
149
+ }
145
150
  function closeMenuModal() {
146
151
  document.documentElement.classList.remove('menu-modal-show')
147
152
  }
@@ -4,18 +4,33 @@
4
4
  */
5
5
  @media (hover: hover) and (pointer: fine) {
6
6
  .colorize-on-hover:hover [class^='decolorize-'],
7
- .colorize-on-hover:hover [class*=' decolorize-'] {
7
+ .colorize-on-hover:hover [class*=' decolorize-'],
8
+ html.menu-modal-show .menu-toggle [class^='decolorize-'],
9
+ html.menu-modal-show .menu-toggle [class*=' decolorize-'] {
8
10
  filter: grayscale(0) opacity(1) !important;
9
11
  }
10
- .link-hover-animation a:hover {
12
+ .link-hover-animation a:hover,
13
+ .link-hover-animation .menu-toggle:hover,
14
+ html.menu-modal-show .menu-toggle {
11
15
  color: black !important;
12
16
  background-color: var(--active-color);
13
17
  }
14
18
  }
15
19
 
16
- .colorize-on-hover [class^='decolorize-'],
17
- .colorize-on-hover [class*=' decolorize-'] {
18
- transition: filter 0.3s ease-in-out;
20
+ [class^='decolorize-'],
21
+ [class*=' decolorize-'],
22
+ .link-hover-animation a,
23
+ .link-hover-animation .menu-toggle,
24
+ .add-transition {
25
+ transition: all 0.4s ease-in-out;
26
+ }
27
+ [class^='decolorize-'],
28
+ [class*=' decolorize-'] {
29
+ transition-property: filter;
30
+ }
31
+ .link-hover-animation a,
32
+ .menu-toggle {
33
+ transition-property: color, background-color;
19
34
  }
20
35
 
21
36
  .decolorize-7 {
@@ -31,10 +46,6 @@
31
46
  filter: grayscale(1) opacity(0.4);
32
47
  }
33
48
 
34
- .link-hover-animation a {
35
- transition: all 0.3s ease-in-out !important;
36
- transition-property: color, background-color !important;
37
- }
38
49
  body {
39
50
  --active-color: rgba(0, 0, 0, 0.03);
40
51
  }
package/dist/Layout.js CHANGED
@@ -23,7 +23,7 @@ import { EditPageNote } from './components/EditPageNote';
23
23
  import { parseTitle } from './parseTitle';
24
24
  import { usePageContext, usePageContext2 } from './renderer/usePageContext';
25
25
  import { Links } from './Links';
26
- import { toggleMenuModal } from './MenuModal';
26
+ import { closeMenuModal, openMenuModal, toggleMenuModal } from './MenuModal';
27
27
  import { MenuModal } from './MenuModal';
28
28
  import { autoScrollNav_SSR } from './autoScrollNav';
29
29
  import { SearchLink } from './docsearch/SearchLink';
@@ -68,8 +68,9 @@ function Layout(_a) {
68
68
  _b['--bg-color'] = '#f5f5f7',
69
69
  _b['--block-margin'] = "".concat(blockMargin, "px"),
70
70
  _b['--icon-text-padding'] = '8px',
71
+ _b['--top-nav-height'] = "".concat(isLandingPage ? 70 : 60, "px"),
71
72
  _b) },
72
- React.createElement(MenuModal, null),
73
+ React.createElement(MenuModal, { isTopNav: isLandingPage }),
73
74
  React.createElement("div", { className: isLandingPage ? '' : 'doc-page', style: __assign({
74
75
  // We don't add `container` to `body` nor `html` beacuse in Firefox it breaks the `position: fixed` of <MenuModal>
75
76
  // https://stackoverflow.com/questions/74601420/css-container-inline-size-and-fixed-child
@@ -88,7 +89,7 @@ function LayoutDocsPage(_a) {
88
89
  React.createElement(PageContent, null, children))));
89
90
  function getStyle() {
90
91
  var style = css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n@container(min-width: ", "px) {\n .low-prio-grow {\n flex-grow: 1;\n }\n #navigation-container {\n width: ", "px !important;\n }\n}"], ["\n@container(min-width: ", "px) {\n .low-prio-grow {\n flex-grow: 1;\n }\n #navigation-container {\n width: ", "px !important;\n }\n}"])), containerQuerySpacing, navWidthMax);
91
- var navLeftHide = css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n#nav-left {\n display: none;\n}\n.page-wrapper {\n --main-view-padding: 10px !important;\n flex-grow: 1;\n align-items: center;\n}\n.page-content {\n margin: auto;\n}\n"], ["\n#nav-left {\n display: none;\n}\n.page-wrapper {\n --main-view-padding: 10px !important;\n flex-grow: 1;\n align-items: center;\n}\n.page-content {\n margin: auto;\n}\n"])));
92
+ var navLeftHide = css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n#nav-left {\n display: none;\n}\n.page-wrapper {\n --main-view-padding: 10px !important;\n flex-grow: 1;\n align-items: center;\n}\n.page-content {\n margin: auto;\n}\n#menu-modal {\n position: absolute !important;\n}\n"], ["\n#nav-left {\n display: none;\n}\n.page-wrapper {\n --main-view-padding: 10px !important;\n flex-grow: 1;\n align-items: center;\n}\n.page-content {\n margin: auto;\n}\n#menu-modal {\n position: absolute !important;\n}\n"])));
92
93
  if (!hideNavLeftAlways) {
93
94
  navLeftHide = css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n@container(max-width: ", "px) {\n ", "\n}\n@container(min-width: ", "px) {\n #nav-mobile {\n display: none !important;\n }\n}\n"], ["\n@container(max-width: ", "px) {\n ", "\n}\n@container(min-width: ", "px) {\n #nav-mobile {\n display: none !important;\n }\n}\n"])), containerQueryMobile - 1, navLeftHide, containerQueryMobile);
94
95
  }
@@ -134,7 +135,7 @@ function PageContent(_a) {
134
135
  }
135
136
  function NavMobile() {
136
137
  return (React.createElement("div", { id: "nav-mobile" },
137
- React.createElement(NavigationHeader, { headerHeight: 70, iconSize: 40, paddingLeft: 12, style: { justifyContent: 'center' } })));
138
+ React.createElement(NavigationHeader, { iconSize: 40, paddingLeft: 12, style: { justifyContent: 'center' } })));
138
139
  }
139
140
  function NavTop() {
140
141
  var _a;
@@ -174,7 +175,7 @@ function NavLeft() {
174
175
  position: 'sticky',
175
176
  top: 0,
176
177
  } },
177
- React.createElement(NavigationHeader, { headerHeight: headerHeight, iconSize: 39, paddingLeft: 6 }),
178
+ React.createElement(NavigationHeader, { iconSize: 39, paddingLeft: 6 }),
178
179
  React.createElement("div", { style: {
179
180
  backgroundColor: 'var(--bg-color)',
180
181
  display: 'flex',
@@ -187,7 +188,7 @@ function NavLeft() {
187
188
  }
188
189
  function NavigationHeader(_a) {
189
190
  var _b;
190
- var headerHeight = _a.headerHeight, iconSize = _a.iconSize, style = _a.style, paddingLeft = _a.paddingLeft;
191
+ var iconSize = _a.iconSize, style = _a.style, paddingLeft = _a.paddingLeft;
191
192
  var pageContext = usePageContext();
192
193
  //*
193
194
  var projectName = pageContext.meta.projectName;
@@ -203,7 +204,7 @@ function NavigationHeader(_a) {
203
204
  _b);
204
205
  var marginLeft = -10;
205
206
  return (React.createElement("div", { style: __assign({ backgroundColor: 'var(--bg-color)', display: 'flex', justifyContent: 'flex-end', borderBottom: 'var(--block-margin) solid white' }, style) },
206
- React.createElement("div", { style: __assign({ display: 'flex', height: headerHeight, containerType: 'inline-size' }, navWidth) },
207
+ React.createElement("div", { style: __assign({ display: 'flex', height: 'var(--top-nav-height)', containerType: 'inline-size', alignItems: 'center' }, navWidth) },
207
208
  React.createElement("a", { style: __assign(__assign({ display: 'flex', alignItems: 'center', color: 'inherit', textDecoration: 'none', height: '100%', paddingLeft: paddingLeft + marginLeft * -1, marginLeft: marginLeft }, childrenStyle), { justifyContent: 'flex-start', flexGrow: 0.5 }), href: "/" },
208
209
  React.createElement("img", { src: pageContext.meta.faviconUrl, height: iconSize, width: iconSize, onContextMenu: function (ev) {
209
210
  if (!pageContext.config.pressKit)
@@ -220,16 +221,49 @@ function NavigationHeader(_a) {
220
221
  React.createElement(SearchLink, { style: __assign(__assign({}, childrenStyle), { flexGrow: 0.5 }) }),
221
222
  React.createElement(MenuLink, { style: __assign(__assign({}, childrenStyle), { flexGrow: 1 }) }))));
222
223
  }
223
- function MenuLink(props) {
224
- return (React.createElement("a", __assign({}, props, { style: __assign({ height: '100%', display: 'flex', alignItems: 'center', cursor: 'pointer' }, props.style), className: "colorize-on-hover", onClick: function (ev) {
224
+ var onMouseIgnore;
225
+ function MenuLink(_a) {
226
+ var style = _a.style;
227
+ return (React.createElement("div", { style: __assign({ height: '100%', display: 'flex', alignItems: 'center', cursor: 'default' }, style), className: "colorize-on-hover menu-toggle", onClick: function (ev) {
225
228
  ev.preventDefault();
226
229
  toggleMenuModal();
227
- }, "aria-label": 'Ctrl\xa0+\xa0M' }),
228
- React.createElement(MenuIcon, null),
229
- "Menu"));
230
+ }, onMouseOver: function () {
231
+ if (onMouseIgnore)
232
+ return;
233
+ openMenuModal();
234
+ }, onMouseLeave: function () {
235
+ if (onMouseIgnore)
236
+ return;
237
+ closeMenuModal();
238
+ }, onTouchStart: function () {
239
+ onMouseIgnore = setTimeout(function () {
240
+ onMouseIgnore = undefined;
241
+ }, 1000);
242
+ } },
243
+ React.createElement(DocsIcon, null),
244
+ "Docs"));
230
245
  }
246
+ function DocsIcon() {
247
+ return (React.createElement("span", { style: { marginRight: 'calc(var(--icon-text-padding) + 2px)', lineHeight: 0, width: '1.3em' }, className: "decolorize-6" }, "\uD83D\uDCDA"));
248
+ }
249
+ /* TODO/now: use for mobile
231
250
  function MenuIcon() {
232
- return (React.createElement("svg", { style: { marginRight: 'calc(var(--icon-text-padding) + 2px)', lineHeight: 0, width: '1.3em' }, className: "decolorize-6", viewBox: "0 0 448 512" },
233
- React.createElement("path", { fill: "currentColor", d: "M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z" })));
251
+ return (
252
+ <svg
253
+ style={{ marginRight: 'calc(var(--icon-text-padding) + 2px)', lineHeight: 0, width: '1.3em' }}
254
+ className="decolorize-6"
255
+ viewBox="0 0 448 512"
256
+ >
257
+ <path
258
+ fill="currentColor"
259
+ d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"
260
+ ></path>
261
+ </svg>
262
+ )
263
+ }
264
+ */
265
+ function Style(_a) {
266
+ var children = _a.children;
267
+ return React.createElement("style", { dangerouslySetInnerHTML: { __html: children } });
234
268
  }
235
269
  var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
package/dist/Links.d.ts CHANGED
@@ -1,6 +1,6 @@
1
+ export { Links };
1
2
  import React from 'react';
2
3
  import '@docsearch/css';
3
- export { Links };
4
4
  declare function Links({ style }: {
5
5
  style?: React.CSSProperties;
6
6
  }): React.JSX.Element;
package/dist/Links.js CHANGED
@@ -9,6 +9,8 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ // TODO/refactor: rename
13
+ export { Links };
12
14
  import React from 'react';
13
15
  import iconGithub from './icons/github.svg';
14
16
  import iconTwitter from './icons/twitter.svg';
@@ -17,7 +19,6 @@ import iconChangelog from './icons/changelog.svg';
17
19
  import iconLanguages from './icons/languages.svg';
18
20
  import { usePageContext } from './renderer/usePageContext';
19
21
  import '@docsearch/css';
20
- export { Links };
21
22
  function Links(_a) {
22
23
  var style = _a.style;
23
24
  var pageContext = usePageContext();
@@ -1,7 +1,11 @@
1
1
  export { MenuModal };
2
2
  export { toggleMenuModal };
3
+ export { openMenuModal };
3
4
  export { closeMenuModal };
4
5
  import React from 'react';
5
- declare function MenuModal(): React.JSX.Element;
6
+ declare function MenuModal({ isTopNav }: {
7
+ isTopNav: boolean;
8
+ }): React.JSX.Element;
6
9
  declare function toggleMenuModal(): void;
10
+ declare function openMenuModal(): void;
7
11
  declare function closeMenuModal(): void;
package/dist/MenuModal.js CHANGED
@@ -4,6 +4,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
4
4
  };
5
5
  export { MenuModal };
6
6
  export { toggleMenuModal };
7
+ export { openMenuModal };
7
8
  export { closeMenuModal };
8
9
  import React from 'react';
9
10
  import { usePageContext } from './renderer/usePageContext';
@@ -14,38 +15,31 @@ import { Links } from './Links';
14
15
  import { isBrowser } from './utils/isBrowser';
15
16
  import { getViewportWidth } from './utils/getViewportWidth';
16
17
  initCloseListeners();
17
- function MenuModal() {
18
+ function MenuModal(_a) {
19
+ var isTopNav = _a.isTopNav;
18
20
  return (React.createElement(React.Fragment, null,
19
21
  React.createElement("style", null, getStyle()),
20
- React.createElement("div", { id: "menu-modal", className: "link-hover-animation", style: {
21
- position: 'fixed',
22
+ React.createElement("div", { id: "menu-modal", className: "link-hover-animation add-transition", style: {
23
+ position: isTopNav ? 'absolute' : 'fixed',
22
24
  width: '100%',
23
- /* Do this once Firefox supports `dvh`: https://caniuse.com/?search=dvh
24
- * - Then also replace all `vh` values with `dvh` values.
25
- * - https://stackoverflow.com/questions/37112218/css3-100vh-not-constant-in-mobile-browser/72245072#72245072
26
- height: '100dh',
27
- /*/
28
- height: '100vh',
29
- maxHeight: '100dvh',
30
- //*/
31
- top: 0,
25
+ height: 'calc(100vh - var(--top-nav-height))',
26
+ top: 'var(--top-nav-height)',
32
27
  left: 0,
33
28
  zIndex: 9999,
34
29
  overflow: 'scroll',
35
- background: '#eaeaea',
36
- } },
30
+ background: '#ededef',
31
+ transitionProperty: 'opacity',
32
+ }, onMouseOver: openMenuModal, onMouseLeave: closeMenuModal },
37
33
  React.createElement("div", { style: {
38
34
  // Place <LinksBottom /> to the bottom
39
35
  display: 'flex',
40
36
  flexDirection: 'column',
41
- minHeight: '100dvh',
37
+ minHeight: 'calc(100vh - var(--top-nav-height))',
42
38
  justifyContent: 'space-between',
43
39
  // We don't set `container` to parent beacuse of a Chrome bug (showing a blank <MenuModal>)
44
40
  containerType: 'inline-size',
45
41
  } },
46
- React.createElement(Nav, null),
47
- React.createElement(LinksBottom, null)),
48
- React.createElement(CloseButton, null))));
42
+ React.createElement(Nav, null)))));
49
43
  }
50
44
  function Nav() {
51
45
  var pageContext = usePageContext();
@@ -60,7 +54,7 @@ function LinksBottom() {
60
54
  React.createElement(Links, { style: { height: 70 } })));
61
55
  }
62
56
  function getStyle() {
63
- return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\nhtml:not(.menu-modal-show) #menu-modal {\n display: none;\n}\n// disable scroll of main view\nhtml.menu-modal-show {\n overflow: hidden !important;\n}\n@container(min-width: ", "px) {\n #menu-modal .nav-item-level-3 {\n display: none;\n }\n}\n"], ["\nhtml:not(.menu-modal-show) #menu-modal {\n display: none;\n}\n// disable scroll of main view\nhtml.menu-modal-show {\n overflow: hidden !important;\n}\n@container(min-width: ", "px) {\n #menu-modal .nav-item-level-3 {\n display: none;\n }\n}\n"])), containerQueryMobile);
57
+ return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\nhtml:not(.menu-modal-show) #menu-modal {\n opacity: 0;\n pointer-events: none;\n}\n// disable scroll of main view\nhtml.menu-modal-show {\n overflow: hidden !important;\n}\n@container(min-width: ", "px) {\n #menu-modal .nav-item-level-3 {\n display: none;\n }\n}\n"], ["\nhtml:not(.menu-modal-show) #menu-modal {\n opacity: 0;\n pointer-events: none;\n}\n// disable scroll of main view\nhtml.menu-modal-show {\n overflow: hidden !important;\n}\n@container(min-width: ", "px) {\n #menu-modal .nav-item-level-3 {\n display: none;\n }\n}\n"])), containerQueryMobile);
64
58
  }
65
59
  function CloseButton() {
66
60
  return (React.createElement("div", { onClick: toggleMenuModal, style: { position: 'fixed', top: 0, right: 0, zIndex: 10, padding: 11, cursor: 'pointer' }, "aria-label": 'Escape\nCtrl\xa0+\xa0M', "data-label-shift": true },
@@ -87,6 +81,9 @@ function autoScroll() {
87
81
  inline: 'start',
88
82
  });
89
83
  }
84
+ function openMenuModal() {
85
+ document.documentElement.classList.add('menu-modal-show');
86
+ }
90
87
  function closeMenuModal() {
91
88
  document.documentElement.classList.remove('menu-modal-show');
92
89
  }
@@ -21,6 +21,5 @@ function SearchLink(props) {
21
21
  "Search"));
22
22
  }
23
23
  function SearchIcon() {
24
- return (React.createElement("svg", { style: { marginRight: 'var(--icon-text-padding)', lineHeight: 0, width: '1.3em' }, className: "decolorize-7", viewBox: "0 0 20 20" },
25
- React.createElement("path", { d: "M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z", fill: "none", stroke: "currentColor", strokeWidth: "2" })));
24
+ return (React.createElement("span", { style: { marginRight: 'var(--icon-text-padding)', fontSize: '1.1em' }, className: "decolorize-7" }, "\uD83D\uDD0D"));
26
25
  }
@@ -29,17 +29,8 @@ function SearchLink(props: PropsAnchor) {
29
29
  }
30
30
  function SearchIcon() {
31
31
  return (
32
- <svg
33
- style={{ marginRight: 'var(--icon-text-padding)', lineHeight: 0, width: '1.3em' }}
34
- className="decolorize-7"
35
- viewBox="0 0 20 20"
36
- >
37
- <path
38
- d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z"
39
- fill="none"
40
- stroke="currentColor"
41
- strokeWidth="2"
42
- ></path>
43
- </svg>
32
+ <span style={{ marginRight: 'var(--icon-text-padding)', fontSize: '1.1em' }} className="decolorize-7">
33
+ 🔍
34
+ </span>
44
35
  )
45
36
  }
@@ -1,7 +1,7 @@
1
1
  export { initKeyBindings }
2
2
 
3
3
  import { closeDocsearchModal } from './docsearch/toggleDocsearchModal'
4
- import { closeMenuModal, toggleMenuModal } from './MenuModal'
4
+ import { closeMenuModal } from './MenuModal'
5
5
 
6
6
  function initKeyBindings() {
7
7
  window.addEventListener(
@@ -14,11 +14,6 @@ function initKeyBindings() {
14
14
  closeMenuModal()
15
15
  }
16
16
 
17
- if (key === 'm' && ev.ctrlKey) {
18
- closeDocsearchModal()
19
- toggleMenuModal()
20
- }
21
-
22
17
  // Replicates docsearch keybinding
23
18
  // https://github.com/algolia/docsearch/blob/90f3c6aabbc324fe49e9a1dfe0906fcd4d90f27b/packages/docsearch-react/src/useDocSearchKeyboardEvents.ts#L45-L49
24
19
  if ((key === 'k' && (ev.ctrlKey || ev.metaKey)) || (key === '/' && !isEditingContent(ev))) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.8.13",
3
+ "version": "0.8.14",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",