@brillout/docpress 0.8.15 → 0.8.16

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
@@ -11,7 +11,7 @@ import { EditPageNote } from './components/EditPageNote'
11
11
  import { parseTitle } from './parseTitle'
12
12
  import { usePageContext, usePageContext2 } from './renderer/usePageContext'
13
13
  import { NavSecondaryContent } from './NavSecondaryContent'
14
- import { closeMenuModal, openMenuModal, toggleMenuModal } from './MenuModal'
14
+ import { closeMenuModalWithDelay, openMenuModal, toggleMenuModal } from './MenuModal'
15
15
  import { MenuModal } from './MenuModal'
16
16
  import { autoScrollNav_SSR } from './autoScrollNav'
17
17
  import { SearchLink } from './docsearch/SearchLink'
@@ -479,7 +479,7 @@ function MenuLink(props: PropsDiv) {
479
479
  }}
480
480
  onMouseLeave={() => {
481
481
  if (onMouseIgnore) return
482
- closeMenuModal()
482
+ closeMenuModalWithDelay(100)
483
483
  }}
484
484
  onTouchStart={() => {
485
485
  onMouseIgnore = setTimeout(() => {
package/MenuModal.tsx CHANGED
@@ -2,6 +2,7 @@ export { MenuModal }
2
2
  export { toggleMenuModal }
3
3
  export { openMenuModal }
4
4
  export { closeMenuModal }
5
+ export { closeMenuModalWithDelay }
5
6
 
6
7
  import React from 'react'
7
8
  import { usePageContext } from './renderer/usePageContext'
@@ -12,6 +13,8 @@ import { NavSecondaryContent } from './NavSecondaryContent'
12
13
  import { getViewportWidth } from './utils/getViewportWidth'
13
14
  import { Style } from './utils/Style'
14
15
 
16
+ let closeMenuModalPending: NodeJS.Timeout
17
+
15
18
  function MenuModal({ isTopNav }: { isTopNav: boolean }) {
16
19
  return (
17
20
  <>
@@ -22,7 +25,14 @@ function MenuModal({ isTopNav }: { isTopNav: boolean }) {
22
25
  style={{
23
26
  position: isTopNav ? 'absolute' : 'fixed',
24
27
  width: '100%',
28
+ /* Firefox doesn't support `dvh` yet: https://caniuse.com/?search=dvh
29
+ * - Always use `dvh` instead of `vh` once Firefox supports it.
30
+ * - We use dvh because of mobile: https://stackoverflow.com/questions/37112218/css3-100vh-not-constant-in-mobile-browser/72245072#72245072
31
+ height: 'calc(100dvh - var(--nav-head-height))',
32
+ /*/
25
33
  height: 'calc(100vh - var(--nav-head-height))',
34
+ maxHeight: 'calc(100dvh - var(--nav-head-height))',
35
+ //*/
26
36
  top: 'var(--nav-head-height)',
27
37
  left: 0,
28
38
  zIndex: 9999,
@@ -38,7 +48,7 @@ function MenuModal({ isTopNav }: { isTopNav: boolean }) {
38
48
  // Place <LinksBottom /> to the bottom
39
49
  display: 'flex',
40
50
  flexDirection: 'column',
41
- minHeight: 'calc(100vh - var(--nav-head-height))',
51
+ minHeight: 'calc(100dvh - var(--nav-head-height))',
42
52
  justifyContent: 'space-between',
43
53
  // We don't set `container` to parent beacuse of a Chrome bug (showing a blank <MenuModal>)
44
54
  container: 'container-viewport / inline-size',
@@ -165,8 +175,12 @@ function findCollapsibleEl(navLink: HTMLElement | undefined) {
165
175
  return null
166
176
  }
167
177
  function openMenuModal() {
178
+ clearTimeout(closeMenuModalPending)
168
179
  document.documentElement.classList.add('menu-modal-show')
169
180
  }
170
181
  function closeMenuModal() {
171
182
  document.documentElement.classList.remove('menu-modal-show')
172
183
  }
184
+ function closeMenuModalWithDelay(delay: number) {
185
+ closeMenuModalPending = setTimeout(closeMenuModal, delay)
186
+ }
@@ -93,8 +93,12 @@ function NoteGeneric({
93
93
  return (
94
94
  <blockquote className={className} style={style}>
95
95
  <div style={{ marginBottom: 20 }} />
96
- <span style={{ fontFamily: 'emoji' }}>{icon}</span>
97
- <span style={{ width: iconMargin ?? undefined, display: 'inline-block' }}></span>{' '}
96
+ {icon && (
97
+ <>
98
+ <span style={{ fontFamily: 'emoji' }}>{icon}</span>
99
+ <span style={{ width: iconMargin ?? undefined, display: 'inline-block' }}></span>{' '}
100
+ </>
101
+ )}
98
102
  <div className="blockquote-content">{children}</div>
99
103
  <div style={{ marginTop: 20 }} />
100
104
  </blockquote>
package/dist/Layout.js CHANGED
@@ -25,7 +25,7 @@ import { EditPageNote } from './components/EditPageNote';
25
25
  import { parseTitle } from './parseTitle';
26
26
  import { usePageContext, usePageContext2 } from './renderer/usePageContext';
27
27
  import { NavSecondaryContent } from './NavSecondaryContent';
28
- import { closeMenuModal, openMenuModal, toggleMenuModal } from './MenuModal';
28
+ import { closeMenuModalWithDelay, openMenuModal, toggleMenuModal } from './MenuModal';
29
29
  import { MenuModal } from './MenuModal';
30
30
  import { autoScrollNav_SSR } from './autoScrollNav';
31
31
  import { SearchLink } from './docsearch/SearchLink';
@@ -290,7 +290,7 @@ function MenuLink(props) {
290
290
  }, onMouseLeave: function () {
291
291
  if (onMouseIgnore)
292
292
  return;
293
- closeMenuModal();
293
+ closeMenuModalWithDelay(100);
294
294
  }, onTouchStart: function () {
295
295
  onMouseIgnore = setTimeout(function () {
296
296
  onMouseIgnore = undefined;
@@ -2,6 +2,7 @@ export { MenuModal };
2
2
  export { toggleMenuModal };
3
3
  export { openMenuModal };
4
4
  export { closeMenuModal };
5
+ export { closeMenuModalWithDelay };
5
6
  import React from 'react';
6
7
  declare function MenuModal({ isTopNav }: {
7
8
  isTopNav: boolean;
@@ -9,3 +10,4 @@ declare function MenuModal({ isTopNav }: {
9
10
  declare function toggleMenuModal(): void;
10
11
  declare function openMenuModal(): void;
11
12
  declare function closeMenuModal(): void;
13
+ declare function closeMenuModalWithDelay(delay: number): void;
package/dist/MenuModal.js CHANGED
@@ -6,6 +6,7 @@ export { MenuModal };
6
6
  export { toggleMenuModal };
7
7
  export { openMenuModal };
8
8
  export { closeMenuModal };
9
+ export { closeMenuModalWithDelay };
9
10
  import React from 'react';
10
11
  import { usePageContext } from './renderer/usePageContext';
11
12
  import { NavigationContent } from './navigation/Navigation';
@@ -14,6 +15,7 @@ import { containerQueryMobileLayout, containerQueryMobileMenu } from './Layout';
14
15
  import { NavSecondaryContent } from './NavSecondaryContent';
15
16
  import { getViewportWidth } from './utils/getViewportWidth';
16
17
  import { Style } from './utils/Style';
18
+ var closeMenuModalPending;
17
19
  function MenuModal(_a) {
18
20
  var isTopNav = _a.isTopNav;
19
21
  return (React.createElement(React.Fragment, null,
@@ -21,7 +23,14 @@ function MenuModal(_a) {
21
23
  React.createElement("div", { id: "menu-modal", className: "link-hover-animation add-transition", style: {
22
24
  position: isTopNav ? 'absolute' : 'fixed',
23
25
  width: '100%',
26
+ /* Firefox doesn't support `dvh` yet: https://caniuse.com/?search=dvh
27
+ * - Always use `dvh` instead of `vh` once Firefox supports it.
28
+ * - We use dvh because of mobile: https://stackoverflow.com/questions/37112218/css3-100vh-not-constant-in-mobile-browser/72245072#72245072
29
+ height: 'calc(100dvh - var(--nav-head-height))',
30
+ /*/
24
31
  height: 'calc(100vh - var(--nav-head-height))',
32
+ maxHeight: 'calc(100dvh - var(--nav-head-height))',
33
+ //*/
25
34
  top: 'var(--nav-head-height)',
26
35
  left: 0,
27
36
  zIndex: 9999,
@@ -33,7 +42,7 @@ function MenuModal(_a) {
33
42
  // Place <LinksBottom /> to the bottom
34
43
  display: 'flex',
35
44
  flexDirection: 'column',
36
- minHeight: 'calc(100vh - var(--nav-head-height))',
45
+ minHeight: 'calc(100dvh - var(--nav-head-height))',
37
46
  justifyContent: 'space-between',
38
47
  // We don't set `container` to parent beacuse of a Chrome bug (showing a blank <MenuModal>)
39
48
  container: 'container-viewport / inline-size',
@@ -99,9 +108,13 @@ function findCollapsibleEl(navLink) {
99
108
  return null;
100
109
  }
101
110
  function openMenuModal() {
111
+ clearTimeout(closeMenuModalPending);
102
112
  document.documentElement.classList.add('menu-modal-show');
103
113
  }
104
114
  function closeMenuModal() {
105
115
  document.documentElement.classList.remove('menu-modal-show');
106
116
  }
117
+ function closeMenuModalWithDelay(delay) {
118
+ closeMenuModalPending = setTimeout(closeMenuModal, delay);
119
+ }
107
120
  var templateObject_1;
@@ -86,9 +86,10 @@ function NoteGeneric(_a) {
86
86
  }
87
87
  return (React.createElement("blockquote", { className: className, style: style },
88
88
  React.createElement("div", { style: { marginBottom: 20 } }),
89
- React.createElement("span", { style: { fontFamily: 'emoji' } }, icon),
90
- React.createElement("span", { style: { width: iconMargin !== null && iconMargin !== void 0 ? iconMargin : undefined, display: 'inline-block' } }),
91
- ' ',
89
+ icon && (React.createElement(React.Fragment, null,
90
+ React.createElement("span", { style: { fontFamily: 'emoji' } }, icon),
91
+ React.createElement("span", { style: { width: iconMargin !== null && iconMargin !== void 0 ? iconMargin : undefined, display: 'inline-block' } }),
92
+ ' ')),
92
93
  React.createElement("div", { className: "blockquote-content" }, children),
93
94
  React.createElement("div", { style: { marginTop: 20 } })));
94
95
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.8.15",
3
+ "version": "0.8.16",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",