@brillout/docpress 0.15.13-commit-f8fc961 → 0.15.13-commit-a35cb87
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 +23 -26
- package/MenuModal/toggleMenuModal.ts +35 -8
- package/MenuModal.tsx +3 -3
- package/code-blocks/components/Pre.tsx +1 -1
- package/css/tooltip.css +3 -2
- package/package.json +1 -1
- package/utils/getViewportWidth.ts +2 -2
package/Layout.tsx
CHANGED
|
@@ -7,7 +7,9 @@ export { navLeftWidthMax }
|
|
|
7
7
|
export { unexpandNav }
|
|
8
8
|
export { blockMargin }
|
|
9
9
|
|
|
10
|
-
// -
|
|
10
|
+
// - @media VS @container
|
|
11
|
+
// - Using `@container container-viewport` instead of @media would be interesting because @media doesn't consider the scrollbar width.
|
|
12
|
+
// - But we still use @media because using @container is complicated(/buggy?) to use inside <MenuModal> because of `position: fixed`.
|
|
11
13
|
// - We use --padding-side because we cannot set a fixed max-width on the <NavHead> container .nav-head-content — DocPress doesn't know how many extra <NavHead> elements the user adds using the +docpress.topNavigation setting.
|
|
12
14
|
|
|
13
15
|
import React from 'react'
|
|
@@ -15,7 +17,12 @@ import { getNavItemsWithComputed, NavItem, NavItemComponent } from './NavItemCom
|
|
|
15
17
|
import { parseMarkdownMini } from './parseMarkdownMini'
|
|
16
18
|
import { usePageContext } from './renderer/usePageContext'
|
|
17
19
|
import { ExternalLinks } from './ExternalLinks'
|
|
18
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
closeMenuModalOnMouseLeaveToggle,
|
|
22
|
+
ignoreHoverOnTouchStart,
|
|
23
|
+
openMenuModalOnMouseEnter,
|
|
24
|
+
toggleMenuModal,
|
|
25
|
+
} from './MenuModal/toggleMenuModal'
|
|
19
26
|
import { MenuModal } from './MenuModal'
|
|
20
27
|
import { autoScrollNav_SSR } from './autoScrollNav'
|
|
21
28
|
import { initializeJsToggle_SSR } from './code-blocks/hooks/useSelectCodeLang'
|
|
@@ -34,7 +41,7 @@ const mainViewWidthMax = (mainViewWidthMaxInner + mainViewPadding * 2) as 840 //
|
|
|
34
41
|
const navLeftWidthMin = 300
|
|
35
42
|
const navLeftWidthMax = 370
|
|
36
43
|
const viewMobile = 450
|
|
37
|
-
const viewTablet =
|
|
44
|
+
const viewTablet = 1016
|
|
38
45
|
const viewDesktop = (mainViewWidthMax + navLeftWidthMin) as 1140 // 1140 = 840 + 300
|
|
39
46
|
const viewDesktopLarge = (mainViewWidthMax + navLeftWidthMax + blockMargin) as 1213 // 1213 = 840 + 370 + 3
|
|
40
47
|
|
|
@@ -336,7 +343,7 @@ function getStyleNav() {
|
|
|
336
343
|
|
|
337
344
|
// Mobile
|
|
338
345
|
style += css`
|
|
339
|
-
@
|
|
346
|
+
@media(max-width: ${viewMobile}px) {
|
|
340
347
|
.nav-head:not(.is-nav-left) {
|
|
341
348
|
.nav-head-menu-toggle {
|
|
342
349
|
justify-content: flex-end !important;
|
|
@@ -353,7 +360,7 @@ function getStyleNav() {
|
|
|
353
360
|
|
|
354
361
|
// Mobile + tablet
|
|
355
362
|
style += css`
|
|
356
|
-
@
|
|
363
|
+
@media(max-width: ${viewTablet}px) {
|
|
357
364
|
.nav-head:not(.is-nav-left) {
|
|
358
365
|
.nav-head-secondary {
|
|
359
366
|
display: none !important;
|
|
@@ -363,7 +370,7 @@ function getStyleNav() {
|
|
|
363
370
|
|
|
364
371
|
// Tablet
|
|
365
372
|
style += css`
|
|
366
|
-
@
|
|
373
|
+
@media(max-width: ${viewTablet}px) and (min-width: ${viewMobile + 1}px) {
|
|
367
374
|
.nav-head:not(.is-nav-left) {
|
|
368
375
|
.nav-head-content {
|
|
369
376
|
--icon-text-padding: 8px;
|
|
@@ -374,7 +381,7 @@ function getStyleNav() {
|
|
|
374
381
|
|
|
375
382
|
// Desktop small + desktop
|
|
376
383
|
style += css`
|
|
377
|
-
@
|
|
384
|
+
@media(min-width: ${viewTablet + 1}px) {
|
|
378
385
|
.nav-head:not(.is-nav-left) {
|
|
379
386
|
.nav-head-content {
|
|
380
387
|
--icon-text-padding: min(8px, 0.5cqw);
|
|
@@ -542,7 +549,10 @@ function NavHeadLogo({ isNavLeft }: { isNavLeft?: true }) {
|
|
|
542
549
|
paddingLeft: 'var(--main-view-padding)',
|
|
543
550
|
paddingRight: 'var(--padding-side)',
|
|
544
551
|
}
|
|
545
|
-
: {
|
|
552
|
+
: {
|
|
553
|
+
paddingLeft: 15,
|
|
554
|
+
marginLeft: -10,
|
|
555
|
+
}),
|
|
546
556
|
}}
|
|
547
557
|
href="/"
|
|
548
558
|
onContextMenu={!navLogo ? undefined : onContextMenu}
|
|
@@ -562,7 +572,6 @@ function isProjectNameShort(name: string) {
|
|
|
562
572
|
return name.length <= 4
|
|
563
573
|
}
|
|
564
574
|
|
|
565
|
-
let onMouseIgnore: ReturnType<typeof setTimeout> | undefined
|
|
566
575
|
type PropsDiv = React.HTMLProps<HTMLDivElement>
|
|
567
576
|
function MenuToggleMain(props: PropsDiv) {
|
|
568
577
|
return (
|
|
@@ -574,12 +583,12 @@ function MenuToggleMain(props: PropsDiv) {
|
|
|
574
583
|
<MenuIcon /> Menu
|
|
575
584
|
</span>
|
|
576
585
|
<Style>{css`
|
|
577
|
-
@
|
|
586
|
+
@media(max-width: ${viewTablet}px) {
|
|
578
587
|
.text-docs, .caret-icon {
|
|
579
588
|
display: none !important;
|
|
580
589
|
}
|
|
581
590
|
}
|
|
582
|
-
@
|
|
591
|
+
@media(min-width: ${viewTablet + 1}px) {
|
|
583
592
|
.text-menu {
|
|
584
593
|
display: none;
|
|
585
594
|
}
|
|
@@ -607,20 +616,12 @@ function MenuToggle({ menuId, ...props }: PropsDiv & { menuId: number }) {
|
|
|
607
616
|
toggleMenuModal(menuId)
|
|
608
617
|
}}
|
|
609
618
|
onMouseEnter={() => {
|
|
610
|
-
|
|
611
|
-
if (isMobileNav()) return
|
|
612
|
-
openMenuModal(menuId)
|
|
619
|
+
openMenuModalOnMouseEnter(menuId)
|
|
613
620
|
}}
|
|
614
621
|
onMouseLeave={() => {
|
|
615
|
-
|
|
616
|
-
if (isMobileNav()) return
|
|
617
|
-
coseMenuModalOnMouseLeave(menuId)
|
|
618
|
-
}}
|
|
619
|
-
onTouchStart={() => {
|
|
620
|
-
onMouseIgnore = setTimeout(() => {
|
|
621
|
-
onMouseIgnore = undefined
|
|
622
|
-
}, 1000)
|
|
622
|
+
closeMenuModalOnMouseLeaveToggle(menuId)
|
|
623
623
|
}}
|
|
624
|
+
onTouchStart={ignoreHoverOnTouchStart}
|
|
624
625
|
>
|
|
625
626
|
<Style>{getAnimation()}</Style>
|
|
626
627
|
{props.children}
|
|
@@ -728,7 +729,3 @@ function MenuIcon() {
|
|
|
728
729
|
</svg>
|
|
729
730
|
)
|
|
730
731
|
}
|
|
731
|
-
|
|
732
|
-
function isMobileNav() {
|
|
733
|
-
return window.innerWidth <= viewTablet
|
|
734
|
-
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export { toggleMenuModal }
|
|
2
|
-
export { openMenuModal }
|
|
3
|
-
export { keepMenuModalOpen }
|
|
4
2
|
export { closeMenuModal }
|
|
5
|
-
|
|
3
|
+
// Hover handling
|
|
4
|
+
export { ignoreHoverOnTouchStart }
|
|
5
|
+
export { openMenuModalOnMouseEnter }
|
|
6
|
+
export { keepMenuModalOpenOnMouseOver }
|
|
7
|
+
export { closeMenuModalOnMouseLeave }
|
|
8
|
+
export { closeMenuModalOnMouseLeaveToggle }
|
|
6
9
|
|
|
7
10
|
import { viewTablet } from '../Layout'
|
|
8
11
|
import { getHydrationPromise } from '../renderer/getHydrationPromise'
|
|
@@ -11,9 +14,6 @@ import { isBrowser } from '../utils/isBrowser'
|
|
|
11
14
|
|
|
12
15
|
initScrollListener()
|
|
13
16
|
|
|
14
|
-
function keepMenuModalOpen() {
|
|
15
|
-
open()
|
|
16
|
-
}
|
|
17
17
|
function openMenuModal(menuNavigationId: number) {
|
|
18
18
|
open(menuNavigationId)
|
|
19
19
|
}
|
|
@@ -72,7 +72,8 @@ let toggleLock:
|
|
|
72
72
|
timeoutAction: NodeJS.Timeout
|
|
73
73
|
}
|
|
74
74
|
| undefined
|
|
75
|
-
function
|
|
75
|
+
function closeMenuModalOnMouseLeaveToggle(menuId: number) {
|
|
76
|
+
if (ignoreHover()) return
|
|
76
77
|
clearTimeout(toggleLock?.timeoutAction)
|
|
77
78
|
const timeoutAction = setTimeout(action, 100)
|
|
78
79
|
toggleLock = {
|
|
@@ -111,7 +112,7 @@ function toggleMenuModal(menuId: number) {
|
|
|
111
112
|
closeMenuModal()
|
|
112
113
|
} else {
|
|
113
114
|
openMenuModal(menuId)
|
|
114
|
-
if (
|
|
115
|
+
if (isMobileNav()) autoScroll()
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
|
|
@@ -137,3 +138,29 @@ function findCollapsibleEl(navLink: HTMLElement | undefined) {
|
|
|
137
138
|
}
|
|
138
139
|
return null
|
|
139
140
|
}
|
|
141
|
+
|
|
142
|
+
function closeMenuModalOnMouseLeave() {
|
|
143
|
+
if (ignoreHover()) return
|
|
144
|
+
closeMenuModal()
|
|
145
|
+
}
|
|
146
|
+
function keepMenuModalOpenOnMouseOver() {
|
|
147
|
+
if (ignoreHover()) return
|
|
148
|
+
open()
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
let isTouchStart: ReturnType<typeof setTimeout> | undefined
|
|
152
|
+
function ignoreHoverOnTouchStart() {
|
|
153
|
+
isTouchStart = setTimeout(() => {
|
|
154
|
+
isTouchStart = undefined
|
|
155
|
+
}, 1000)
|
|
156
|
+
}
|
|
157
|
+
function openMenuModalOnMouseEnter(menuId: number) {
|
|
158
|
+
if (ignoreHover()) return
|
|
159
|
+
openMenuModal(menuId)
|
|
160
|
+
}
|
|
161
|
+
function ignoreHover() {
|
|
162
|
+
return isTouchStart || isMobileNav()
|
|
163
|
+
}
|
|
164
|
+
function isMobileNav() {
|
|
165
|
+
return getViewportWidth() <= viewTablet
|
|
166
|
+
}
|
package/MenuModal.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { viewDesktop, viewTablet } from './Layout'
|
|
|
7
7
|
import { ExternalLinks } from './ExternalLinks'
|
|
8
8
|
import { Style } from './utils/Style'
|
|
9
9
|
import { NavigationWithColumnLayout } from './MenuModal/NavigationWithColumnLayout'
|
|
10
|
-
import { closeMenuModal,
|
|
10
|
+
import { closeMenuModal, closeMenuModalOnMouseLeave, keepMenuModalOpenOnMouseOver } from './MenuModal/toggleMenuModal'
|
|
11
11
|
import { EditLink } from './EditLink'
|
|
12
12
|
|
|
13
13
|
function MenuModal({ isTopNav }: { isTopNav: boolean }) {
|
|
@@ -27,8 +27,8 @@ function MenuModal({ isTopNav }: { isTopNav: boolean }) {
|
|
|
27
27
|
transitionProperty: 'opacity',
|
|
28
28
|
transitionTimingFunction: 'ease',
|
|
29
29
|
}}
|
|
30
|
-
onMouseOver={
|
|
31
|
-
onMouseLeave={
|
|
30
|
+
onMouseOver={keepMenuModalOpenOnMouseOver}
|
|
31
|
+
onMouseLeave={closeMenuModalOnMouseLeave}
|
|
32
32
|
>
|
|
33
33
|
<div
|
|
34
34
|
id="menu-modal-scroll-container"
|
package/css/tooltip.css
CHANGED
|
@@ -37,9 +37,10 @@
|
|
|
37
37
|
top: 100%;
|
|
38
38
|
margin-top: 5px;
|
|
39
39
|
}
|
|
40
|
-
/* Show above */
|
|
41
|
-
[aria-label][data-label-position='top']::before {
|
|
40
|
+
/* Show above-left */
|
|
41
|
+
[aria-label][data-label-position='top-left']::before {
|
|
42
42
|
bottom: 100%;
|
|
43
43
|
margin-bottom: 7px;
|
|
44
|
+
transform: translate(calc(-100% + 25px), 0);
|
|
44
45
|
}
|
|
45
46
|
}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export function getViewportWidth(): number {
|
|
2
|
-
//
|
|
3
|
-
return document.documentElement.
|
|
2
|
+
// Width without scrollbar
|
|
3
|
+
return document.documentElement.scrollWidth
|
|
4
4
|
}
|