@brillout/docpress 0.8.11 → 0.8.13-commit-8740149

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.
Files changed (37) hide show
  1. package/Layout.tsx +35 -23
  2. package/MenuModal.tsx +23 -11
  3. package/config/resolveHeadingsData.ts +2 -6
  4. package/css/colorize-on-hover.css +10 -1
  5. package/dist/Layout.d.ts +11 -0
  6. package/dist/Layout.js +243 -0
  7. package/dist/Links.d.ts +6 -0
  8. package/dist/Links.js +58 -0
  9. package/dist/MenuModal.d.ts +9 -0
  10. package/dist/MenuModal.js +131 -0
  11. package/dist/autoScrollNav.d.ts +3 -0
  12. package/dist/autoScrollNav.js +35 -0
  13. package/dist/components/EditPageNote.d.ts +7 -0
  14. package/dist/components/EditPageNote.js +11 -0
  15. package/dist/config/resolveHeadingsData.d.ts +0 -1
  16. package/dist/config/resolveHeadingsData.js +2 -6
  17. package/dist/config/resolvePageContext.d.ts +0 -1
  18. package/dist/docsearch/SearchLink.d.ts +4 -0
  19. package/dist/docsearch/SearchLink.js +25 -0
  20. package/dist/docsearch/toggleDocsearchModal.d.ts +4 -0
  21. package/dist/docsearch/toggleDocsearchModal.js +26 -0
  22. package/dist/navigation/Navigation.d.ts +2 -1
  23. package/dist/navigation/Navigation.js +69 -38
  24. package/dist/renderer/determineColumnEntries.d.ts +3 -0
  25. package/dist/renderer/{getStyleColumnLayout.js → determineColumnEntries.js} +16 -64
  26. package/dist/utils/PassTrough.d.ts +3 -0
  27. package/dist/utils/PassTrough.js +6 -0
  28. package/dist/utils/getViewportWidth.d.ts +1 -0
  29. package/dist/utils/getViewportWidth.js +4 -0
  30. package/docsearch/SearchLink.tsx +3 -12
  31. package/navigation/Navigation.css +2 -1
  32. package/navigation/Navigation.tsx +94 -63
  33. package/package.json +1 -1
  34. package/renderer/{getStyleColumnLayout.ts → determineColumnEntries.ts} +20 -90
  35. package/renderer/onRenderHtml.tsx +0 -4
  36. package/utils/getViewportWidth.ts +4 -0
  37. package/dist/renderer/getStyleColumnLayout.d.ts +0 -7
package/Layout.tsx CHANGED
@@ -1,5 +1,7 @@
1
1
  export { Layout }
2
2
  export { containerQueryMobile }
3
+ export { navWidthMin }
4
+ export { navWidthMax }
3
5
 
4
6
  import React from 'react'
5
7
  import { NavigationContent } from './navigation/Navigation'
@@ -7,7 +9,7 @@ import { EditPageNote } from './components/EditPageNote'
7
9
  import { parseTitle } from './parseTitle'
8
10
  import { usePageContext, usePageContext2 } from './renderer/usePageContext'
9
11
  import { Links } from './Links'
10
- import { toggleMenuModal } from './MenuModal'
12
+ import { closeMenuModal, openMenuModal, toggleMenuModal } from './MenuModal'
11
13
  import { MenuModal } from './MenuModal'
12
14
  import { autoScrollNav_SSR } from './autoScrollNav'
13
15
  import { SearchLink } from './docsearch/SearchLink'
@@ -56,6 +58,7 @@ function Layout({ children }: { children: React.ReactNode }) {
56
58
  ['--bg-color']: '#f5f5f7',
57
59
  ['--block-margin']: `${blockMargin}px`,
58
60
  ['--icon-text-padding']: '8px',
61
+ ['--top-nav-height']: `${isLandingPage ? 70 : 60}px`,
59
62
  }}
60
63
  >
61
64
  <MenuModal />
@@ -196,7 +199,7 @@ function PageContent({ children }: { children: React.ReactNode }) {
196
199
  function NavMobile() {
197
200
  return (
198
201
  <div id="nav-mobile">
199
- <NavigationHeader headerHeight={70} iconSize={40} paddingLeft={12} style={{ justifyContent: 'center' }} />
202
+ <NavigationHeader iconSize={40} paddingLeft={12} style={{ justifyContent: 'center' }} />
200
203
  </div>
201
204
  )
202
205
  }
@@ -253,7 +256,7 @@ function NavLeft() {
253
256
  top: 0,
254
257
  }}
255
258
  >
256
- <NavigationHeader headerHeight={headerHeight} iconSize={39} paddingLeft={6} />
259
+ <NavigationHeader iconSize={39} paddingLeft={6} />
257
260
  <div
258
261
  style={{
259
262
  backgroundColor: 'var(--bg-color)',
@@ -291,11 +294,10 @@ function NavLeft() {
291
294
  }
292
295
 
293
296
  function NavigationHeader({
294
- headerHeight,
295
297
  iconSize,
296
298
  style,
297
299
  paddingLeft,
298
- }: { headerHeight: number; iconSize: number; paddingLeft: number; style?: React.CSSProperties }) {
300
+ }: { iconSize: number; paddingLeft: number; style?: React.CSSProperties }) {
299
301
  const pageContext = usePageContext()
300
302
  //*
301
303
  const { projectName } = pageContext.meta
@@ -322,8 +324,9 @@ function NavigationHeader({
322
324
  <div
323
325
  style={{
324
326
  display: 'flex',
325
- height: headerHeight,
327
+ height: 'var(--top-nav-height)',
326
328
  containerType: 'inline-size',
329
+ alignItems: 'center',
327
330
  ...navWidth,
328
331
  }}
329
332
  >
@@ -381,41 +384,50 @@ function NavigationHeader({
381
384
  )
382
385
  }
383
386
 
384
- type PropsAnchor = React.HTMLProps<HTMLAnchorElement>
385
- function MenuLink(props: PropsAnchor) {
387
+ function MenuLink({ style }: { style: React.CSSProperties }) {
386
388
  return (
387
- <a
388
- {...props}
389
+ <div
389
390
  style={{
390
- height: '100%',
391
+ height: 'calc(100% + 2 * var(--block-margin))',
391
392
  display: 'flex',
392
393
  alignItems: 'center',
393
- cursor: 'pointer',
394
- ...props.style,
394
+ ...style,
395
395
  }}
396
- className="colorize-on-hover"
396
+ className="colorize-on-hover colorize-on-menu"
397
397
  onClick={(ev) => {
398
398
  ev.preventDefault()
399
399
  toggleMenuModal()
400
400
  }}
401
+ onMouseEnter={openMenuModal}
402
+ onMouseLeave={closeMenuModal}
401
403
  aria-label={'Ctrl\xa0+\xa0M'}
402
404
  >
405
+ {/* TODO/refactor
406
+ <style>{css`
407
+ `}</style>
408
+ */}
409
+ <div
410
+ id="link-bg"
411
+ style={{
412
+ position: 'absolute',
413
+ width: '100%',
414
+ height: 'calc(100% - var(--block-margin))',
415
+ left: 0,
416
+ top: 0,
417
+ }}
418
+ ></div>
403
419
  <MenuIcon />
404
- Menu
405
- </a>
420
+ Docs
421
+ </div>
406
422
  )
407
423
  }
408
424
  function MenuIcon() {
409
425
  return (
410
- <svg
426
+ <span
411
427
  style={{ marginRight: 'calc(var(--icon-text-padding) + 2px)', lineHeight: 0, width: '1.3em' }}
412
428
  className="decolorize-6"
413
- viewBox="0 0 448 512"
414
429
  >
415
- <path
416
- fill="currentColor"
417
- 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"
418
- ></path>
419
- </svg>
430
+ 📚
431
+ </span>
420
432
  )
421
433
  }
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'
@@ -9,6 +10,7 @@ import { css } from './utils/css'
9
10
  import { containerQueryMobile } from './Layout'
10
11
  import { Links } from './Links'
11
12
  import { isBrowser } from './utils/isBrowser'
13
+ import { getViewportWidth } from './utils/getViewportWidth'
12
14
 
13
15
  initCloseListeners()
14
16
 
@@ -27,31 +29,39 @@ function MenuModal() {
27
29
  * - https://stackoverflow.com/questions/37112218/css3-100vh-not-constant-in-mobile-browser/72245072#72245072
28
30
  height: '100dh',
29
31
  /*/
30
- height: '100vh',
31
- maxHeight: '100dvh',
32
+ height: 'calc(100vh - var(--top-nav-height))',
32
33
  //*/
33
- top: 0,
34
+ top: 'calc(var(--top-nav-height) + var(--block-margin))',
34
35
  left: 0,
35
36
  zIndex: 9999,
36
37
  overflow: 'scroll',
37
- background: 'var(--bg-color)',
38
+ background: '#eaeaea',
39
+ // background: '#ededef',
40
+ // boxShadow: 'rgba(0, 0, 0, 0.35) 0 0 13px 3px',
41
+ // boxShadow: 'rgba(6, 24, 44, 0.4) 0px 0px 0px 2px, rgba(6, 24, 44, 0.65) 0px 4px 13px -1px, rgba(255, 255, 255, 0.08) 0px 1px 0px inset',
42
+ boxShadow:
43
+ 'rgb(6 24 44 / 8%) 0px 0px 0px 3px, rgba(6, 24, 44, 0.65) 0px 4px 13px -1px, rgba(255, 255, 255, 0.28) 0px 1px 0px inset',
44
+ transition: 'opacity 0.3s ease-in-out',
38
45
  }}
46
+ onMouseEnter={openMenuModal}
47
+ onMouseLeave={closeMenuModal}
39
48
  >
40
49
  <div
41
50
  style={{
42
51
  // Place <LinksBottom /> to the bottom
43
52
  display: 'flex',
44
53
  flexDirection: 'column',
45
- minHeight: '100dvh',
54
+ minHeight: 'calc(100vh - var(--top-nav-height))',
46
55
  justifyContent: 'space-between',
47
56
  // We don't set `container` to parent beacuse of a Chrome bug (showing a blank <MenuModal>)
48
57
  containerType: 'inline-size',
49
58
  }}
50
59
  >
51
60
  <Nav />
52
- <LinksBottom />
53
61
  </div>
62
+ {/* TODO: remove
54
63
  <CloseButton />
64
+ */}
55
65
  </div>
56
66
  </>
57
67
  )
@@ -61,6 +71,7 @@ function Nav() {
61
71
  const navItems = pageContext.navItemsAll
62
72
  return <NavigationContent columnLayout={true} navItems={navItems} />
63
73
  }
74
+ // TODO: remove
64
75
  function LinksBottom() {
65
76
  return (
66
77
  <div
@@ -77,7 +88,8 @@ function LinksBottom() {
77
88
  function getStyle() {
78
89
  return css`
79
90
  html:not(.menu-modal-show) #menu-modal {
80
- display: none;
91
+ opacity: 0;
92
+ pointer-events:none;
81
93
  }
82
94
  // disable scroll of main view
83
95
  html.menu-modal-show {
@@ -91,6 +103,7 @@ html.menu-modal-show {
91
103
  `
92
104
  }
93
105
 
106
+ // TODO: remove?
94
107
  function CloseButton() {
95
108
  return (
96
109
  <div
@@ -129,10 +142,6 @@ function toggleMenuModal() {
129
142
  autoScroll()
130
143
  }
131
144
  }
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
145
  function autoScroll() {
137
146
  const nav = document.querySelector('#menu-modal .navigation-content')!
138
147
  const href = window.location.pathname
@@ -145,6 +154,9 @@ function autoScroll() {
145
154
  inline: 'start',
146
155
  })
147
156
  }
157
+ function openMenuModal() {
158
+ document.documentElement.classList.add('menu-modal-show')
159
+ }
148
160
  function closeMenuModal() {
149
161
  document.documentElement.classList.remove('menu-modal-show')
150
162
  }
@@ -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 { determineColumnLayoutEntries } from '../renderer/getStyleColumnLayout'
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
- const res = determineColumnLayoutEntries(navItemsAll)
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
@@ -4,7 +4,9 @@
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 .colorize-on-menu [class^='decolorize-'],
9
+ html.menu-modal-show .colorize-on-menu [class*=' decolorize-'] {
8
10
  filter: grayscale(0) opacity(1) !important;
9
11
  }
10
12
  .link-hover-animation a:hover {
@@ -38,3 +40,10 @@
38
40
  body {
39
41
  --active-color: rgba(0, 0, 0, 0.03);
40
42
  }
43
+
44
+
45
+ /* TODO/refactor: move */
46
+ :has(> #link-bg):hover > #link-bg,
47
+ html.menu-modal-show #link-bg {
48
+ background: var(--active-color)
49
+ }
@@ -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,243 @@
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 { closeMenuModal, openMenuModal, 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['--top-nav-height'] = "".concat(isLandingPage ? 70 : 60, "px"),
72
+ _b) },
73
+ React.createElement(MenuModal, null),
74
+ React.createElement("div", { className: isLandingPage ? '' : 'doc-page', style: __assign({
75
+ // We don't add `container` to `body` nor `html` beacuse in Firefox it breaks the `position: fixed` of <MenuModal>
76
+ // https://stackoverflow.com/questions/74601420/css-container-inline-size-and-fixed-child
77
+ containerType: 'inline-size' }, whitespaceBuster1) }, content)));
78
+ }
79
+ function LayoutDocsPage(_a) {
80
+ var children = _a.children;
81
+ var pageContext = usePageContext();
82
+ var hideNavLeftAlways = pageContext.navItems.length <= 1;
83
+ return (React.createElement(React.Fragment, null,
84
+ React.createElement("style", null, getStyle()),
85
+ React.createElement(NavMobile, null),
86
+ React.createElement("div", { style: __assign({ display: 'flex' }, whitespaceBuster2) },
87
+ React.createElement(NavLeft, null),
88
+ React.createElement("div", { className: "low-prio-grow", style: { width: 0, maxWidth: 50, background: 'var(--bg-color)' } }),
89
+ React.createElement(PageContent, null, children))));
90
+ function getStyle() {
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);
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"], ["\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"])));
93
+ if (!hideNavLeftAlways) {
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);
95
+ }
96
+ style += navLeftHide;
97
+ return style;
98
+ }
99
+ }
100
+ function LayoutLandingPage(_a) {
101
+ var children = _a.children;
102
+ var mobile = 800;
103
+ return (React.createElement(React.Fragment, null,
104
+ React.createElement("style", null, getStyle()),
105
+ React.createElement(NavTop, null),
106
+ React.createElement(NavMobile, null),
107
+ React.createElement(PageContent, null, children)));
108
+ function getStyle() {
109
+ 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);
110
+ }
111
+ }
112
+ function PageContent(_a) {
113
+ var _b;
114
+ var children = _a.children;
115
+ var pageContext = usePageContext();
116
+ var isLandingPage = pageContext.isLandingPage, pageTitle = pageContext.pageTitle;
117
+ var pageTitleParsed = pageTitle && parseTitle(pageTitle);
118
+ var globalNote = pageContext.config.globalNote;
119
+ var ifDocPage = function (style) { return (isLandingPage ? {} : style); };
120
+ return (React.createElement("div", { className: "page-wrapper low-prio-grow", style: __assign({
121
+ // Avoid overflow, see https://stackoverflow.com/questions/36230944/prevent-flex-items-from-overflowing-a-container/66689926#66689926
122
+ minWidth: 0 }, ifDocPage({
123
+ backgroundColor: 'var(--bg-color)',
124
+ paddingBottom: 50,
125
+ })) },
126
+ React.createElement("div", { className: "page-content", style: __assign((_b = {}, _b['--main-view-padding'] = "".concat(mainViewPadding, "px"), _b), ifDocPage({
127
+ width: "calc(".concat(mainViewWidthMax, "px + 2 * var(--main-view-padding))"),
128
+ maxWidth: '100%',
129
+ padding: '20px var(--main-view-padding)',
130
+ })) },
131
+ globalNote,
132
+ pageTitleParsed && React.createElement("h1", { id: "".concat(pageContext.urlPathname.replace('/', '')) }, pageTitleParsed),
133
+ children,
134
+ !isLandingPage && React.createElement(EditPageNote, { pageContext: pageContext }))));
135
+ }
136
+ function NavMobile() {
137
+ return (React.createElement("div", { id: "nav-mobile" },
138
+ React.createElement(NavigationHeader, { iconSize: 40, paddingLeft: 12, style: { justifyContent: 'center' } })));
139
+ }
140
+ function NavTop() {
141
+ var _a;
142
+ var pageContext2 = usePageContext2();
143
+ var paddingSize = 35;
144
+ var padding = "0 ".concat(paddingSize, "px");
145
+ var TopNavigation = pageContext2.config.TopNavigation || PassThrough;
146
+ return (React.createElement("div", { id: "top-navigation", className: "link-hover-animation", style: (_a = {
147
+ position: 'relative',
148
+ display: 'flex',
149
+ alignItems: 'center',
150
+ justifyContent: 'center',
151
+ textDecoration: 'none',
152
+ marginBottom: 'var(--block-margin)',
153
+ backgroundColor: 'var(--bg-color)'
154
+ },
155
+ _a['--padding-side'] = "".concat(paddingSize, "px"),
156
+ _a.fontSize = '1.06em',
157
+ _a.color = '#666',
158
+ _a) },
159
+ React.createElement("div", { style: { display: 'flex', alignItems: 'center', height: 70 } },
160
+ React.createElement(TopNavigation, null),
161
+ React.createElement(SearchLink, { style: { padding: padding } }),
162
+ React.createElement(MenuLink, { style: { padding: padding } }),
163
+ React.createElement(Links, { style: { display: 'inline-flex', padding: padding, marginLeft: -8 } }))));
164
+ }
165
+ function NavLeft() {
166
+ var pageContext = usePageContext();
167
+ var navItems = pageContext.navItems, navItemsAll = pageContext.navItemsAll, isDetachedPage = pageContext.isDetachedPage;
168
+ var headerHeight = 60;
169
+ return (React.createElement(React.Fragment, null,
170
+ React.createElement("div", { id: "nav-left", className: "link-hover-animation", style: {
171
+ flexGrow: 1,
172
+ borderRight: 'var(--block-margin) solid white',
173
+ } },
174
+ React.createElement("div", { style: {
175
+ position: 'sticky',
176
+ top: 0,
177
+ } },
178
+ React.createElement(NavigationHeader, { iconSize: 39, paddingLeft: 6 }),
179
+ React.createElement("div", { style: {
180
+ backgroundColor: 'var(--bg-color)',
181
+ display: 'flex',
182
+ justifyContent: 'flex-end',
183
+ } },
184
+ 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) },
185
+ // TODO/refactor: simplify?
186
+ isDetachedPage ? (React.createElement(NavigationContent, { navItems: navItems })) : (React.createElement(NavigationContent, { navItems: navItemsAll, showOnlyRelevant: true })))))),
187
+ React.createElement("script", { dangerouslySetInnerHTML: { __html: autoScrollNav_SSR } })));
188
+ }
189
+ function NavigationHeader(_a) {
190
+ var _b;
191
+ var iconSize = _a.iconSize, style = _a.style, paddingLeft = _a.paddingLeft;
192
+ var pageContext = usePageContext();
193
+ //*
194
+ var projectName = pageContext.meta.projectName;
195
+ /*/
196
+ const projectName = 'Vike'
197
+ //*/
198
+ var isProjectNameShort = projectName.length <= 4;
199
+ var childrenStyle = (_b = {
200
+ justifyContent: 'center',
201
+ fontSize: isProjectNameShort ? '4.8cqw' : '4.5cqw'
202
+ },
203
+ _b['--icon-text-padding'] = '1.8cqw',
204
+ _b);
205
+ var marginLeft = -10;
206
+ return (React.createElement("div", { style: __assign({ backgroundColor: 'var(--bg-color)', display: 'flex', justifyContent: 'flex-end', borderBottom: 'var(--block-margin) solid white' }, style) },
207
+ React.createElement("div", { style: __assign({ display: 'flex', height: 'var(--top-nav-height)', containerType: 'inline-size', alignItems: 'center' }, navWidth) },
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: "/" },
209
+ React.createElement("img", { src: pageContext.meta.faviconUrl, height: iconSize, width: iconSize, onContextMenu: function (ev) {
210
+ if (!pageContext.config.pressKit)
211
+ return; // no /press page
212
+ if (window.location.pathname === '/press')
213
+ return;
214
+ ev.preventDefault();
215
+ navigate('/press#logo');
216
+ } }),
217
+ React.createElement("span", { style: {
218
+ marginLeft: "calc(var(--icon-text-padding) + 2px)",
219
+ fontSize: isProjectNameShort ? '1.65em' : '1.3em',
220
+ } }, projectName)),
221
+ React.createElement(SearchLink, { style: __assign(__assign({}, childrenStyle), { flexGrow: 0.5 }) }),
222
+ React.createElement(MenuLink, { style: __assign(__assign({}, childrenStyle), { flexGrow: 1 }) }))));
223
+ }
224
+ function MenuLink(_a) {
225
+ var style = _a.style;
226
+ return (React.createElement("div", { style: __assign({ height: 'calc(100% + 2 * var(--block-margin))', display: 'flex', alignItems: 'center' }, style), className: "colorize-on-hover colorize-on-menu", onClick: function (ev) {
227
+ ev.preventDefault();
228
+ toggleMenuModal();
229
+ }, onMouseEnter: openMenuModal, onMouseLeave: closeMenuModal, "aria-label": 'Ctrl\xa0+\xa0M' },
230
+ React.createElement("div", { id: "link-bg", style: {
231
+ position: 'absolute',
232
+ width: '100%',
233
+ height: 'calc(100% - var(--block-margin))',
234
+ left: 0,
235
+ top: 0,
236
+ } }),
237
+ React.createElement(MenuIcon, null),
238
+ "Docs"));
239
+ }
240
+ function MenuIcon() {
241
+ return (React.createElement("span", { style: { marginRight: 'calc(var(--icon-text-padding) + 2px)', lineHeight: 0, width: '1.3em' }, className: "decolorize-6" }, "\uD83D\uDCDA"));
242
+ }
243
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import '@docsearch/css';
3
+ export { Links };
4
+ declare function Links({ style }: {
5
+ style?: React.CSSProperties;
6
+ }): React.JSX.Element;
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,9 @@
1
+ export { MenuModal };
2
+ export { toggleMenuModal };
3
+ export { openMenuModal };
4
+ export { closeMenuModal };
5
+ import React from 'react';
6
+ declare function MenuModal(): React.JSX.Element;
7
+ declare function toggleMenuModal(): void;
8
+ declare function openMenuModal(): void;
9
+ declare function closeMenuModal(): void;