@brillout/docpress 0.8.11 → 0.8.12
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 +2 -0
- package/MenuModal.tsx +1 -4
- package/config/resolveHeadingsData.ts +2 -6
- package/dist/Layout.d.ts +11 -0
- package/dist/Layout.js +235 -0
- package/dist/Links.d.ts +6 -0
- package/dist/Links.js +58 -0
- package/dist/MenuModal.d.ts +7 -0
- package/dist/MenuModal.js +123 -0
- package/dist/autoScrollNav.d.ts +3 -0
- package/dist/autoScrollNav.js +35 -0
- package/dist/components/EditPageNote.d.ts +7 -0
- package/dist/components/EditPageNote.js +11 -0
- package/dist/config/resolveHeadingsData.d.ts +0 -1
- package/dist/config/resolveHeadingsData.js +2 -6
- package/dist/config/resolvePageContext.d.ts +0 -1
- package/dist/docsearch/SearchLink.d.ts +4 -0
- package/dist/docsearch/SearchLink.js +26 -0
- package/dist/docsearch/toggleDocsearchModal.d.ts +4 -0
- package/dist/docsearch/toggleDocsearchModal.js +26 -0
- package/dist/navigation/Navigation.d.ts +2 -1
- package/dist/navigation/Navigation.js +67 -38
- package/dist/renderer/determineColumnEntries.d.ts +3 -0
- package/dist/renderer/{getStyleColumnLayout.js → determineColumnEntries.js} +16 -64
- package/dist/utils/PassTrough.d.ts +3 -0
- package/dist/utils/PassTrough.js +6 -0
- package/dist/utils/getViewportWidth.d.ts +1 -0
- package/dist/utils/getViewportWidth.js +4 -0
- package/navigation/Navigation.css +2 -1
- package/navigation/Navigation.tsx +92 -63
- package/package.json +1 -1
- package/renderer/{getStyleColumnLayout.ts → determineColumnEntries.ts} +20 -90
- package/renderer/onRenderHtml.tsx +0 -4
- package/utils/getViewportWidth.ts +4 -0
- package/dist/renderer/getStyleColumnLayout.d.ts +0 -7
package/Layout.tsx
CHANGED
package/MenuModal.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import { css } from './utils/css'
|
|
|
9
9
|
import { containerQueryMobile } from './Layout'
|
|
10
10
|
import { Links } from './Links'
|
|
11
11
|
import { isBrowser } from './utils/isBrowser'
|
|
12
|
+
import { getViewportWidth } from './utils/getViewportWidth'
|
|
12
13
|
|
|
13
14
|
initCloseListeners()
|
|
14
15
|
|
|
@@ -129,10 +130,6 @@ function toggleMenuModal() {
|
|
|
129
130
|
autoScroll()
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
|
-
function getViewportWidth(): number {
|
|
133
|
-
// `window.innerWidth` inlcudes scrollbar width: https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
|
|
134
|
-
return document.documentElement.clientWidth
|
|
135
|
-
}
|
|
136
133
|
function autoScroll() {
|
|
137
134
|
const nav = document.querySelector('#menu-modal .navigation-content')!
|
|
138
135
|
const href = window.location.pathname
|
|
@@ -14,7 +14,7 @@ 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 { determineColumnEntries } from '../renderer/determineColumnEntries'
|
|
18
18
|
assert(!isBrowser())
|
|
19
19
|
|
|
20
20
|
type PageSectionResolved = {
|
|
@@ -56,14 +56,12 @@ function resolveHeadingsData(pageContext: PageContextOriginal) {
|
|
|
56
56
|
// TODO/refactor: remove navItems
|
|
57
57
|
let navItems: NavItem[]
|
|
58
58
|
let navItemsAll: NavItemAll[]
|
|
59
|
-
let columnLayouts: number[][]
|
|
60
59
|
{
|
|
61
60
|
const navItemsPageSections = pageSectionsResolved
|
|
62
61
|
.filter((pageSection) => pageSection.pageSectionLevel === 2)
|
|
63
62
|
.map(pageSectionToNavItem)
|
|
64
63
|
navItemsAll = headingsResolved.map(headingToNavItem)
|
|
65
|
-
|
|
66
|
-
columnLayouts = res.columnLayouts
|
|
64
|
+
determineColumnEntries(navItemsAll)
|
|
67
65
|
if (isDetachedPage) {
|
|
68
66
|
navItems = [headingToNavItem(activeHeading), ...navItemsPageSections]
|
|
69
67
|
} else {
|
|
@@ -85,8 +83,6 @@ function resolveHeadingsData(pageContext: PageContextOriginal) {
|
|
|
85
83
|
pageTitle,
|
|
86
84
|
documentTitle,
|
|
87
85
|
// TODO: don't pass to client-side
|
|
88
|
-
columnLayouts,
|
|
89
|
-
// TODO: don't pass to client-side
|
|
90
86
|
activeCategory,
|
|
91
87
|
}
|
|
92
88
|
return pageContextAddendum
|
package/dist/Layout.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { Layout };
|
|
2
|
+
export { containerQueryMobile };
|
|
3
|
+
export { navWidthMin };
|
|
4
|
+
export { navWidthMax };
|
|
5
|
+
import React from 'react';
|
|
6
|
+
declare const navWidthMax = 370;
|
|
7
|
+
declare const navWidthMin = 300;
|
|
8
|
+
declare const containerQueryMobile: number;
|
|
9
|
+
declare function Layout({ children }: {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}): React.JSX.Element;
|
package/dist/Layout.js
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
export { Layout };
|
|
17
|
+
export { containerQueryMobile };
|
|
18
|
+
export { navWidthMin };
|
|
19
|
+
export { navWidthMax };
|
|
20
|
+
import React from 'react';
|
|
21
|
+
import { NavigationContent } from './navigation/Navigation';
|
|
22
|
+
import { EditPageNote } from './components/EditPageNote';
|
|
23
|
+
import { parseTitle } from './parseTitle';
|
|
24
|
+
import { usePageContext, usePageContext2 } from './renderer/usePageContext';
|
|
25
|
+
import { Links } from './Links';
|
|
26
|
+
import { toggleMenuModal } from './MenuModal';
|
|
27
|
+
import { MenuModal } from './MenuModal';
|
|
28
|
+
import { autoScrollNav_SSR } from './autoScrollNav';
|
|
29
|
+
import { SearchLink } from './docsearch/SearchLink';
|
|
30
|
+
import { navigate } from 'vike/client/router';
|
|
31
|
+
import { css } from './utils/css';
|
|
32
|
+
import { PassThrough } from './utils/PassTrough';
|
|
33
|
+
var mainViewWidthMax = 800;
|
|
34
|
+
var mainViewPadding = 20;
|
|
35
|
+
var navWidthMax = 370;
|
|
36
|
+
var navWidthMin = 300;
|
|
37
|
+
var navWidth = {
|
|
38
|
+
minWidth: navWidthMin,
|
|
39
|
+
maxWidth: navWidthMax,
|
|
40
|
+
width: '100%',
|
|
41
|
+
};
|
|
42
|
+
var blockMargin = 3;
|
|
43
|
+
var mainViewMax = mainViewWidthMax + mainViewPadding * 2;
|
|
44
|
+
var containerQuerySpacing = mainViewMax + navWidthMax + blockMargin;
|
|
45
|
+
var containerQueryMobile = mainViewMax + navWidthMin;
|
|
46
|
+
// Avoid whitespace at the bottom of pages with almost no content
|
|
47
|
+
var whitespaceBuster1 = {
|
|
48
|
+
minHeight: '100vh',
|
|
49
|
+
display: 'flex',
|
|
50
|
+
flexDirection: 'column',
|
|
51
|
+
};
|
|
52
|
+
var whitespaceBuster2 = {
|
|
53
|
+
flexGrow: 1,
|
|
54
|
+
};
|
|
55
|
+
function Layout(_a) {
|
|
56
|
+
var _b;
|
|
57
|
+
var children = _a.children;
|
|
58
|
+
var pageContext = usePageContext();
|
|
59
|
+
var isLandingPage = pageContext.isLandingPage;
|
|
60
|
+
var content;
|
|
61
|
+
if (isLandingPage) {
|
|
62
|
+
content = React.createElement(LayoutLandingPage, null, children);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
content = React.createElement(LayoutDocsPage, null, children);
|
|
66
|
+
}
|
|
67
|
+
return (React.createElement("div", { style: (_b = {},
|
|
68
|
+
_b['--bg-color'] = '#f5f5f7',
|
|
69
|
+
_b['--block-margin'] = "".concat(blockMargin, "px"),
|
|
70
|
+
_b['--icon-text-padding'] = '8px',
|
|
71
|
+
_b) },
|
|
72
|
+
React.createElement(MenuModal, null),
|
|
73
|
+
React.createElement("div", { className: isLandingPage ? '' : 'doc-page', style: __assign({
|
|
74
|
+
// We don't add `container` to `body` nor `html` beacuse in Firefox it breaks the `position: fixed` of <MenuModal>
|
|
75
|
+
// https://stackoverflow.com/questions/74601420/css-container-inline-size-and-fixed-child
|
|
76
|
+
containerType: 'inline-size' }, whitespaceBuster1) }, content)));
|
|
77
|
+
}
|
|
78
|
+
function LayoutDocsPage(_a) {
|
|
79
|
+
var children = _a.children;
|
|
80
|
+
var pageContext = usePageContext();
|
|
81
|
+
var hideNavLeftAlways = pageContext.navItems.length <= 1;
|
|
82
|
+
return (React.createElement(React.Fragment, null,
|
|
83
|
+
React.createElement("style", null, getStyle()),
|
|
84
|
+
React.createElement(NavMobile, null),
|
|
85
|
+
React.createElement("div", { style: __assign({ display: 'flex' }, whitespaceBuster2) },
|
|
86
|
+
React.createElement(NavLeft, null),
|
|
87
|
+
React.createElement("div", { className: "low-prio-grow", style: { width: 0, maxWidth: 50, background: 'var(--bg-color)' } }),
|
|
88
|
+
React.createElement(PageContent, null, children))));
|
|
89
|
+
function getStyle() {
|
|
90
|
+
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
|
+
if (!hideNavLeftAlways) {
|
|
93
|
+
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
|
+
style += navLeftHide;
|
|
96
|
+
return style;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function LayoutLandingPage(_a) {
|
|
100
|
+
var children = _a.children;
|
|
101
|
+
var mobile = 800;
|
|
102
|
+
return (React.createElement(React.Fragment, null,
|
|
103
|
+
React.createElement("style", null, getStyle()),
|
|
104
|
+
React.createElement(NavTop, null),
|
|
105
|
+
React.createElement(NavMobile, null),
|
|
106
|
+
React.createElement(PageContent, null, children)));
|
|
107
|
+
function getStyle() {
|
|
108
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n@container(min-width: ", "px) {\n #nav-mobile {\n display: none !important;\n }\n}\n@container(max-width: ", "px) {\n #top-navigation {\n display: none !important;\n }\n"], ["\n@container(min-width: ", "px) {\n #nav-mobile {\n display: none !important;\n }\n}\n@container(max-width: ", "px) {\n #top-navigation {\n display: none !important;\n }\n"])), mobile, mobile - 1);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function PageContent(_a) {
|
|
112
|
+
var _b;
|
|
113
|
+
var children = _a.children;
|
|
114
|
+
var pageContext = usePageContext();
|
|
115
|
+
var isLandingPage = pageContext.isLandingPage, pageTitle = pageContext.pageTitle;
|
|
116
|
+
var pageTitleParsed = pageTitle && parseTitle(pageTitle);
|
|
117
|
+
var globalNote = pageContext.config.globalNote;
|
|
118
|
+
var ifDocPage = function (style) { return (isLandingPage ? {} : style); };
|
|
119
|
+
return (React.createElement("div", { className: "page-wrapper low-prio-grow", style: __assign({
|
|
120
|
+
// Avoid overflow, see https://stackoverflow.com/questions/36230944/prevent-flex-items-from-overflowing-a-container/66689926#66689926
|
|
121
|
+
minWidth: 0 }, ifDocPage({
|
|
122
|
+
backgroundColor: 'var(--bg-color)',
|
|
123
|
+
paddingBottom: 50,
|
|
124
|
+
})) },
|
|
125
|
+
React.createElement("div", { className: "page-content", style: __assign((_b = {}, _b['--main-view-padding'] = "".concat(mainViewPadding, "px"), _b), ifDocPage({
|
|
126
|
+
width: "calc(".concat(mainViewWidthMax, "px + 2 * var(--main-view-padding))"),
|
|
127
|
+
maxWidth: '100%',
|
|
128
|
+
padding: '20px var(--main-view-padding)',
|
|
129
|
+
})) },
|
|
130
|
+
globalNote,
|
|
131
|
+
pageTitleParsed && React.createElement("h1", { id: "".concat(pageContext.urlPathname.replace('/', '')) }, pageTitleParsed),
|
|
132
|
+
children,
|
|
133
|
+
!isLandingPage && React.createElement(EditPageNote, { pageContext: pageContext }))));
|
|
134
|
+
}
|
|
135
|
+
function NavMobile() {
|
|
136
|
+
return (React.createElement("div", { id: "nav-mobile" },
|
|
137
|
+
React.createElement(NavigationHeader, { headerHeight: 70, iconSize: 40, paddingLeft: 12, style: { justifyContent: 'center' } })));
|
|
138
|
+
}
|
|
139
|
+
function NavTop() {
|
|
140
|
+
var _a;
|
|
141
|
+
var pageContext2 = usePageContext2();
|
|
142
|
+
var paddingSize = 35;
|
|
143
|
+
var padding = "0 ".concat(paddingSize, "px");
|
|
144
|
+
var TopNavigation = pageContext2.config.TopNavigation || PassThrough;
|
|
145
|
+
return (React.createElement("div", { id: "top-navigation", className: "link-hover-animation", style: (_a = {
|
|
146
|
+
position: 'relative',
|
|
147
|
+
display: 'flex',
|
|
148
|
+
alignItems: 'center',
|
|
149
|
+
justifyContent: 'center',
|
|
150
|
+
textDecoration: 'none',
|
|
151
|
+
marginBottom: 'var(--block-margin)',
|
|
152
|
+
backgroundColor: 'var(--bg-color)'
|
|
153
|
+
},
|
|
154
|
+
_a['--padding-side'] = "".concat(paddingSize, "px"),
|
|
155
|
+
_a.fontSize = '1.06em',
|
|
156
|
+
_a.color = '#666',
|
|
157
|
+
_a) },
|
|
158
|
+
React.createElement("div", { style: { display: 'flex', alignItems: 'center', height: 70 } },
|
|
159
|
+
React.createElement(TopNavigation, null),
|
|
160
|
+
React.createElement(SearchLink, { style: { padding: padding } }),
|
|
161
|
+
React.createElement(MenuLink, { style: { padding: padding } }),
|
|
162
|
+
React.createElement(Links, { style: { display: 'inline-flex', padding: padding, marginLeft: -8 } }))));
|
|
163
|
+
}
|
|
164
|
+
function NavLeft() {
|
|
165
|
+
var pageContext = usePageContext();
|
|
166
|
+
var navItems = pageContext.navItems, navItemsAll = pageContext.navItemsAll, isDetachedPage = pageContext.isDetachedPage;
|
|
167
|
+
var headerHeight = 60;
|
|
168
|
+
return (React.createElement(React.Fragment, null,
|
|
169
|
+
React.createElement("div", { id: "nav-left", className: "link-hover-animation", style: {
|
|
170
|
+
flexGrow: 1,
|
|
171
|
+
borderRight: 'var(--block-margin) solid white',
|
|
172
|
+
} },
|
|
173
|
+
React.createElement("div", { style: {
|
|
174
|
+
position: 'sticky',
|
|
175
|
+
top: 0,
|
|
176
|
+
} },
|
|
177
|
+
React.createElement(NavigationHeader, { headerHeight: headerHeight, iconSize: 39, paddingLeft: 6 }),
|
|
178
|
+
React.createElement("div", { style: {
|
|
179
|
+
backgroundColor: 'var(--bg-color)',
|
|
180
|
+
display: 'flex',
|
|
181
|
+
justifyContent: 'flex-end',
|
|
182
|
+
} },
|
|
183
|
+
React.createElement("div", { id: "navigation-container", style: __assign({ top: 0, height: "calc(100vh - ".concat(headerHeight, "px - var(--block-margin))"), overflowY: 'auto', overscrollBehavior: 'contain', paddingBottom: 40 }, navWidth) },
|
|
184
|
+
// TODO/refactor: simplify?
|
|
185
|
+
isDetachedPage ? (React.createElement(NavigationContent, { navItems: navItems })) : (React.createElement(NavigationContent, { navItems: navItemsAll, showOnlyRelevant: true })))))),
|
|
186
|
+
React.createElement("script", { dangerouslySetInnerHTML: { __html: autoScrollNav_SSR } })));
|
|
187
|
+
}
|
|
188
|
+
function NavigationHeader(_a) {
|
|
189
|
+
var _b;
|
|
190
|
+
var headerHeight = _a.headerHeight, iconSize = _a.iconSize, style = _a.style, paddingLeft = _a.paddingLeft;
|
|
191
|
+
var pageContext = usePageContext();
|
|
192
|
+
//*
|
|
193
|
+
var projectName = pageContext.meta.projectName;
|
|
194
|
+
/*/
|
|
195
|
+
const projectName = 'Vike'
|
|
196
|
+
//*/
|
|
197
|
+
var isProjectNameShort = projectName.length <= 4;
|
|
198
|
+
var childrenStyle = (_b = {
|
|
199
|
+
justifyContent: 'center',
|
|
200
|
+
fontSize: isProjectNameShort ? '4.8cqw' : '4.5cqw'
|
|
201
|
+
},
|
|
202
|
+
_b['--icon-text-padding'] = '1.8cqw',
|
|
203
|
+
_b);
|
|
204
|
+
var marginLeft = -10;
|
|
205
|
+
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("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
|
+
React.createElement("img", { src: pageContext.meta.faviconUrl, height: iconSize, width: iconSize, onContextMenu: function (ev) {
|
|
209
|
+
if (!pageContext.config.pressKit)
|
|
210
|
+
return; // no /press page
|
|
211
|
+
if (window.location.pathname === '/press')
|
|
212
|
+
return;
|
|
213
|
+
ev.preventDefault();
|
|
214
|
+
navigate('/press#logo');
|
|
215
|
+
} }),
|
|
216
|
+
React.createElement("span", { style: {
|
|
217
|
+
marginLeft: "calc(var(--icon-text-padding) + 2px)",
|
|
218
|
+
fontSize: isProjectNameShort ? '1.65em' : '1.3em',
|
|
219
|
+
} }, projectName)),
|
|
220
|
+
React.createElement(SearchLink, { style: __assign(__assign({}, childrenStyle), { flexGrow: 0.5 }) }),
|
|
221
|
+
React.createElement(MenuLink, { style: __assign(__assign({}, childrenStyle), { flexGrow: 1 }) }))));
|
|
222
|
+
}
|
|
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) {
|
|
225
|
+
ev.preventDefault();
|
|
226
|
+
toggleMenuModal();
|
|
227
|
+
}, "aria-label": 'Ctrl\xa0+\xa0M' }),
|
|
228
|
+
React.createElement(MenuIcon, null),
|
|
229
|
+
"Menu"));
|
|
230
|
+
}
|
|
231
|
+
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" })));
|
|
234
|
+
}
|
|
235
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
package/dist/Links.d.ts
ADDED
package/dist/Links.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import iconGithub from './icons/github.svg';
|
|
14
|
+
import iconTwitter from './icons/twitter.svg';
|
|
15
|
+
import iconDiscord from './icons/discord.svg';
|
|
16
|
+
import iconChangelog from './icons/changelog.svg';
|
|
17
|
+
import iconLanguages from './icons/languages.svg';
|
|
18
|
+
import { usePageContext } from './renderer/usePageContext';
|
|
19
|
+
import '@docsearch/css';
|
|
20
|
+
export { Links };
|
|
21
|
+
function Links(_a) {
|
|
22
|
+
var style = _a.style;
|
|
23
|
+
var pageContext = usePageContext();
|
|
24
|
+
var _b = pageContext.config, projectInfo = _b.projectInfo, i18n = _b.i18n;
|
|
25
|
+
var iconI18n = !i18n ? null : (React.createElement(LinkIcon, { className: "decolorize-4", icon: iconLanguages, href: '/languages', style: { height: 21, position: 'relative', top: 0, left: 0 } }));
|
|
26
|
+
return (React.createElement("div", { style: __assign({ display: 'flex', alignItems: 'center', paddingTop: 0, justifyContent: 'left', height: '100%' }, style) },
|
|
27
|
+
iconI18n,
|
|
28
|
+
projectInfo.discordInvite && (React.createElement(LinkIcon, { className: "decolorize-6", icon: iconDiscord, href: projectInfo.discordInvite })),
|
|
29
|
+
React.createElement(LinkIcon, { className: "decolorize-4", icon: iconTwitter, href: projectInfo.twitterProfile }),
|
|
30
|
+
React.createElement(LinkIcon, { className: "decolorize-4", icon: iconGithub, href: projectInfo.githubRepository }),
|
|
31
|
+
React.createElement(ChangelogButton, null)));
|
|
32
|
+
}
|
|
33
|
+
function ChangelogButton() {
|
|
34
|
+
var pageContext = usePageContext();
|
|
35
|
+
var projectInfo = pageContext.config.projectInfo;
|
|
36
|
+
return (React.createElement("a", { href: "".concat(projectInfo.githubRepository, "/blob/main/CHANGELOG.md"), className: "colorize-on-hover", style: {
|
|
37
|
+
display: 'flex',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
padding: 10,
|
|
40
|
+
height: '100%',
|
|
41
|
+
} },
|
|
42
|
+
React.createElement("div", { className: "button", style: {
|
|
43
|
+
display: 'flex',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
padding: '2px 10px',
|
|
46
|
+
fontSize: '0.97em',
|
|
47
|
+
} },
|
|
48
|
+
React.createElement("span", { id: "version-number", className: "decolorize-7" },
|
|
49
|
+
"v",
|
|
50
|
+
projectInfo.projectVersion),
|
|
51
|
+
React.createElement("img", { className: "decolorize-6", src: iconChangelog, height: 16, style: { marginLeft: 6 } }))));
|
|
52
|
+
}
|
|
53
|
+
function LinkIcon(_a) {
|
|
54
|
+
var className = _a.className, icon = _a.icon, href = _a.href, style = _a.style;
|
|
55
|
+
return (React.createElement(React.Fragment, null,
|
|
56
|
+
React.createElement("a", { className: "colorize-on-hover", href: href, style: { padding: 5, display: 'inline-flex', lineHeight: 0, height: '100%', alignItems: 'center' } },
|
|
57
|
+
React.createElement("img", { className: className, src: icon, height: "20", style: style }))));
|
|
58
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
export { MenuModal };
|
|
6
|
+
export { toggleMenuModal };
|
|
7
|
+
export { closeMenuModal };
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { usePageContext } from './renderer/usePageContext';
|
|
10
|
+
import { NavigationContent } from './navigation/Navigation';
|
|
11
|
+
import { css } from './utils/css';
|
|
12
|
+
import { containerQueryMobile } from './Layout';
|
|
13
|
+
import { Links } from './Links';
|
|
14
|
+
import { isBrowser } from './utils/isBrowser';
|
|
15
|
+
import { getViewportWidth } from './utils/getViewportWidth';
|
|
16
|
+
initCloseListeners();
|
|
17
|
+
function MenuModal() {
|
|
18
|
+
return (React.createElement(React.Fragment, null,
|
|
19
|
+
React.createElement("style", null, getStyle()),
|
|
20
|
+
React.createElement("div", { id: "menu-modal", className: "link-hover-animation", style: {
|
|
21
|
+
position: 'fixed',
|
|
22
|
+
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,
|
|
32
|
+
left: 0,
|
|
33
|
+
zIndex: 9999,
|
|
34
|
+
overflow: 'scroll',
|
|
35
|
+
background: 'var(--bg-color)',
|
|
36
|
+
} },
|
|
37
|
+
React.createElement("div", { style: {
|
|
38
|
+
// Place <LinksBottom /> to the bottom
|
|
39
|
+
display: 'flex',
|
|
40
|
+
flexDirection: 'column',
|
|
41
|
+
minHeight: '100dvh',
|
|
42
|
+
justifyContent: 'space-between',
|
|
43
|
+
// We don't set `container` to parent beacuse of a Chrome bug (showing a blank <MenuModal>)
|
|
44
|
+
containerType: 'inline-size',
|
|
45
|
+
} },
|
|
46
|
+
React.createElement(Nav, null),
|
|
47
|
+
React.createElement(LinksBottom, null)),
|
|
48
|
+
React.createElement(CloseButton, null))));
|
|
49
|
+
}
|
|
50
|
+
function Nav() {
|
|
51
|
+
var pageContext = usePageContext();
|
|
52
|
+
var navItems = pageContext.navItemsAll;
|
|
53
|
+
return React.createElement(NavigationContent, { columnLayout: true, navItems: navItems });
|
|
54
|
+
}
|
|
55
|
+
function LinksBottom() {
|
|
56
|
+
return (React.createElement("div", { style: {
|
|
57
|
+
display: 'flex',
|
|
58
|
+
justifyContent: 'center',
|
|
59
|
+
} },
|
|
60
|
+
React.createElement(Links, { style: { height: 70 } })));
|
|
61
|
+
}
|
|
62
|
+
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);
|
|
64
|
+
}
|
|
65
|
+
function CloseButton() {
|
|
66
|
+
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 },
|
|
67
|
+
React.createElement("svg", { width: "48.855", height: "48.855", version: "1.1", viewBox: "0 0 22.901 22.901", xmlns: "http://www.w3.org/2000/svg" },
|
|
68
|
+
React.createElement("circle", { cx: "11.45", cy: "11.45", r: "10.607", fill: "#ececec", stroke: "#666", strokeDashoffset: "251.44", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "1.6875", style: { paintOrder: 'normal' } }),
|
|
69
|
+
React.createElement("path", { d: "m7.5904 6.2204 3.86 3.86 3.84-3.84a0.92 0.92 0 0 1 0.66-0.29 1 1 0 0 1 1 1 0.9 0.9 0 0 1-0.27 0.66l-3.89 3.84 3.89 3.89a0.9 0.9 0 0 1 0.27 0.61 1 1 0 0 1-1 1 0.92 0.92 0 0 1-0.69-0.27l-3.81-3.86-3.85 3.85a0.92 0.92 0 0 1-0.65 0.28 1 1 0 0 1-1-1 0.9 0.9 0 0 1 0.27-0.66l3.89-3.84-3.89-3.89a0.9 0.9 0 0 1-0.27-0.61 1 1 0 0 1 1-1c0.24 3e-3 0.47 0.1 0.64 0.27z", fill: "#666", stroke: "#666", strokeWidth: ".11719" }))));
|
|
70
|
+
}
|
|
71
|
+
function toggleMenuModal() {
|
|
72
|
+
document.documentElement.classList.toggle('menu-modal-show');
|
|
73
|
+
if (document.documentElement.classList.contains('menu-modal-show') && getViewportWidth() < containerQueryMobile) {
|
|
74
|
+
autoScroll();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function autoScroll() {
|
|
78
|
+
var nav = document.querySelector('#menu-modal .navigation-content');
|
|
79
|
+
var href = window.location.pathname;
|
|
80
|
+
var navLinks = Array.from(nav.querySelectorAll("a[href=\"".concat(href, "\"]")));
|
|
81
|
+
var navLink = navLinks[0];
|
|
82
|
+
if (!navLink)
|
|
83
|
+
return;
|
|
84
|
+
navLink.scrollIntoView({
|
|
85
|
+
behavior: 'instant',
|
|
86
|
+
block: 'center',
|
|
87
|
+
inline: 'start',
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function closeMenuModal() {
|
|
91
|
+
document.documentElement.classList.remove('menu-modal-show');
|
|
92
|
+
}
|
|
93
|
+
function initCloseListeners() {
|
|
94
|
+
if (!isBrowser())
|
|
95
|
+
return;
|
|
96
|
+
document.addEventListener('click', onLinkClick);
|
|
97
|
+
// It's redundant (and onLinkClick() is enough), but just to be sure.
|
|
98
|
+
addEventListener('hashchange', closeMenuModal);
|
|
99
|
+
}
|
|
100
|
+
function onLinkClick(ev) {
|
|
101
|
+
if (ev.altKey || ev.ctrlKey || ev.metaKey || ev.shiftKey)
|
|
102
|
+
return;
|
|
103
|
+
var linkTag = findLinkTag(ev.target);
|
|
104
|
+
if (!linkTag)
|
|
105
|
+
return;
|
|
106
|
+
var href = linkTag.getAttribute('href');
|
|
107
|
+
if (!href)
|
|
108
|
+
return;
|
|
109
|
+
if (!href.startsWith('/') && !href.startsWith('#'))
|
|
110
|
+
return;
|
|
111
|
+
closeMenuModal();
|
|
112
|
+
}
|
|
113
|
+
function findLinkTag(target) {
|
|
114
|
+
while (target.tagName !== 'A') {
|
|
115
|
+
var parentNode = target.parentNode;
|
|
116
|
+
if (!parentNode) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
target = parentNode;
|
|
120
|
+
}
|
|
121
|
+
return target;
|
|
122
|
+
}
|
|
123
|
+
var templateObject_1;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export { autoScrollNav };
|
|
2
|
+
export var autoScrollNav_SSR = "autoScrollNav();".concat(autoScrollNav.toString());
|
|
3
|
+
// - We cannot use TypeScript syntax because of autoScrollNav_SSR
|
|
4
|
+
// - We have to save & restore `document.documentElement.scrollTop` because scrollIntoView() scrolls the main view. (I don't know why).
|
|
5
|
+
// - Failed alternatives:
|
|
6
|
+
// - scrollIntoViewIfNeeded() (https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewIfNeeded) would work (it doesn't scroll the main view) but Firefox doesn't support it.
|
|
7
|
+
// - Doesn't work: the scrolling is off by hundreds of px (I guess because this function runs too early while the page is still rendering).
|
|
8
|
+
// ```js
|
|
9
|
+
// const offset = navLink.offsetTop - (window.innerHeight / 2)
|
|
10
|
+
// navigationContainerEl.scrollTop = offset
|
|
11
|
+
// ```
|
|
12
|
+
// - Doesn't work: scrollIntoView() still scrolls the main view
|
|
13
|
+
// ```js
|
|
14
|
+
// const overflowOriginal = document.documentElement.style.overflow
|
|
15
|
+
// document.documentElement.style.overflow = 'hidden'
|
|
16
|
+
// // ...
|
|
17
|
+
// document.documentElement.style.overflow = overflowOriginal
|
|
18
|
+
// ```
|
|
19
|
+
function autoScrollNav() {
|
|
20
|
+
var nav = document.querySelector('#nav-left .navigation-content');
|
|
21
|
+
if (!nav)
|
|
22
|
+
return;
|
|
23
|
+
var href = window.location.pathname;
|
|
24
|
+
var navLinks = Array.from(nav.querySelectorAll("a[href=\"".concat(href, "\"]")));
|
|
25
|
+
var navLink = navLinks[0];
|
|
26
|
+
if (!navLink)
|
|
27
|
+
return;
|
|
28
|
+
var scrollTopOriginal = document.documentElement.scrollTop;
|
|
29
|
+
navLink.scrollIntoView({
|
|
30
|
+
behavior: 'instant',
|
|
31
|
+
block: 'center',
|
|
32
|
+
inline: 'start',
|
|
33
|
+
});
|
|
34
|
+
document.documentElement.scrollTop = scrollTopOriginal;
|
|
35
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RepoLink } from './RepoLink';
|
|
3
|
+
export { EditPageNote };
|
|
4
|
+
function EditPageNote(_a) {
|
|
5
|
+
var pageContext = _a.pageContext;
|
|
6
|
+
var text = (React.createElement(React.Fragment, null,
|
|
7
|
+
React.createElement("span", { style: { fontFamily: 'emoji' } }, "\u270D"),
|
|
8
|
+
" Edit this page"));
|
|
9
|
+
return (React.createElement("div", { style: { marginTop: 50 } },
|
|
10
|
+
React.createElement(RepoLink, { path: '/docs/pages' + pageContext.urlPathname + '/+Page.mdx', text: text, editMode: true })));
|
|
11
|
+
}
|
|
@@ -23,7 +23,7 @@ import { assert, isBrowser, jsxToTextContent } from '../utils/server';
|
|
|
23
23
|
import { getConfig } from './getConfig';
|
|
24
24
|
import pc from '@brillout/picocolors';
|
|
25
25
|
import { parseTitle } from '../parseTitle';
|
|
26
|
-
import {
|
|
26
|
+
import { determineColumnEntries } from '../renderer/determineColumnEntries';
|
|
27
27
|
assert(!isBrowser());
|
|
28
28
|
function resolveHeadingsData(pageContext) {
|
|
29
29
|
var config = getConfig();
|
|
@@ -41,14 +41,12 @@ function resolveHeadingsData(pageContext) {
|
|
|
41
41
|
// TODO/refactor: remove navItems
|
|
42
42
|
var navItems;
|
|
43
43
|
var navItemsAll;
|
|
44
|
-
var columnLayouts;
|
|
45
44
|
{
|
|
46
45
|
var navItemsPageSections = pageSectionsResolved
|
|
47
46
|
.filter(function (pageSection) { return pageSection.pageSectionLevel === 2; })
|
|
48
47
|
.map(pageSectionToNavItem);
|
|
49
48
|
navItemsAll = headingsResolved.map(headingToNavItem);
|
|
50
|
-
|
|
51
|
-
columnLayouts = res.columnLayouts;
|
|
49
|
+
determineColumnEntries(navItemsAll);
|
|
52
50
|
if (isDetachedPage) {
|
|
53
51
|
navItems = __spreadArray([headingToNavItem(activeHeading)], navItemsPageSections, true);
|
|
54
52
|
}
|
|
@@ -70,8 +68,6 @@ function resolveHeadingsData(pageContext) {
|
|
|
70
68
|
pageTitle: pageTitle,
|
|
71
69
|
documentTitle: documentTitle,
|
|
72
70
|
// TODO: don't pass to client-side
|
|
73
|
-
columnLayouts: columnLayouts,
|
|
74
|
-
// TODO: don't pass to client-side
|
|
75
71
|
activeCategory: activeCategory,
|
|
76
72
|
};
|
|
77
73
|
return pageContextAddendum;
|