@brillout/docpress 0.7.9 → 0.7.10-commit-776b1fc

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 -11
  29. package/dist/navigation/Navigation.js +75 -73
  30. package/dist/renderer/getStyleColumnLayout.d.ts +7 -0
  31. package/dist/renderer/getStyleColumnLayout.js +167 -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/closeDocsearchModal.ts +29 -0
  42. package/initKeyBindings.ts +41 -0
  43. package/installSectionUrlHashs.ts +6 -5
  44. package/navigation/Navigation.css +101 -3
  45. package/navigation/Navigation.tsx +109 -124
  46. package/package.json +1 -8
  47. package/renderer/getPageContextCurrent.ts +16 -0
  48. package/renderer/getPageElement.tsx +19 -7
  49. package/renderer/getStyleColumnLayout.ts +187 -0
  50. package/renderer/onRenderClient.tsx +20 -24
  51. package/renderer/onRenderHtml.tsx +4 -0
  52. package/types/Heading.ts +2 -5
  53. package/types.d.ts +8 -0
  54. package/utils/client.ts +1 -0
  55. package/utils/css.ts +26 -0
  56. package/utils/getGlobalObject.ts +11 -0
  57. package/Layout.css +0 -63
  58. package/MobileHeader.tsx +0 -70
  59. package/algolia/DocSearch.css +0 -28
  60. package/components/FeatureList/FeatureList.client.ts +0 -60
  61. package/components/FeatureList/FeatureList.css +0 -119
  62. package/components/FeatureList/FeatureList.tsx +0 -114
  63. package/components/FeatureList/chevron.svg +0 -7
  64. package/css/block-design.css +0 -4
  65. package/dist/autoScrollNav.d.ts +0 -3
  66. package/dist/autoScrollNav.js +0 -36
  67. package/dist/components/Algolia/Hit.d.ts +0 -4
  68. package/dist/components/Algolia/Hit.js +0 -30
  69. package/dist/components/Algolia/SelectIcon.d.ts +0 -2
  70. package/dist/components/Algolia/SelectIcon.js +0 -7
  71. package/dist/components/Algolia/Snippet.d.ts +0 -13
  72. package/dist/components/Algolia/Snippet.js +0 -37
  73. package/dist/components/Algolia/SourceIcon.d.ts +0 -4
  74. package/dist/components/Algolia/SourceIcon.js +0 -23
  75. package/dist/components/Algolia/types.d.ts +0 -79
  76. package/dist/components/Algolia/types.js +0 -1
  77. package/dist/navigation/NavigationHeader.d.ts +0 -8
  78. package/dist/navigation/NavigationHeader.js +0 -75
  79. package/dist/navigation/navigation-fullscreen/NavigationFullscreenButton.d.ts +0 -6
  80. package/dist/navigation/navigation-fullscreen/NavigationFullscreenButton.js +0 -23
  81. package/dist/navigation/navigation-fullscreen/hotkeyLabel.d.ts +0 -1
  82. package/dist/navigation/navigation-fullscreen/hotkeyLabel.js +0 -1
  83. package/navigation/Navigation-highlight.css +0 -41
  84. package/navigation/Navigation-items.css +0 -119
  85. package/navigation/Navigation-layout.css +0 -127
  86. package/navigation/initMobileNavigation.ts +0 -23
  87. package/navigation/initPressKit.ts +0 -19
  88. package/navigation/navigation-fullscreen/NavigationFullscreenButton.css +0 -32
  89. package/navigation/navigation-fullscreen/NavigationFullscreenButton.tsx +0 -47
  90. package/navigation/navigation-fullscreen/chevron.svg +0 -1
  91. package/navigation/navigation-fullscreen/close.svg +0 -4
  92. package/navigation/navigation-fullscreen/hotkeyLabel.ts +0 -1
  93. package/navigation/navigation-fullscreen/initNavigationFullscreen.ts +0 -147
@@ -0,0 +1,187 @@
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, 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[]) {
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
+ return
32
+ }
33
+ if (navItem.level === 4) {
34
+ navItemLevel4 = navItem
35
+ return
36
+ }
37
+ const bumpNavItemLength = (navItem: NavItemWithLength) => {
38
+ assert(navItem.numberOfHeadings !== null && navItem.numberOfHeadings >= 0)
39
+ navItem.numberOfHeadings++
40
+ }
41
+ assert(navItemLevel1)
42
+ bumpNavItemLength(navItemLevel1)
43
+ if (navItemLevel4) {
44
+ bumpNavItemLength(navItemLevel4)
45
+ }
46
+ })
47
+
48
+ const columnLayouts: number[][] = []
49
+ let columns: number[] = []
50
+ let isFullWidth: boolean | undefined
51
+ navItemsWithLength.forEach((navItem, i) => {
52
+ let isFullWidthBegin = false
53
+ if (navItem.level === 1) {
54
+ const isFullWidthPrevious = isFullWidth
55
+ isFullWidth = !!navItem.menuModalFullWidth
56
+ if (isFullWidth) isFullWidthBegin = true
57
+ if (isFullWidthPrevious !== undefined && isFullWidthPrevious !== isFullWidth) {
58
+ columnLayouts.push(columns)
59
+ columns = []
60
+ }
61
+ }
62
+ if (
63
+ (!isFullWidth && navItem.level === 1) ||
64
+ (isFullWidth && navItem.level === 4 && navItemsWithLength[i - 1]!.level !== 1) ||
65
+ isFullWidthBegin
66
+ ) {
67
+ assert(navItem.numberOfHeadings !== null)
68
+ columns.push(navItem.numberOfHeadings)
69
+ navItems[i].columnLayoutEntry = true
70
+ }
71
+ })
72
+ columnLayouts.push(columns)
73
+
74
+ return { columnLayouts }
75
+ }
76
+
77
+ function getStyleColumnLayout(columnLayouts: number[][]): string {
78
+ let style = '\n'
79
+ columnLayouts.forEach((columns, i) => {
80
+ for (let numberOfColumns = columns.length; numberOfColumns >= 1; numberOfColumns--) {
81
+ let styleGivenNumberOfColumns: string[] = []
82
+ styleGivenNumberOfColumns.push(
83
+ css`
84
+ .column-layout-${i} {
85
+ column-count: ${numberOfColumns};
86
+ max-width: min(100%, ${columnWidthMax * numberOfColumns}px);
87
+ }
88
+ `,
89
+ )
90
+ const columnsIdMap = determineColumns(columns, numberOfColumns)
91
+ const columnBreakPoints = determineColumnBreakPoints(columnsIdMap)
92
+ columnBreakPoints.forEach((columnBreakPoint, columnUngroupedId) => {
93
+ styleGivenNumberOfColumns.push(
94
+ css`
95
+ .column-layout-entry:nth-child(${columnUngroupedId + 1}) {
96
+ break-before: ${columnBreakPoint ? 'column' : 'avoid'};
97
+ }
98
+ `,
99
+ )
100
+ })
101
+ const noContainerQuery = numberOfColumns === columns.length
102
+ if (!noContainerQuery) {
103
+ const maxWidth = (numberOfColumns + 1) * columnWidthMin - 1
104
+ styleGivenNumberOfColumns = [
105
+ //
106
+ `@container(max-width: ${maxWidth}px) {`,
107
+ ...styleGivenNumberOfColumns,
108
+ `}`,
109
+ ]
110
+ }
111
+ style += styleGivenNumberOfColumns.join('\n') + '\n'
112
+ }
113
+ })
114
+ return style
115
+ }
116
+
117
+ function determineColumnBreakPoints(columnsIdMap: number[]): boolean[] {
118
+ assert(columnsIdMap[0] === 0)
119
+ let columnGroupedIdBefore = -1
120
+ const columnBreakPoints = columnsIdMap.map((columnGroupedId) => {
121
+ assert(
122
+ [
123
+ //
124
+ columnGroupedIdBefore,
125
+ columnGroupedIdBefore + 1,
126
+ ].includes(columnGroupedId),
127
+ )
128
+ const val = columnGroupedId !== columnGroupedIdBefore
129
+ columnGroupedIdBefore = columnGroupedId
130
+ return val
131
+ })
132
+ return columnBreakPoints
133
+ }
134
+
135
+ function determineColumns(columnsUnmerged: number[], numberOfColumns: number): number[] {
136
+ assert(numberOfColumns <= columnsUnmerged.length)
137
+ const columnsMergingInit: ColumnMerging[] = columnsUnmerged.map((columnHeight, i) => ({
138
+ columnIdsMerged: [i],
139
+ heightTotal: columnHeight,
140
+ }))
141
+ const columnsMerged = mergeColumns(columnsMergingInit, numberOfColumns)
142
+ const columnsIdMap: number[] = new Array(columnsUnmerged.length)
143
+ assert(columnsMerged.length === numberOfColumns)
144
+ columnsMerged.forEach((columnMerged, columnMergedId) => {
145
+ columnMerged.columnIdsMerged.forEach((columnId) => {
146
+ columnsIdMap[columnId] = columnMergedId
147
+ })
148
+ })
149
+ assert(columnsIdMap.length === columnsUnmerged.length)
150
+
151
+ return columnsIdMap
152
+ }
153
+ type ColumnMerging = { columnIdsMerged: number[]; heightTotal: number }
154
+ function mergeColumns(columnsMerging: ColumnMerging[], numberOfColumns: number): ColumnMerging[] {
155
+ if (columnsMerging.length <= numberOfColumns) return columnsMerging
156
+
157
+ let mergeCandidate: null | (ColumnMerging & { i: number }) = null
158
+ for (let i = 0; i <= columnsMerging.length - 2; i++) {
159
+ const column1 = columnsMerging[i + 0]
160
+ const column2 = columnsMerging[i + 1]
161
+ const heightTotal = column1.heightTotal + column2.heightTotal
162
+ if (!mergeCandidate || mergeCandidate.heightTotal > heightTotal) {
163
+ mergeCandidate = {
164
+ i,
165
+ columnIdsMerged: [
166
+ //
167
+ ...column1.columnIdsMerged,
168
+ ...column2.columnIdsMerged,
169
+ ],
170
+ heightTotal,
171
+ }
172
+ }
173
+ }
174
+ assert(mergeCandidate)
175
+
176
+ const { i } = mergeCandidate
177
+ assert(-1 < i && i < columnsMerging.length - 1)
178
+ const columnsMergingMod = [
179
+ //
180
+ ...columnsMerging.slice(0, i),
181
+ mergeCandidate,
182
+ ...columnsMerging.slice(i + 2),
183
+ ]
184
+
185
+ assert(columnsMergingMod.length === columnsMerging.length - 1)
186
+ return mergeColumns(columnsMergingMod, numberOfColumns)
187
+ }
@@ -5,41 +5,42 @@ 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 { setpageContextCurrent } from './getPageContextCurrent'
14
+ import { initKeyBindings } from '../initKeyBindings'
15
+
16
+ const globalObject = getGlobalObject<{
17
+ root?: ReactDOM.Root
18
+ renderPromiseResolve?: () => void
19
+ }>('onRenderClient.ts', {})
19
20
 
20
21
  addEcosystemStamp()
21
- initNavigationFullscreenOnce()
22
+ initKeyBindings()
22
23
 
23
- let root: ReactDOM.Root
24
- let renderPromiseResolve: () => void
25
24
  async function onRenderClient(pageContext: PageContextClient) {
25
+ setpageContextCurrent(pageContext)
26
+
26
27
  onRenderStart()
27
28
 
28
29
  // TODO: stop using any
29
30
  const pageContextResolved: PageContextResolved = (pageContext as any).pageContextResolved
30
31
  const renderPromise = new Promise<void>((r) => {
31
- renderPromiseResolve = r
32
+ globalObject.renderPromiseResolve = r
32
33
  })
33
34
  let page = getPageElement(pageContext, pageContextResolved)
34
35
  page = <OnRenderDoneHook>{page}</OnRenderDoneHook>
35
36
  const container = document.getElementById('page-view')!
36
37
  if (pageContext.isHydration) {
37
- root = ReactDOM.hydrateRoot(container, page)
38
+ globalObject.root = ReactDOM.hydrateRoot(container, page)
38
39
  } else {
39
- if (!root) {
40
- root = ReactDOM.createRoot(container)
40
+ if (!globalObject.root) {
41
+ globalObject.root = ReactDOM.createRoot(container)
41
42
  }
42
- root.render(page)
43
+ globalObject.root.render(page)
43
44
  }
44
45
  if (!pageContext.isHydration) {
45
46
  applyHead(pageContext)
@@ -54,20 +55,15 @@ function applyHead(pageContext: PageContextClient) {
54
55
  }
55
56
 
56
57
  function onRenderStart() {
57
- hideMobileNavigation()
58
- hideNavigationFullScreen()
58
+ closeMenuModal()
59
59
  }
60
60
 
61
61
  function onRenderDone() {
62
62
  autoScrollNav()
63
+ // TODO/refactor: use React?
63
64
  installSectionUrlHashs()
64
- initNavigationFullscreen()
65
- initMobileNavigation()
66
- initPressKit()
67
- addFeatureClickHandlers()
68
- addTwitterWidgets()
69
65
  setHydrationIsFinished()
70
- renderPromiseResolve()
66
+ globalObject.renderPromiseResolve!()
71
67
  }
72
68
 
73
69
  function OnRenderDoneHook({ children }: { children: React.ReactNode }) {
@@ -6,6 +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 { getStyleColumnLayout } from './getStyleColumnLayout'
9
10
 
10
11
  const onRenderHtml: OnRenderHtmlAsync = async (
11
12
  pageContext,
@@ -15,6 +16,8 @@ Promise<Awaited<ReturnType<OnRenderHtmlAsync>>> => {
15
16
 
16
17
  const page = getPageElement(pageContext, pageContextResolved)
17
18
 
19
+ const styleMenuModalLayout = getStyleColumnLayout(pageContextResolved.columnLayouts)
20
+
18
21
  const descriptionTag = pageContextResolved.isLandingPage
19
22
  ? dangerouslySkipEscape(`<meta name="description" content="${pageContextResolved.meta.tagline}" />`)
20
23
  : ''
@@ -30,6 +33,7 @@ Promise<Awaited<ReturnType<OnRenderHtmlAsync>>> => {
30
33
  ${descriptionTag}
31
34
  <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
32
35
  ${getOpenGraphTags(pageContext.urlPathname, pageContextResolved.documentTitle, pageContextResolved.meta)}
36
+ <style>${dangerouslySkipEscape(styleMenuModalLayout)}</style>
33
37
  </head>
34
38
  <body>
35
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/types.d.ts CHANGED
@@ -5,3 +5,11 @@ declare module '*.mdx' {
5
5
  export default value
6
6
  export const headings: { level: number; title: string; id: string }[]
7
7
  }
8
+
9
+ // https://stackoverflow.com/questions/52005083/how-to-define-css-variables-in-style-attribute-in-react-and-typescript/70398145#70398145
10
+ import 'react'
11
+ declare module 'react' {
12
+ interface CSSProperties {
13
+ [key: `--${string}`]: string | number
14
+ }
15
+ }
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
- }