@brillout/docpress 0.7.10 → 0.8.1

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 (93) hide show
  1. package/+config.ts +2 -10
  2. package/Layout.tsx +397 -67
  3. package/{navigation/NavigationHeader.tsx → Links.tsx} +6 -57
  4. package/MenuModal.tsx +146 -0
  5. package/autoScrollNav.ts +4 -5
  6. package/components/CodeBlockTransformer.tsx +0 -2
  7. package/components/Note.css +4 -4
  8. package/components/Note.tsx +0 -2
  9. package/components/Supporters.tsx +1 -0
  10. package/config/resolveHeadingsData.ts +20 -23
  11. package/config/resolvePageContext.ts +11 -1
  12. package/css/code/block.css +5 -5
  13. package/css/code/inline.css +1 -1
  14. package/css/code.css +9 -5
  15. package/css/index.css +0 -4
  16. package/css/reset.css +0 -6
  17. package/dist/+config.d.ts +1 -13
  18. package/dist/+config.js +0 -3
  19. package/dist/components/CodeBlockTransformer.d.ts +1 -0
  20. package/dist/components/CodeBlockTransformer.js +1 -0
  21. package/dist/components/Note.d.ts +1 -0
  22. package/dist/components/Note.js +1 -0
  23. package/dist/components/Supporters.js +1 -0
  24. package/dist/config/resolveHeadingsData.d.ts +5 -8
  25. package/dist/config/resolveHeadingsData.js +20 -22
  26. package/dist/config/resolvePageContext.d.ts +5 -7
  27. package/dist/config/resolvePageContext.js +2 -1
  28. package/dist/navigation/Navigation.d.ts +12 -17
  29. package/dist/navigation/Navigation.js +82 -74
  30. package/dist/renderer/getStyleColumnLayout.d.ts +7 -0
  31. package/dist/renderer/getStyleColumnLayout.js +183 -0
  32. package/dist/types/Heading.d.ts +2 -4
  33. package/dist/utils/client.d.ts +1 -0
  34. package/dist/utils/client.js +1 -0
  35. package/dist/utils/css.d.ts +1 -0
  36. package/dist/utils/css.js +27 -0
  37. package/dist/utils/getGlobalObject.d.ts +1 -0
  38. package/dist/utils/getGlobalObject.js +9 -0
  39. package/docsearch/DocSearchInstall.tsx +23 -0
  40. package/docsearch/SearchLink.tsx +48 -0
  41. package/docsearch/toggleDocsearchModal.ts +29 -0
  42. package/global.d.ts +7 -0
  43. package/initKeyBindings.ts +41 -0
  44. package/installSectionUrlHashs.ts +6 -5
  45. package/navigation/Navigation.css +101 -3
  46. package/navigation/Navigation.tsx +114 -128
  47. package/package.json +1 -8
  48. package/renderer/getPageElement.tsx +19 -7
  49. package/renderer/getStyleColumnLayout.ts +204 -0
  50. package/renderer/onRenderClient.tsx +17 -24
  51. package/renderer/onRenderHtml.tsx +3 -6
  52. package/types/Heading.ts +2 -5
  53. package/utils/client.ts +1 -0
  54. package/utils/css.ts +26 -0
  55. package/utils/getGlobalObject.ts +11 -0
  56. package/Layout.css +0 -63
  57. package/MobileHeader.tsx +0 -70
  58. package/algolia/DocSearch.css +0 -28
  59. package/components/FeatureList/FeatureList.client.ts +0 -60
  60. package/components/FeatureList/FeatureList.css +0 -119
  61. package/components/FeatureList/FeatureList.tsx +0 -114
  62. package/components/FeatureList/chevron.svg +0 -7
  63. package/css/block-design.css +0 -4
  64. package/dist/autoScrollNav.d.ts +0 -3
  65. package/dist/autoScrollNav.js +0 -36
  66. package/dist/components/Algolia/Hit.d.ts +0 -4
  67. package/dist/components/Algolia/Hit.js +0 -30
  68. package/dist/components/Algolia/SelectIcon.d.ts +0 -2
  69. package/dist/components/Algolia/SelectIcon.js +0 -7
  70. package/dist/components/Algolia/Snippet.d.ts +0 -13
  71. package/dist/components/Algolia/Snippet.js +0 -37
  72. package/dist/components/Algolia/SourceIcon.d.ts +0 -4
  73. package/dist/components/Algolia/SourceIcon.js +0 -23
  74. package/dist/components/Algolia/types.d.ts +0 -79
  75. package/dist/components/Algolia/types.js +0 -1
  76. package/dist/navigation/NavigationHeader.d.ts +0 -8
  77. package/dist/navigation/NavigationHeader.js +0 -75
  78. package/dist/navigation/navigation-fullscreen/NavigationFullscreenButton.d.ts +0 -6
  79. package/dist/navigation/navigation-fullscreen/NavigationFullscreenButton.js +0 -23
  80. package/dist/navigation/navigation-fullscreen/hotkeyLabel.d.ts +0 -1
  81. package/dist/navigation/navigation-fullscreen/hotkeyLabel.js +0 -1
  82. package/navigation/Navigation-highlight.css +0 -41
  83. package/navigation/Navigation-items.css +0 -116
  84. package/navigation/Navigation-layout.css +0 -129
  85. package/navigation/initMobileNavigation.ts +0 -23
  86. package/navigation/initPressKit.ts +0 -19
  87. package/navigation/navigation-fullscreen/NavigationFullscreenButton.css +0 -32
  88. package/navigation/navigation-fullscreen/NavigationFullscreenButton.tsx +0 -47
  89. package/navigation/navigation-fullscreen/chevron.svg +0 -1
  90. package/navigation/navigation-fullscreen/close.svg +0 -4
  91. package/navigation/navigation-fullscreen/hotkeyLabel.ts +0 -1
  92. package/navigation/navigation-fullscreen/initNavigationFullscreen.ts +0 -60
  93. package/renderer/getCSSForResponsiveFullcreenNavItems.ts +0 -127
@@ -0,0 +1,204 @@
1
+ export { getStyleColumnLayout }
2
+ export { determineColumnLayoutEntries }
3
+
4
+ // There doens't seem to be as simpler way to have a column layout that uses the whole width real estate.
5
+ // - https://stackoverflow.com/questions/9683425/css-column-count-not-respected
6
+ // - https://stackoverflow.com/questions/25446921/get-flexbox-column-wrap-to-use-full-width-and-minimize-height
7
+ // - https://stackoverflow.com/questions/74873283/how-to-create-a-css-grid-with-3-columns-having-column-flow
8
+ // - https://stackoverflow.com/questions/50693793/3-columns-grid-top-to-bottom-using-grid-css
9
+ // - https://stackoverflow.com/questions/9119347/html-css-vertical-flow-layout-columnar-style-how-to-implement
10
+ // - https://stackoverflow.com/questions/27119691/how-to-start-a-new-column-in-flex-column-wrap-layout
11
+ // - https://stackoverflow.com/questions/45264354/is-it-possible-to-place-more-than-one-element-into-a-css-grid-cell-without-overl/49047281#49047281
12
+
13
+ import { type NavItemAll } from '../navigation/Navigation'
14
+ import { css } from '../utils/css'
15
+ import { assert, assertUsage, isBrowser } from '../utils/server'
16
+ assert(!isBrowser())
17
+ const columnWidthMin = 300
18
+ const columnWidthMax = 350
19
+
20
+ type NavItemWithLength = NavItemAll & { numberOfHeadings: number | null }
21
+ function determineColumnLayoutEntries(navItems: NavItemAll[]): { columnLayouts: number[][] } {
22
+ const navItemsWithLength: NavItemWithLength[] = navItems.map((navItem) => ({
23
+ ...navItem,
24
+ numberOfHeadings: navItem.level === 1 || navItem.level === 4 ? 0 : null,
25
+ }))
26
+ let navItemLevel1: NavItemWithLength | undefined
27
+ let navItemLevel4: NavItemWithLength | undefined
28
+ navItemsWithLength.forEach((navItem) => {
29
+ if (navItem.level === 1) {
30
+ navItemLevel1 = navItem
31
+ navItemLevel4 = undefined
32
+ return
33
+ }
34
+ if (navItem.level === 4) {
35
+ navItemLevel4 = navItem
36
+ return
37
+ }
38
+ const bumpNavItemLength = (navItem: NavItemWithLength) => {
39
+ assert(navItem.numberOfHeadings !== null)
40
+ navItem.numberOfHeadings++
41
+ }
42
+ assert(navItemLevel1)
43
+ bumpNavItemLength(navItemLevel1)
44
+ if (navItemLevel4) {
45
+ bumpNavItemLength(navItemLevel4)
46
+ }
47
+ })
48
+
49
+ const columnLayouts: number[][] = []
50
+ let columns: number[] = []
51
+ let isFullWidth: boolean | undefined
52
+ navItemsWithLength.forEach((navItem, i) => {
53
+ let isFullWidthBegin = false
54
+ if (navItem.level === 1) {
55
+ const isFullWidthPrevious = isFullWidth
56
+ isFullWidth = !!navItem.menuModalFullWidth
57
+ if (isFullWidth) isFullWidthBegin = true
58
+ if (isFullWidthPrevious !== undefined && isFullWidthPrevious !== isFullWidth) {
59
+ columnLayouts.push(columns)
60
+ columns = []
61
+ }
62
+ }
63
+ const navItemPrevious = navItemsWithLength[i - 1]
64
+ const navItemNext = navItemsWithLength[i + 1]
65
+ if (
66
+ !isFullWidth ? navItem.level === 1 : (navItem.level === 4 && navItemPrevious!.level !== 1) || isFullWidthBegin
67
+ ) {
68
+ if (isFullWidth) {
69
+ assert(navItem.level === 4 || (navItem.level === 1 && isFullWidthBegin))
70
+ } else {
71
+ assert(navItem.level === 1)
72
+ }
73
+ let { numberOfHeadings } = navItem
74
+ assert(numberOfHeadings !== null)
75
+ if (isFullWidthBegin) {
76
+ assert(navItem.level === 1)
77
+ assertUsage(
78
+ navItemNext && navItemNext.level === 4,
79
+ // We can lift this requirement, but it isn't trivial to implement.
80
+ 'level-1 headings with menuModalFullWidth need to be followed by a level-4 heading',
81
+ )
82
+ assert(navItemNext.numberOfHeadings)
83
+ numberOfHeadings = navItemNext.numberOfHeadings
84
+ }
85
+ columns.push(numberOfHeadings)
86
+ navItems[i].isColumnLayoutElement = true
87
+ }
88
+ })
89
+ columnLayouts.push(columns)
90
+
91
+ return { columnLayouts }
92
+ }
93
+
94
+ function getStyleColumnLayout(columnLayouts: number[][]): string {
95
+ let style = '\n'
96
+ columnLayouts.forEach((columns, i) => {
97
+ for (let numberOfColumns = columns.length; numberOfColumns >= 1; numberOfColumns--) {
98
+ let styleGivenNumberOfColumns: string[] = []
99
+ styleGivenNumberOfColumns.push(
100
+ css`
101
+ .column-layout-${i} {
102
+ column-count: ${numberOfColumns};
103
+ max-width: min(100%, ${columnWidthMax * numberOfColumns}px);
104
+ }
105
+ `,
106
+ )
107
+ const columnsIdMap = determineColumns(columns, numberOfColumns)
108
+ const columnBreakPoints = determineColumnBreakPoints(columnsIdMap)
109
+ columnBreakPoints.forEach((columnBreakPoint, columnUngroupedId) => {
110
+ styleGivenNumberOfColumns.push(
111
+ css`
112
+ .column-layout-${i} .column-layout-entry:nth-child(${columnUngroupedId + 1}) {
113
+ break-before: ${columnBreakPoint ? 'column' : 'avoid'};
114
+ }
115
+ `,
116
+ )
117
+ })
118
+ const noContainerQuery = numberOfColumns === columns.length
119
+ if (!noContainerQuery) {
120
+ const maxWidth = (numberOfColumns + 1) * columnWidthMin - 1
121
+ styleGivenNumberOfColumns = [
122
+ //
123
+ `@container(max-width: ${maxWidth}px) {`,
124
+ ...styleGivenNumberOfColumns,
125
+ `}`,
126
+ ]
127
+ }
128
+ style += styleGivenNumberOfColumns.join('\n') + '\n'
129
+ }
130
+ })
131
+ return style
132
+ }
133
+
134
+ function determineColumnBreakPoints(columnsIdMap: number[]): boolean[] {
135
+ assert(columnsIdMap[0] === 0)
136
+ let columnGroupedIdBefore = -1
137
+ const columnBreakPoints = columnsIdMap.map((columnGroupedId) => {
138
+ assert(
139
+ [
140
+ //
141
+ columnGroupedIdBefore,
142
+ columnGroupedIdBefore + 1,
143
+ ].includes(columnGroupedId),
144
+ )
145
+ const val = columnGroupedId !== columnGroupedIdBefore
146
+ columnGroupedIdBefore = columnGroupedId
147
+ return val
148
+ })
149
+ return columnBreakPoints
150
+ }
151
+
152
+ function determineColumns(columnsUnmerged: number[], numberOfColumns: number): number[] {
153
+ assert(numberOfColumns <= columnsUnmerged.length)
154
+ const columnsMergingInit: ColumnMerging[] = columnsUnmerged.map((columnHeight, i) => ({
155
+ columnIdsMerged: [i],
156
+ heightTotal: columnHeight,
157
+ }))
158
+ const columnsMerged = mergeColumns(columnsMergingInit, numberOfColumns)
159
+ const columnsIdMap: number[] = new Array(columnsUnmerged.length)
160
+ assert(columnsMerged.length === numberOfColumns)
161
+ columnsMerged.forEach((columnMerged, columnMergedId) => {
162
+ columnMerged.columnIdsMerged.forEach((columnId) => {
163
+ columnsIdMap[columnId] = columnMergedId
164
+ })
165
+ })
166
+ assert(columnsIdMap.length === columnsUnmerged.length)
167
+
168
+ return columnsIdMap
169
+ }
170
+ type ColumnMerging = { columnIdsMerged: number[]; heightTotal: number }
171
+ function mergeColumns(columnsMerging: ColumnMerging[], numberOfColumns: number): ColumnMerging[] {
172
+ if (columnsMerging.length <= numberOfColumns) return columnsMerging
173
+
174
+ let mergeCandidate: null | (ColumnMerging & { i: number }) = null
175
+ for (let i = 0; i <= columnsMerging.length - 2; i++) {
176
+ const column1 = columnsMerging[i + 0]
177
+ const column2 = columnsMerging[i + 1]
178
+ const heightTotal = column1.heightTotal + column2.heightTotal
179
+ if (!mergeCandidate || mergeCandidate.heightTotal > heightTotal) {
180
+ mergeCandidate = {
181
+ i,
182
+ columnIdsMerged: [
183
+ //
184
+ ...column1.columnIdsMerged,
185
+ ...column2.columnIdsMerged,
186
+ ],
187
+ heightTotal,
188
+ }
189
+ }
190
+ }
191
+ assert(mergeCandidate)
192
+
193
+ const { i } = mergeCandidate
194
+ assert(-1 < i && i < columnsMerging.length - 1)
195
+ const columnsMergingMod = [
196
+ //
197
+ ...columnsMerging.slice(0, i),
198
+ mergeCandidate,
199
+ ...columnsMerging.slice(i + 2),
200
+ ]
201
+
202
+ assert(columnsMergingMod.length === columnsMerging.length - 1)
203
+ return mergeColumns(columnsMergingMod, numberOfColumns)
204
+ }
@@ -5,41 +5,39 @@ import type { PageContextClient } from 'vike/types'
5
5
  import ReactDOM from 'react-dom/client'
6
6
  import { PageContextResolved } from '../config/resolvePageContext'
7
7
  import { getPageElement } from './getPageElement'
8
- import {
9
- hideNavigationFullScreen,
10
- initNavigationFullscreen,
11
- initNavigationFullscreenOnce,
12
- } from '../navigation/navigation-fullscreen/initNavigationFullscreen'
13
- import { hideMobileNavigation, initMobileNavigation } from '../navigation/initMobileNavigation'
14
- import { initPressKit } from '../navigation/initPressKit'
8
+ import { closeMenuModal } from '../MenuModal'
15
9
  import '../css/index.css'
16
10
  import { autoScrollNav } from '../autoScrollNav'
17
11
  import { installSectionUrlHashs } from '../installSectionUrlHashs'
18
- import { addFeatureClickHandlers, addTwitterWidgets } from '../components/FeatureList/FeatureList.client'
12
+ import { getGlobalObject } from '../utils/client'
13
+ import { initKeyBindings } from '../initKeyBindings'
14
+
15
+ const globalObject = getGlobalObject<{
16
+ root?: ReactDOM.Root
17
+ renderPromiseResolve?: () => void
18
+ }>('onRenderClient.ts', {})
19
19
 
20
20
  addEcosystemStamp()
21
- initNavigationFullscreenOnce()
21
+ initKeyBindings()
22
22
 
23
- let root: ReactDOM.Root
24
- let renderPromiseResolve: () => void
25
23
  async function onRenderClient(pageContext: PageContextClient) {
26
24
  onRenderStart()
27
25
 
28
26
  // TODO: stop using any
29
27
  const pageContextResolved: PageContextResolved = (pageContext as any).pageContextResolved
30
28
  const renderPromise = new Promise<void>((r) => {
31
- renderPromiseResolve = r
29
+ globalObject.renderPromiseResolve = r
32
30
  })
33
31
  let page = getPageElement(pageContext, pageContextResolved)
34
32
  page = <OnRenderDoneHook>{page}</OnRenderDoneHook>
35
33
  const container = document.getElementById('page-view')!
36
34
  if (pageContext.isHydration) {
37
- root = ReactDOM.hydrateRoot(container, page)
35
+ globalObject.root = ReactDOM.hydrateRoot(container, page)
38
36
  } else {
39
- if (!root) {
40
- root = ReactDOM.createRoot(container)
37
+ if (!globalObject.root) {
38
+ globalObject.root = ReactDOM.createRoot(container)
41
39
  }
42
- root.render(page)
40
+ globalObject.root.render(page)
43
41
  }
44
42
  if (!pageContext.isHydration) {
45
43
  applyHead(pageContext)
@@ -54,20 +52,15 @@ function applyHead(pageContext: PageContextClient) {
54
52
  }
55
53
 
56
54
  function onRenderStart() {
57
- hideMobileNavigation()
58
- hideNavigationFullScreen()
55
+ closeMenuModal()
59
56
  }
60
57
 
61
58
  function onRenderDone() {
62
59
  autoScrollNav()
60
+ // TODO/refactor: use React?
63
61
  installSectionUrlHashs()
64
- initNavigationFullscreen()
65
- initMobileNavigation()
66
- initPressKit()
67
- addFeatureClickHandlers()
68
- addTwitterWidgets()
69
62
  setHydrationIsFinished()
70
- renderPromiseResolve()
63
+ globalObject.renderPromiseResolve!()
71
64
  }
72
65
 
73
66
  function OnRenderDoneHook({ children }: { children: React.ReactNode }) {
@@ -6,8 +6,7 @@ import { assert } from '../utils/server'
6
6
  import type { PageContextResolved } from '../config/resolvePageContext'
7
7
  import { getPageElement } from './getPageElement'
8
8
  import type { OnRenderHtmlAsync } from 'vike/types'
9
- import { groupByLevelMin } from '../navigation/Navigation'
10
- import { getCSSForResponsiveFullcreenNavItems } from './getCSSForResponsiveFullcreenNavItems'
9
+ import { getStyleColumnLayout } from './getStyleColumnLayout'
11
10
 
12
11
  const onRenderHtml: OnRenderHtmlAsync = async (
13
12
  pageContext,
@@ -17,9 +16,7 @@ Promise<Awaited<ReturnType<OnRenderHtmlAsync>>> => {
17
16
 
18
17
  const page = getPageElement(pageContext, pageContextResolved)
19
18
 
20
- const { navItemsAll } = pageContextResolved.navigationData
21
- const navItemsGrouped = groupByLevelMin(navItemsAll)
22
- const CSSResponsiveNavItems = getCSSForResponsiveFullcreenNavItems(navItemsGrouped)
19
+ const styleMenuModalLayout = getStyleColumnLayout(pageContextResolved.columnLayouts)
23
20
 
24
21
  const descriptionTag = pageContextResolved.isLandingPage
25
22
  ? dangerouslySkipEscape(`<meta name="description" content="${pageContextResolved.meta.tagline}" />`)
@@ -36,7 +33,7 @@ Promise<Awaited<ReturnType<OnRenderHtmlAsync>>> => {
36
33
  ${descriptionTag}
37
34
  <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
38
35
  ${getOpenGraphTags(pageContext.urlPathname, pageContextResolved.documentTitle, pageContextResolved.meta)}
39
- <style>${dangerouslySkipEscape(CSSResponsiveNavItems)}</style>
36
+ <style>${dangerouslySkipEscape(styleMenuModalLayout)}</style>
40
37
  </head>
41
38
  <body>
42
39
  <div id="page-view">${dangerouslySkipEscape(pageHtml)}</div>
package/types/Heading.ts CHANGED
@@ -8,10 +8,10 @@ type HeadingResolved = {
8
8
  level: number
9
9
  title: string
10
10
  titleInNav: string
11
- noSideNavigation?: NoSideNavigation
12
11
  topNavigation?: true | string
13
12
  linkBreadcrumb: string[]
14
13
  sectionTitles?: string[]
14
+ menuModalFullWidth?: true
15
15
  } & Tmp
16
16
 
17
17
  type HeadingDetachedResolved = Omit<HeadingResolved, 'level' | 'linkBreadcrumb'> & {
@@ -22,6 +22,7 @@ type HeadingDetachedResolved = Omit<HeadingResolved, 'level' | 'linkBreadcrumb'>
22
22
  type HeadingDefinitionCommon = {
23
23
  title: string
24
24
  topNavigation?: true | string
25
+ menuModalFullWidth?: true
25
26
  }
26
27
 
27
28
  type HeadingDetachedDefinition = HeadingDefinitionCommon & {
@@ -32,14 +33,12 @@ type HeadingDetachedDefinition = HeadingDefinitionCommon & {
32
33
  type HeadingDefinition = HeadingDefinitionCommon & {
33
34
  url?: null | string
34
35
  titleInNav?: string
35
- noSideNavigation?: NoSideNavigation
36
36
  } & HeadingDefinitionLevel &
37
37
  Tmp
38
38
  type IsCategory = {
39
39
  url?: undefined
40
40
  titleDocument?: undefined
41
41
  titleInNav?: undefined
42
- noSideNavigation?: undefined
43
42
  }
44
43
  type HeadingDefinitionLevel =
45
44
  | ({ level: 1 } & IsCategory)
@@ -54,5 +53,3 @@ type Tmp = {
54
53
  // TODO: remove? Both Vike and Telefunc set it to the same value than docpress.config.js#projectInfo.projectName
55
54
  titleDocument?: string
56
55
  }
57
-
58
- type NoSideNavigation = true | 'no-logo'
package/utils/client.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './assert'
2
2
  export * from './isBrowser'
3
+ export * from './getGlobalObject'
package/utils/css.ts ADDED
@@ -0,0 +1,26 @@
1
+ export function css(strings: TemplateStringsArray | string[], ...values: (string | number)[]): string {
2
+ // The boring part
3
+ let result = strings
4
+ .map((str, i) => {
5
+ let s = str
6
+ if (i !== strings.length - 1) {
7
+ s += values[i]
8
+ }
9
+ return s
10
+ })
11
+ .join('')
12
+
13
+ // Remove comments
14
+ result = result
15
+ .split('\n')
16
+ .filter((line) => !line.startsWith('// '))
17
+ .join('\n')
18
+
19
+ // Minifiy
20
+ result = result
21
+ .replace(/\s+/g, ' ') // Replace all whitespace sequences with a single space
22
+ .replace(/\s*([{}:;])\s*/g, '$1') // Remove space around {, }, :, ;
23
+ .trim() // Trim any leading/trailing whitespace
24
+
25
+ return result
26
+ }
@@ -0,0 +1,11 @@
1
+ export function getGlobalObject<T extends Record<string, unknown> = never>(
2
+ // We use the filename as key; each `getGlobalObject()` call should live inside a file with a unique filename.
3
+ key: `${string}.ts`,
4
+ defaultValue: T,
5
+ ): T {
6
+ // @ts-ignore
7
+ const globalObjectsAll = (globalThis[projectKey] = globalThis[projectKey] || {})
8
+ const globalObject = (globalObjectsAll[key] = globalObjectsAll[key] || defaultValue)
9
+ return globalObject
10
+ }
11
+ const projectKey = '_docpress'
package/Layout.css DELETED
@@ -1,63 +0,0 @@
1
- .doc-page .page-container {
2
- padding-bottom: 100px;
3
- }
4
-
5
- .page-layout {
6
- display: flex;
7
- justify-content: center;
8
- width: 100%;
9
- }
10
- .page-layout > #navigation-wrapper,
11
- .page-layout > .page-wrapper {
12
- flex-grow: 1;
13
- }
14
- /* Avoid overflow, see https://stackoverflow.com/questions/36230944/prevent-flex-items-from-overflowing-a-container/66689926#66689926 */
15
- .page-layout > .page-wrapper {
16
- min-width: 0;
17
- }
18
-
19
- .doc-page .page-wrapper {
20
- --main-view-max-width: 800px;
21
- }
22
- .landing-page .page-wrapper {
23
- --main-view-max-width: 1010px;
24
- }
25
- .page-layout:not(.noSideNavigation) .page-wrapper {
26
- max-width: calc(var(--main-view-max-width) + 80px);
27
- }
28
- .page-layout:not(.noSideNavigation) .page-content {
29
- box-sizing: content-box;
30
- max-width: var(--main-view-max-width);
31
- padding: 20px var(--main-view-padding);
32
- margin: auto;
33
- }
34
-
35
- .page-content {
36
- --main-view-padding: 20px;
37
- }
38
- @media screen and (max-width: 1139px) {
39
- .page-content {
40
- --main-view-padding: 10px;
41
- }
42
- }
43
-
44
-
45
- /* === noSideNavigation === */
46
- .page-layout:not(.noSideNavigation) #top-navigation {
47
- display: none !important;
48
- }
49
- @media screen and (max-width: 1139px) {
50
- #top-navigation {
51
- display: none !important;
52
- }
53
- }
54
- @media screen and (min-width: 1140px) {
55
- html:not(.navigation-fullscreen) .page-layout.noSideNavigation #navigation-wrapper,
56
- html:not(.navigation-fullscreen) .page-layout.noSideNavigation #navigation-fullscreen-button {
57
- display: none !important;
58
- }
59
- .noSideNavigation .page-wrapper {
60
- /* Maybe we can remove this after we remove the vertical fullscreen navigation toggler? */
61
- margin-left: 0 !important;
62
- }
63
- }
package/MobileHeader.tsx DELETED
@@ -1,70 +0,0 @@
1
- import React from 'react'
2
- import { usePageContext, usePageContext2 } from './renderer/usePageContext'
3
-
4
- export { MobileHeader }
5
-
6
- function MobileHeader() {
7
- const pageContext = usePageContext()
8
- const pageContext2 = usePageContext2()
9
- const { NavHeaderMobile } = pageContext2.config.NavHeader!
10
- return (
11
- <div
12
- id="mobile-header"
13
- style={{
14
- height: 'var(--mobile-header-height)',
15
- width: '100%',
16
- position: 'relative',
17
- }}
18
- >
19
- <div
20
- style={{
21
- position: 'fixed',
22
- display: 'flex',
23
- alignItems: 'center',
24
- background: 'white',
25
- zIndex: 99,
26
- top: 0,
27
- left: 0,
28
- height: 'var(--mobile-header-height)',
29
- width: '100%',
30
- borderBottom: '1px solid #ddd',
31
- }}
32
- >
33
- <MobileShowNavigationToggle />
34
- <a
35
- href="/"
36
- style={{
37
- color: 'inherit',
38
- display: 'flex',
39
- alignItems: 'center',
40
- justifyContent: 'left',
41
- textDecoration: 'none',
42
- ...pageContext2.config.NavHeader?.navHeaderMobileWrapperStyle,
43
- }}
44
- >
45
- <NavHeaderMobile />
46
- </a>
47
- </div>
48
- </div>
49
- )
50
- }
51
-
52
- function MobileShowNavigationToggle() {
53
- return (
54
- <div style={{ padding: 20, lineHeight: 0, cursor: 'pointer' }} id="mobile-show-navigation-toggle">
55
- <svg
56
- style={{ width: 20 }}
57
- className="icon"
58
- xmlns="http://www.w3.org/2000/svg"
59
- aria-hidden="true"
60
- role="img"
61
- viewBox="0 0 448 512"
62
- >
63
- <path
64
- fill="currentColor"
65
- 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"
66
- ></path>
67
- </svg>
68
- </div>
69
- )
70
- }
@@ -1,28 +0,0 @@
1
- .DocSearch-Button-Keys {
2
- margin-left: 6px !important;
3
- }
4
- .DocSearch-Search-Icon {
5
- margin-right: 0 !important;
6
- }
7
- .DocSearch-Button-Placeholder {
8
- padding-right: 6px !important;
9
- }
10
-
11
- .DocSearch-Button-Placeholder,
12
- .DocSearch-Button-Keys {
13
- display: none !important;
14
- }
15
- .DocSearch-Button {
16
- background: transparent !important;
17
- padding: 5px !important;
18
- outline: none !important;
19
- border: none !important;
20
- box-shadow: none !important;
21
- }
22
- .DocSearch-Search-Icon {
23
- height: 21px !important;
24
- width: 21px !important;
25
- }
26
- .DocSearch-Button {
27
- margin: 0 !important;
28
- }
@@ -1,60 +0,0 @@
1
- export { addTwitterWidgets }
2
- export { addFeatureClickHandlers }
3
-
4
- import { assert } from '../../utils/client'
5
-
6
- function addTwitterWidgets() {
7
- loadScript('https://platform.twitter.com/widgets.js')
8
- }
9
-
10
- function addFeatureClickHandlers() {
11
- const featuresEl = document.getElementById('features')
12
- if (!featuresEl) return
13
- const featureEls: HTMLElement[] = Array.from(featuresEl.querySelectorAll('.feature.has-learn-more'))
14
- featureEls.forEach((featureEl) => {
15
- featureEl.onclick = () => {
16
- expandLearnMore(featureEl)
17
- }
18
- })
19
- }
20
-
21
- function expandLearnMore(featureEl: HTMLElement) {
22
- const featureId = featureEl.id
23
- assert(featureId.startsWith('feature-'), { featureId })
24
- const featureName = featureId.slice('feature-'.length)
25
-
26
- const selectedClass = 'selected'
27
- const learnId = 'learn-more-' + featureName
28
- const learnEl = document.getElementById(learnId)
29
- assert(learnEl, { learnId })
30
-
31
- const isExpanded = featureEl.classList.contains(selectedClass)
32
-
33
- if (!isExpanded) {
34
- const rowEl = featureEl.parentNode as HTMLElement
35
- if (getComputedStyle(rowEl, 'display') === 'grid') {
36
- ;[
37
- ...(rowEl.querySelectorAll('.learn-more') as any as HTMLElement[]),
38
- ...(rowEl.querySelectorAll('.feature') as any as HTMLElement[]),
39
- ].forEach((el) => {
40
- el.classList.remove(selectedClass)
41
- })
42
- }
43
- }
44
- ;[featureEl, learnEl].forEach((el) => {
45
- el.classList.toggle(selectedClass)
46
- })
47
- }
48
-
49
- function loadScript(scriptUrl: string): void {
50
- assert(scriptUrl.startsWith('https://'))
51
- const scriptEl = document.createElement('script')
52
- scriptEl.src = scriptUrl
53
- scriptEl.async = true
54
- scriptEl.setAttribute('charset', 'utf-8')
55
- document.getElementsByTagName('head')[0].appendChild(scriptEl)
56
- }
57
-
58
- function getComputedStyle(el: HTMLElement, styleProp: string) {
59
- return window.document.defaultView!.getComputedStyle(el).getPropertyValue(styleProp)
60
- }