@brillout/docpress 0.8.13 → 0.8.15
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 +279 -171
- package/MenuModal.tsx +55 -56
- package/{Links.tsx → NavSecondaryContent.tsx} +6 -8
- package/components/HorizontalLine.tsx +4 -3
- package/config/resolveHeadingsData.ts +7 -10
- package/css/code/block.css +5 -5
- package/css/code/inline.css +1 -1
- package/css/colorize-on-hover.css +20 -9
- package/dist/Layout.d.ts +10 -6
- package/dist/Layout.js +181 -102
- package/dist/MenuModal.d.ts +5 -1
- package/dist/MenuModal.js +44 -60
- package/dist/{Links.d.ts → NavSecondaryContent.d.ts} +3 -2
- package/dist/{Links.js → NavSecondaryContent.js} +5 -6
- package/dist/components/HorizontalLine.d.ts +1 -1
- package/dist/components/HorizontalLine.js +3 -2
- package/dist/config/resolveHeadingsData.d.ts +3 -4
- package/dist/config/resolveHeadingsData.js +5 -8
- package/dist/config/resolvePageContext.d.ts +2 -3
- package/dist/docsearch/SearchLink.js +2 -3
- package/dist/navigation/Collapsible.d.ts +10 -0
- package/dist/navigation/Collapsible.js +35 -0
- package/dist/navigation/Navigation.d.ts +0 -3
- package/dist/navigation/Navigation.js +106 -55
- package/dist/renderer/determineNavItemsColumnLayout.d.ts +3 -0
- package/dist/renderer/{determineColumnEntries.js → determineNavItemsColumnLayout.js} +34 -28
- package/dist/renderer/usePageContext.d.ts +2 -2
- package/dist/renderer/usePageContext.js +2 -4
- package/dist/utils/Style.d.ts +5 -0
- package/dist/utils/Style.js +6 -0
- package/dist/utils/cls.d.ts +3 -0
- package/dist/utils/cls.js +5 -0
- package/dist/utils/throttle.d.ts +1 -0
- package/dist/utils/throttle.js +14 -0
- package/docsearch/SearchLink.tsx +4 -13
- package/global.d.ts +1 -1
- package/initKeyBindings.ts +1 -6
- package/navigation/Collapsible.css +11 -0
- package/navigation/Collapsible.tsx +64 -0
- package/navigation/Navigation.css +12 -6
- package/navigation/Navigation.tsx +191 -80
- package/package.json +1 -1
- package/renderer/{determineColumnEntries.ts → determineNavItemsColumnLayout.ts} +35 -29
- package/renderer/initOnNavigation.ts +37 -0
- package/renderer/onRenderClient.tsx +2 -0
- package/renderer/usePageContext.tsx +2 -5
- package/utils/Style.tsx +7 -0
- package/utils/cls.ts +8 -0
- package/utils/throttle.ts +10 -0
- package/dist/renderer/determineColumnEntries.d.ts +0 -3
package/MenuModal.tsx
CHANGED
|
@@ -1,58 +1,53 @@
|
|
|
1
1
|
export { MenuModal }
|
|
2
2
|
export { toggleMenuModal }
|
|
3
|
+
export { openMenuModal }
|
|
3
4
|
export { closeMenuModal }
|
|
4
5
|
|
|
5
6
|
import React from 'react'
|
|
6
7
|
import { usePageContext } from './renderer/usePageContext'
|
|
7
8
|
import { NavigationContent } from './navigation/Navigation'
|
|
8
9
|
import { css } from './utils/css'
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { isBrowser } from './utils/isBrowser'
|
|
10
|
+
import { containerQueryMobileLayout, containerQueryMobileMenu } from './Layout'
|
|
11
|
+
import { NavSecondaryContent } from './NavSecondaryContent'
|
|
12
12
|
import { getViewportWidth } from './utils/getViewportWidth'
|
|
13
|
+
import { Style } from './utils/Style'
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function MenuModal() {
|
|
15
|
+
function MenuModal({ isTopNav }: { isTopNav: boolean }) {
|
|
17
16
|
return (
|
|
18
17
|
<>
|
|
19
|
-
<
|
|
18
|
+
<Style>{getStyle()}</Style>
|
|
20
19
|
<div
|
|
21
20
|
id="menu-modal"
|
|
22
|
-
className="link-hover-animation"
|
|
21
|
+
className="link-hover-animation add-transition"
|
|
23
22
|
style={{
|
|
24
|
-
position: 'fixed',
|
|
23
|
+
position: isTopNav ? 'absolute' : 'fixed',
|
|
25
24
|
width: '100%',
|
|
26
|
-
|
|
27
|
-
|
|
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,
|
|
25
|
+
height: 'calc(100vh - var(--nav-head-height))',
|
|
26
|
+
top: 'var(--nav-head-height)',
|
|
35
27
|
left: 0,
|
|
36
28
|
zIndex: 9999,
|
|
37
29
|
overflow: 'scroll',
|
|
38
|
-
background: '#
|
|
30
|
+
background: '#ededef',
|
|
31
|
+
transitionProperty: 'opacity',
|
|
39
32
|
}}
|
|
33
|
+
onMouseOver={openMenuModal}
|
|
34
|
+
onMouseLeave={closeMenuModal}
|
|
40
35
|
>
|
|
41
36
|
<div
|
|
42
37
|
style={{
|
|
43
38
|
// Place <LinksBottom /> to the bottom
|
|
44
39
|
display: 'flex',
|
|
45
40
|
flexDirection: 'column',
|
|
46
|
-
minHeight: '
|
|
41
|
+
minHeight: 'calc(100vh - var(--nav-head-height))',
|
|
47
42
|
justifyContent: 'space-between',
|
|
48
43
|
// We don't set `container` to parent beacuse of a Chrome bug (showing a blank <MenuModal>)
|
|
49
|
-
|
|
44
|
+
container: 'container-viewport / inline-size',
|
|
50
45
|
}}
|
|
51
46
|
>
|
|
52
47
|
<Nav />
|
|
53
|
-
<
|
|
48
|
+
<NavSecondary className="show-only-for-mobile" />
|
|
54
49
|
</div>
|
|
55
|
-
<CloseButton />
|
|
50
|
+
<CloseButton className="show-only-for-mobile" />
|
|
56
51
|
</div>
|
|
57
52
|
</>
|
|
58
53
|
)
|
|
@@ -62,15 +57,17 @@ function Nav() {
|
|
|
62
57
|
const navItems = pageContext.navItemsAll
|
|
63
58
|
return <NavigationContent columnLayout={true} navItems={navItems} />
|
|
64
59
|
}
|
|
65
|
-
function
|
|
60
|
+
function NavSecondary({ className }: { className: string }) {
|
|
66
61
|
return (
|
|
67
62
|
<div
|
|
63
|
+
className={className}
|
|
68
64
|
style={{
|
|
69
65
|
display: 'flex',
|
|
70
66
|
justifyContent: 'center',
|
|
67
|
+
marginTop: 20,
|
|
71
68
|
}}
|
|
72
69
|
>
|
|
73
|
-
<
|
|
70
|
+
<NavSecondaryContent style={{ height: 70 }} />
|
|
74
71
|
</div>
|
|
75
72
|
)
|
|
76
73
|
}
|
|
@@ -78,23 +75,35 @@ function LinksBottom() {
|
|
|
78
75
|
function getStyle() {
|
|
79
76
|
return css`
|
|
80
77
|
html:not(.menu-modal-show) #menu-modal {
|
|
81
|
-
|
|
78
|
+
opacity: 0;
|
|
79
|
+
pointer-events: none;
|
|
82
80
|
}
|
|
83
81
|
// disable scroll of main view
|
|
84
82
|
html.menu-modal-show {
|
|
85
83
|
overflow: hidden !important;
|
|
86
84
|
}
|
|
87
|
-
@container(min-width: ${
|
|
85
|
+
@container container-viewport (min-width: ${containerQueryMobileLayout}px) {
|
|
88
86
|
#menu-modal .nav-item-level-3 {
|
|
89
87
|
display: none;
|
|
90
88
|
}
|
|
91
89
|
}
|
|
90
|
+
@media(max-width: ${containerQueryMobileMenu}px) {
|
|
91
|
+
#menu-modal {
|
|
92
|
+
--nav-head-height: 0px !important;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
@media(min-width: ${containerQueryMobileMenu + 1}px) {
|
|
96
|
+
.show-only-for-mobile {
|
|
97
|
+
display: none !important;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
92
100
|
`
|
|
93
101
|
}
|
|
94
102
|
|
|
95
|
-
function CloseButton() {
|
|
103
|
+
function CloseButton({ className }: { className: string }) {
|
|
96
104
|
return (
|
|
97
105
|
<div
|
|
106
|
+
className={className}
|
|
98
107
|
onClick={toggleMenuModal}
|
|
99
108
|
style={{ position: 'fixed', top: 0, right: 0, zIndex: 10, padding: 11, cursor: 'pointer' }}
|
|
100
109
|
aria-label={'Escape\nCtrl\xa0+\xa0M'}
|
|
@@ -126,7 +135,10 @@ function CloseButton() {
|
|
|
126
135
|
|
|
127
136
|
function toggleMenuModal() {
|
|
128
137
|
document.documentElement.classList.toggle('menu-modal-show')
|
|
129
|
-
if (
|
|
138
|
+
if (
|
|
139
|
+
document.documentElement.classList.contains('menu-modal-show') &&
|
|
140
|
+
getViewportWidth() < containerQueryMobileLayout
|
|
141
|
+
) {
|
|
130
142
|
autoScroll()
|
|
131
143
|
}
|
|
132
144
|
}
|
|
@@ -134,40 +146,27 @@ function autoScroll() {
|
|
|
134
146
|
const nav = document.querySelector('#menu-modal .navigation-content')!
|
|
135
147
|
const href = window.location.pathname
|
|
136
148
|
const navLinks = Array.from(nav.querySelectorAll(`a[href="${href}"]`))
|
|
137
|
-
const navLink = navLinks[0]
|
|
149
|
+
const navLink = navLinks[0] as HTMLElement | undefined
|
|
138
150
|
if (!navLink) return
|
|
151
|
+
// None of the following seemes to be working: https://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom
|
|
152
|
+
if (findCollapsibleEl(navLink)!.classList.contains('collapsible-collapsed')) return
|
|
139
153
|
navLink.scrollIntoView({
|
|
140
154
|
behavior: 'instant',
|
|
141
155
|
block: 'center',
|
|
142
156
|
inline: 'start',
|
|
143
157
|
})
|
|
144
158
|
}
|
|
145
|
-
function
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
// It's redundant (and onLinkClick() is enough), but just to be sure.
|
|
153
|
-
addEventListener('hashchange', closeMenuModal)
|
|
159
|
+
function findCollapsibleEl(navLink: HTMLElement | undefined) {
|
|
160
|
+
let parentEl: HTMLElement | null | undefined = navLink
|
|
161
|
+
while (parentEl) {
|
|
162
|
+
if (parentEl.classList.contains('collapsible')) return parentEl
|
|
163
|
+
parentEl = parentEl.parentElement
|
|
164
|
+
}
|
|
165
|
+
return null
|
|
154
166
|
}
|
|
155
|
-
function
|
|
156
|
-
|
|
157
|
-
const linkTag = findLinkTag(ev.target as HTMLElement)
|
|
158
|
-
if (!linkTag) return
|
|
159
|
-
const href = linkTag.getAttribute('href')
|
|
160
|
-
if (!href) return
|
|
161
|
-
if (!href.startsWith('/') && !href.startsWith('#')) return
|
|
162
|
-
closeMenuModal()
|
|
167
|
+
function openMenuModal() {
|
|
168
|
+
document.documentElement.classList.add('menu-modal-show')
|
|
163
169
|
}
|
|
164
|
-
function
|
|
165
|
-
|
|
166
|
-
const { parentNode } = target
|
|
167
|
-
if (!parentNode) {
|
|
168
|
-
return null
|
|
169
|
-
}
|
|
170
|
-
target = parentNode as HTMLElement
|
|
171
|
-
}
|
|
172
|
-
return target
|
|
170
|
+
function closeMenuModal() {
|
|
171
|
+
document.documentElement.classList.remove('menu-modal-show')
|
|
173
172
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { NavSecondaryContent }
|
|
2
|
+
|
|
1
3
|
import React from 'react'
|
|
2
4
|
import iconGithub from './icons/github.svg'
|
|
3
5
|
import iconTwitter from './icons/twitter.svg'
|
|
@@ -7,9 +9,7 @@ import iconLanguages from './icons/languages.svg'
|
|
|
7
9
|
import { usePageContext } from './renderer/usePageContext'
|
|
8
10
|
import '@docsearch/css'
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function Links({ style }: { style?: React.CSSProperties }) {
|
|
12
|
+
function NavSecondaryContent(props: { style?: React.CSSProperties; className?: string }) {
|
|
13
13
|
const pageContext = usePageContext()
|
|
14
14
|
const { projectInfo, i18n } = pageContext.config
|
|
15
15
|
const iconI18n = !i18n ? null : (
|
|
@@ -22,13 +22,11 @@ function Links({ style }: { style?: React.CSSProperties }) {
|
|
|
22
22
|
)
|
|
23
23
|
return (
|
|
24
24
|
<div
|
|
25
|
+
{...props}
|
|
25
26
|
style={{
|
|
26
27
|
display: 'flex',
|
|
27
28
|
alignItems: 'center',
|
|
28
|
-
|
|
29
|
-
justifyContent: 'left',
|
|
30
|
-
height: '100%',
|
|
31
|
-
...style,
|
|
29
|
+
...props.style,
|
|
32
30
|
}}
|
|
33
31
|
>
|
|
34
32
|
{iconI18n}
|
|
@@ -52,7 +50,7 @@ function ChangelogButton() {
|
|
|
52
50
|
style={{
|
|
53
51
|
display: 'flex',
|
|
54
52
|
alignItems: 'center',
|
|
55
|
-
padding:
|
|
53
|
+
padding: '0 5px',
|
|
56
54
|
height: '100%',
|
|
57
55
|
}}
|
|
58
56
|
>
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
1
|
export { HorizontalLine }
|
|
4
2
|
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { cls } from '../utils/cls'
|
|
5
|
+
|
|
5
6
|
function HorizontalLine({ primary }: { primary?: true }) {
|
|
6
7
|
return (
|
|
7
|
-
<div className={
|
|
8
|
+
<div className={cls(primary && 'primary')} style={{ textAlign: 'center' }}>
|
|
8
9
|
<hr
|
|
9
10
|
style={{
|
|
10
11
|
display: 'inline-block',
|
|
@@ -9,12 +9,12 @@ import type {
|
|
|
9
9
|
} from '../types/Heading'
|
|
10
10
|
import type { Config } from '../types/Config'
|
|
11
11
|
import { getConfig } from './getConfig'
|
|
12
|
-
import type { NavItem
|
|
12
|
+
import type { NavItem } from '../navigation/Navigation'
|
|
13
13
|
import type { LinkData } from '../components'
|
|
14
14
|
import type { Exports, PageContextOriginal } from './resolvePageContext'
|
|
15
15
|
import pc from '@brillout/picocolors'
|
|
16
16
|
import { parseTitle } from '../parseTitle'
|
|
17
|
-
import {
|
|
17
|
+
import { determineNavItemsColumnLayout } from '../renderer/determineNavItemsColumnLayout'
|
|
18
18
|
assert(!isBrowser())
|
|
19
19
|
|
|
20
20
|
type PageSectionResolved = {
|
|
@@ -53,19 +53,17 @@ function resolveHeadingsData(pageContext: PageContextOriginal) {
|
|
|
53
53
|
...headingsDetachedResolved.map(headingToLinkData),
|
|
54
54
|
]
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
let
|
|
58
|
-
let navItemsAll: NavItemAll[]
|
|
56
|
+
let navItemsAll: NavItem[]
|
|
57
|
+
let navItemsDetached: NavItem[] | undefined
|
|
59
58
|
{
|
|
60
59
|
const navItemsPageSections = pageSectionsResolved
|
|
61
60
|
.filter((pageSection) => pageSection.pageSectionLevel === 2)
|
|
62
61
|
.map(pageSectionToNavItem)
|
|
63
62
|
navItemsAll = headingsResolved.map(headingToNavItem)
|
|
64
|
-
|
|
63
|
+
determineNavItemsColumnLayout(navItemsAll)
|
|
65
64
|
if (isDetachedPage) {
|
|
66
|
-
|
|
65
|
+
navItemsDetached = [headingToNavItem(activeHeading), ...navItemsPageSections]
|
|
67
66
|
} else {
|
|
68
|
-
navItems = navItemsAll
|
|
69
67
|
const activeHeadingIndex = navItemsAll.findIndex((navItem) => navItem.url === pageContext.urlPathname)
|
|
70
68
|
assert(activeHeadingIndex >= 0)
|
|
71
69
|
navItemsPageSections.forEach((navItem, i) => {
|
|
@@ -75,9 +73,8 @@ function resolveHeadingsData(pageContext: PageContextOriginal) {
|
|
|
75
73
|
}
|
|
76
74
|
|
|
77
75
|
const pageContextAddendum = {
|
|
78
|
-
isDetachedPage,
|
|
79
|
-
navItems,
|
|
80
76
|
navItemsAll,
|
|
77
|
+
navItemsDetached,
|
|
81
78
|
linksAll,
|
|
82
79
|
isLandingPage,
|
|
83
80
|
pageTitle,
|
package/css/code/block.css
CHANGED
|
@@ -22,27 +22,27 @@ figure[data-rehype-pretty-code-figure] {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/* 821px screen width => the width of code blocks isn't shrinked anymore => no need to reduce the font-size of code blocks */
|
|
25
|
-
@container(max-width: 820px) {
|
|
25
|
+
@container container-viewport (max-width: 820px) {
|
|
26
26
|
pre > code {
|
|
27
27
|
font-size: 0.9em !important;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
@container(max-width: 720px) {
|
|
30
|
+
@container container-viewport (max-width: 720px) {
|
|
31
31
|
pre > code {
|
|
32
32
|
font-size: 0.8em !important;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
@container(max-width: 620px) {
|
|
35
|
+
@container container-viewport (max-width: 620px) {
|
|
36
36
|
pre > code {
|
|
37
37
|
font-size: 0.7em !important;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
@container(max-width: 550px) {
|
|
40
|
+
@container container-viewport (max-width: 550px) {
|
|
41
41
|
pre > code {
|
|
42
42
|
font-size: 0.6em !important;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
@container(max-width: 450px) {
|
|
45
|
+
@container container-viewport (max-width: 450px) {
|
|
46
46
|
pre > code {
|
|
47
47
|
font-size: 0.5em !important;
|
|
48
48
|
}
|
package/css/code/inline.css
CHANGED
|
@@ -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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
[class^='decolorize-'],
|
|
21
|
+
[class*=' decolorize-'],
|
|
22
|
+
.link-hover-animation a,
|
|
23
|
+
.link-hover-animation .menu-toggle,
|
|
24
|
+
.add-transition {
|
|
25
|
+
transition: none 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 !important;
|
|
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.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
export { Layout };
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
2
|
+
export { containerQueryMobileLayout };
|
|
3
|
+
export { containerQueryMobileMenu };
|
|
4
|
+
export { navLeftWidthMin };
|
|
5
|
+
export { navLeftWidthMax };
|
|
6
|
+
export { unexpandNav };
|
|
5
7
|
import React from 'react';
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
8
|
-
declare const
|
|
8
|
+
declare const navLeftWidthMax = 370;
|
|
9
|
+
declare const navLeftWidthMin = 300;
|
|
10
|
+
declare const containerQueryMobileMenu = 1000;
|
|
11
|
+
declare const containerQueryMobileLayout: number;
|
|
9
12
|
declare function Layout({ children }: {
|
|
10
13
|
children: React.ReactNode;
|
|
11
14
|
}): React.JSX.Element;
|
|
15
|
+
declare function unexpandNav(): void;
|