@elastic/eui-docusaurus-theme 2.0.0

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 (297) hide show
  1. package/LICENSE.txt +6 -0
  2. package/README.md +292 -0
  3. package/lib/.tsbuildinfo-client +1 -0
  4. package/lib/components/badge/index.d.ts +1 -0
  5. package/lib/components/badge/index.js +9 -0
  6. package/lib/components/codesandbox_icon/codesandbox_icon.d.ts +4 -0
  7. package/lib/components/codesandbox_icon/codesandbox_icon.js +2 -0
  8. package/lib/components/codesandbox_icon/index.d.ts +1 -0
  9. package/lib/components/codesandbox_icon/index.js +8 -0
  10. package/lib/components/demo/actions_bar/actions_bar.d.ts +10 -0
  11. package/lib/components/demo/actions_bar/actions_bar.js +34 -0
  12. package/lib/components/demo/actions_bar/index.d.ts +1 -0
  13. package/lib/components/demo/actions_bar/index.js +8 -0
  14. package/lib/components/demo/code_transformer.d.ts +18 -0
  15. package/lib/components/demo/code_transformer.js +39 -0
  16. package/lib/components/demo/codesandbox/find_external_dependencies.d.ts +5 -0
  17. package/lib/components/demo/codesandbox/find_external_dependencies.js +30 -0
  18. package/lib/components/demo/codesandbox/index.d.ts +1 -0
  19. package/lib/components/demo/codesandbox/index.js +8 -0
  20. package/lib/components/demo/codesandbox/open_action.d.ts +16 -0
  21. package/lib/components/demo/codesandbox/open_action.js +91 -0
  22. package/lib/components/demo/context.d.ts +14 -0
  23. package/lib/components/demo/context.js +13 -0
  24. package/lib/components/demo/create_demo.d.ts +5 -0
  25. package/lib/components/demo/create_demo.js +13 -0
  26. package/lib/components/demo/demo.d.ts +23 -0
  27. package/lib/components/demo/demo.js +61 -0
  28. package/lib/components/demo/editor/editor.d.ts +1 -0
  29. package/lib/components/demo/editor/editor.js +39 -0
  30. package/lib/components/demo/editor/index.d.ts +1 -0
  31. package/lib/components/demo/editor/index.js +8 -0
  32. package/lib/components/demo/index.d.ts +3 -0
  33. package/lib/components/demo/index.js +10 -0
  34. package/lib/components/demo/preview/index.d.ts +1 -0
  35. package/lib/components/demo/preview/index.js +8 -0
  36. package/lib/components/demo/preview/preview.d.ts +7 -0
  37. package/lib/components/demo/preview/preview.js +36 -0
  38. package/lib/components/demo/scope.d.ts +1 -0
  39. package/lib/components/demo/scope.js +12 -0
  40. package/lib/components/demo/source/get_source_from_children.d.ts +11 -0
  41. package/lib/components/demo/source/get_source_from_children.js +42 -0
  42. package/lib/components/demo/source/index.d.ts +1 -0
  43. package/lib/components/demo/source/index.js +8 -0
  44. package/lib/components/demo/source/source.d.ts +6 -0
  45. package/lib/components/demo/source/source.js +25 -0
  46. package/lib/components/figma_embed/index.d.ts +5 -0
  47. package/lib/components/figma_embed/index.js +36 -0
  48. package/lib/components/guideline/guideline.d.ts +10 -0
  49. package/lib/components/guideline/guideline.js +68 -0
  50. package/lib/components/guideline/guideline_text.d.ts +6 -0
  51. package/lib/components/guideline/guideline_text.js +28 -0
  52. package/lib/components/guideline/index.d.ts +2 -0
  53. package/lib/components/guideline/index.js +9 -0
  54. package/lib/components/guideline/types.d.ts +1 -0
  55. package/lib/components/guideline/types.js +8 -0
  56. package/lib/components/high_contrast_mode_toggle/index.d.ts +1 -0
  57. package/lib/components/high_contrast_mode_toggle/index.js +15 -0
  58. package/lib/components/icon/index.d.ts +1 -0
  59. package/lib/components/icon/index.js +9 -0
  60. package/lib/components/index.d.ts +7 -0
  61. package/lib/components/index.js +14 -0
  62. package/lib/components/navbar_item/index.d.ts +19 -0
  63. package/lib/components/navbar_item/index.js +84 -0
  64. package/lib/components/prop_table/definition_types.d.ts +43 -0
  65. package/lib/components/prop_table/definition_types.js +8 -0
  66. package/lib/components/prop_table/extended_types.d.ts +5 -0
  67. package/lib/components/prop_table/extended_types.js +27 -0
  68. package/lib/components/prop_table/extended_types_info.d.ts +26 -0
  69. package/lib/components/prop_table/extended_types_info.js +34 -0
  70. package/lib/components/prop_table/index.d.ts +1 -0
  71. package/lib/components/prop_table/index.js +8 -0
  72. package/lib/components/prop_table/prop_table.d.ts +8 -0
  73. package/lib/components/prop_table/prop_table.js +115 -0
  74. package/lib/components/theme_context/index.d.ts +16 -0
  75. package/lib/components/theme_context/index.js +103 -0
  76. package/lib/components/theme_context/theme_overrides.d.ts +2 -0
  77. package/lib/components/theme_context/theme_overrides.js +12 -0
  78. package/lib/components/version_switcher/index.d.ts +23 -0
  79. package/lib/components/version_switcher/index.js +51 -0
  80. package/lib/index.d.ts +2 -0
  81. package/lib/index.js +19 -0
  82. package/lib/index.js.map +1 -0
  83. package/lib/theme/Admonition/Types.d.ts +3 -0
  84. package/lib/theme/Admonition/Types.js +51 -0
  85. package/lib/theme/CodeBlock/index.d.ts +3 -0
  86. package/lib/theme/CodeBlock/index.js +35 -0
  87. package/lib/theme/ColorModeToggle/index.d.ts +10 -0
  88. package/lib/theme/ColorModeToggle/index.js +51 -0
  89. package/lib/theme/Demo/actions.d.ts +8 -0
  90. package/lib/theme/Demo/actions.js +8 -0
  91. package/lib/theme/Demo/default_scope.d.ts +3 -0
  92. package/lib/theme/Demo/default_scope.js +17 -0
  93. package/lib/theme/DocBreadcrumbs/Items/Home/index.d.ts +2 -0
  94. package/lib/theme/DocBreadcrumbs/Items/Home/index.js +15 -0
  95. package/lib/theme/DocBreadcrumbs/Items/item.styles.d.ts +5 -0
  96. package/lib/theme/DocBreadcrumbs/Items/item.styles.js +40 -0
  97. package/lib/theme/DocBreadcrumbs/index.d.ts +2 -0
  98. package/lib/theme/DocBreadcrumbs/index.js +63 -0
  99. package/lib/theme/DocItem/Content/index.d.ts +3 -0
  100. package/lib/theme/DocItem/Content/index.js +44 -0
  101. package/lib/theme/DocItem/Footer/index.d.ts +2 -0
  102. package/lib/theme/DocItem/Footer/index.js +17 -0
  103. package/lib/theme/DocItem/Layout/index.d.ts +3 -0
  104. package/lib/theme/DocItem/Layout/index.js +71 -0
  105. package/lib/theme/DocItem/Metadata/index.d.ts +2 -0
  106. package/lib/theme/DocItem/Metadata/index.js +7 -0
  107. package/lib/theme/DocItem/Paginator/index.d.ts +6 -0
  108. package/lib/theme/DocItem/Paginator/index.js +11 -0
  109. package/lib/theme/DocItem/TOC/Desktop/index.d.ts +2 -0
  110. package/lib/theme/DocItem/TOC/Desktop/index.js +8 -0
  111. package/lib/theme/DocItem/TOC/Mobile/index.d.ts +2 -0
  112. package/lib/theme/DocItem/TOC/Mobile/index.js +17 -0
  113. package/lib/theme/DocItem/index.d.ts +3 -0
  114. package/lib/theme/DocItem/index.js +10 -0
  115. package/lib/theme/DocPaginator/index.d.ts +3 -0
  116. package/lib/theme/DocPaginator/index.js +19 -0
  117. package/lib/theme/DocRoot/Layout/Main/index.d.ts +3 -0
  118. package/lib/theme/DocRoot/Layout/Main/index.js +35 -0
  119. package/lib/theme/DocRoot/Layout/Sidebar/index.d.ts +3 -0
  120. package/lib/theme/DocRoot/Layout/Sidebar/index.js +81 -0
  121. package/lib/theme/DocRoot/Layout/index.d.ts +3 -0
  122. package/lib/theme/DocRoot/Layout/index.js +47 -0
  123. package/lib/theme/DocSidebarItem/Category/index.d.ts +3 -0
  124. package/lib/theme/DocSidebarItem/Category/index.js +146 -0
  125. package/lib/theme/DocSidebarItem/Link/index.d.ts +3 -0
  126. package/lib/theme/DocSidebarItem/Link/index.js +39 -0
  127. package/lib/theme/DocSidebarItem/index.d.ts +3 -0
  128. package/lib/theme/DocSidebarItem/index.js +15 -0
  129. package/lib/theme/DocSidebarItems/index.d.ts +5 -0
  130. package/lib/theme/DocSidebarItems/index.js +17 -0
  131. package/lib/theme/EditThisPage/index.d.ts +3 -0
  132. package/lib/theme/EditThisPage/index.js +17 -0
  133. package/lib/theme/Footer/index.d.ts +2 -0
  134. package/lib/theme/Footer/index.js +43 -0
  135. package/lib/theme/Heading/index.d.ts +3 -0
  136. package/lib/theme/Heading/index.js +49 -0
  137. package/lib/theme/Logo/index.d.ts +3 -0
  138. package/lib/theme/Logo/index.js +80 -0
  139. package/lib/theme/MDXComponents/A.d.ts +6 -0
  140. package/lib/theme/MDXComponents/A.js +17 -0
  141. package/lib/theme/MDXComponents/Blockquote.d.ts +2 -0
  142. package/lib/theme/MDXComponents/Blockquote.js +18 -0
  143. package/lib/theme/MDXComponents/Code.d.ts +6 -0
  144. package/lib/theme/MDXComponents/Code.js +35 -0
  145. package/lib/theme/MDXComponents/Heading.d.ts +4 -0
  146. package/lib/theme/MDXComponents/Heading.js +4 -0
  147. package/lib/theme/MDXComponents/ListItem.d.ts +2 -0
  148. package/lib/theme/MDXComponents/ListItem.js +5 -0
  149. package/lib/theme/MDXComponents/OrderedList.d.ts +2 -0
  150. package/lib/theme/MDXComponents/OrderedList.js +11 -0
  151. package/lib/theme/MDXComponents/Paragraph.d.ts +2 -0
  152. package/lib/theme/MDXComponents/Paragraph.js +18 -0
  153. package/lib/theme/MDXComponents/Table.d.ts +2 -0
  154. package/lib/theme/MDXComponents/Table.js +3 -0
  155. package/lib/theme/MDXComponents/TableBody.d.ts +2 -0
  156. package/lib/theme/MDXComponents/TableBody.js +3 -0
  157. package/lib/theme/MDXComponents/TableDataCell.d.ts +2 -0
  158. package/lib/theme/MDXComponents/TableDataCell.js +3 -0
  159. package/lib/theme/MDXComponents/TableHeader.d.ts +2 -0
  160. package/lib/theme/MDXComponents/TableHeader.js +3 -0
  161. package/lib/theme/MDXComponents/TableHeaderCell.d.ts +2 -0
  162. package/lib/theme/MDXComponents/TableHeaderCell.js +3 -0
  163. package/lib/theme/MDXComponents/TableRow.d.ts +2 -0
  164. package/lib/theme/MDXComponents/TableRow.js +3 -0
  165. package/lib/theme/MDXComponents/UnorderedList.d.ts +2 -0
  166. package/lib/theme/MDXComponents/UnorderedList.js +11 -0
  167. package/lib/theme/MDXComponents/index.d.ts +2 -0
  168. package/lib/theme/MDXComponents/index.js +46 -0
  169. package/lib/theme/MDXContent/index.d.ts +6 -0
  170. package/lib/theme/MDXContent/index.js +4 -0
  171. package/lib/theme/Navbar/Content/index.d.ts +7 -0
  172. package/lib/theme/Navbar/Content/index.js +149 -0
  173. package/lib/theme/Navbar/Layout/index.d.ts +6 -0
  174. package/lib/theme/Navbar/Layout/index.js +59 -0
  175. package/lib/theme/Navbar/MobileSidebar/Header/index.d.ts +7 -0
  176. package/lib/theme/Navbar/MobileSidebar/Header/index.js +46 -0
  177. package/lib/theme/Navbar/MobileSidebar/Layout/index.d.ts +6 -0
  178. package/lib/theme/Navbar/MobileSidebar/Layout/index.js +26 -0
  179. package/lib/theme/Navbar/MobileSidebar/index.d.ts +7 -0
  180. package/lib/theme/Navbar/MobileSidebar/index.js +14 -0
  181. package/lib/theme/NavbarItem/DropdownNavbarItem/index.d.ts +3 -0
  182. package/lib/theme/NavbarItem/DropdownNavbarItem/index.js +94 -0
  183. package/lib/theme/NavbarItem/NavbarNavLink.d.ts +7 -0
  184. package/lib/theme/NavbarItem/NavbarNavLink.js +48 -0
  185. package/lib/theme/PaginatorNavLink/index.d.ts +3 -0
  186. package/lib/theme/PaginatorNavLink/index.js +43 -0
  187. package/lib/theme/Root.d.ts +3 -0
  188. package/lib/theme/Root.js +66 -0
  189. package/lib/theme/Root.styles.d.ts +2 -0
  190. package/lib/theme/Root.styles.js +111 -0
  191. package/lib/theme/TOCCollapsible/CollapseButton/index.d.ts +3 -0
  192. package/lib/theme/TOCCollapsible/CollapseButton/index.js +23 -0
  193. package/lib/theme/TOCItems/Tree.d.ts +5 -0
  194. package/lib/theme/TOCItems/Tree.js +80 -0
  195. package/lib/theme/infima.styles.d.ts +1 -0
  196. package/lib/theme/infima.styles.js +1456 -0
  197. package/lib/theme/reset.styles.d.ts +2 -0
  198. package/lib/theme/reset.styles.js +79 -0
  199. package/package.json +61 -0
  200. package/src/components/badge/index.ts +11 -0
  201. package/src/components/codesandbox_icon/codesandbox_icon.tsx +24 -0
  202. package/src/components/codesandbox_icon/index.ts +9 -0
  203. package/src/components/demo/actions_bar/actions_bar.tsx +95 -0
  204. package/src/components/demo/actions_bar/index.ts +9 -0
  205. package/src/components/demo/code_transformer.ts +44 -0
  206. package/src/components/demo/codesandbox/find_external_dependencies.ts +34 -0
  207. package/src/components/demo/codesandbox/index.ts +9 -0
  208. package/src/components/demo/codesandbox/open_action.tsx +132 -0
  209. package/src/components/demo/context.ts +30 -0
  210. package/src/components/demo/create_demo.tsx +17 -0
  211. package/src/components/demo/demo.tsx +143 -0
  212. package/src/components/demo/editor/editor.tsx +51 -0
  213. package/src/components/demo/editor/index.ts +9 -0
  214. package/src/components/demo/index.ts +11 -0
  215. package/src/components/demo/preview/index.ts +9 -0
  216. package/src/components/demo/preview/preview.tsx +77 -0
  217. package/src/components/demo/scope.ts +14 -0
  218. package/src/components/demo/source/get_source_from_children.ts +59 -0
  219. package/src/components/demo/source/index.ts +9 -0
  220. package/src/components/demo/source/source.tsx +36 -0
  221. package/src/components/figma_embed/index.tsx +57 -0
  222. package/src/components/guideline/guideline.tsx +121 -0
  223. package/src/components/guideline/guideline_text.tsx +51 -0
  224. package/src/components/guideline/index.ts +10 -0
  225. package/src/components/guideline/types.ts +9 -0
  226. package/src/components/high_contrast_mode_toggle/index.tsx +28 -0
  227. package/src/components/icon/index.ts +11 -0
  228. package/src/components/index.ts +15 -0
  229. package/src/components/navbar_item/index.tsx +164 -0
  230. package/src/components/prop_table/definition_types.ts +53 -0
  231. package/src/components/prop_table/extended_types.tsx +66 -0
  232. package/src/components/prop_table/extended_types_info.ts +35 -0
  233. package/src/components/prop_table/index.ts +9 -0
  234. package/src/components/prop_table/prop_table.tsx +235 -0
  235. package/src/components/theme_context/index.tsx +156 -0
  236. package/src/components/theme_context/theme_overrides.ts +15 -0
  237. package/src/components/version_switcher/index.tsx +144 -0
  238. package/src/index.ts +21 -0
  239. package/src/theme/Admonition/Types.tsx +85 -0
  240. package/src/theme/CodeBlock/index.tsx +57 -0
  241. package/src/theme/ColorModeToggle/index.tsx +93 -0
  242. package/src/theme/Demo/actions.tsx +20 -0
  243. package/src/theme/Demo/default_scope.ts +19 -0
  244. package/src/theme/DocBreadcrumbs/Items/Home/index.tsx +38 -0
  245. package/src/theme/DocBreadcrumbs/Items/item.styles.ts +43 -0
  246. package/src/theme/DocBreadcrumbs/index.tsx +144 -0
  247. package/src/theme/DocItem/Content/index.tsx +75 -0
  248. package/src/theme/DocItem/Footer/index.tsx +59 -0
  249. package/src/theme/DocItem/Layout/index.tsx +112 -0
  250. package/src/theme/DocItem/Metadata/index.tsx +23 -0
  251. package/src/theme/DocItem/Paginator/index.tsx +20 -0
  252. package/src/theme/DocItem/TOC/Desktop/index.tsx +24 -0
  253. package/src/theme/DocItem/TOC/Mobile/index.tsx +35 -0
  254. package/src/theme/DocItem/index.tsx +30 -0
  255. package/src/theme/DocPaginator/index.tsx +64 -0
  256. package/src/theme/DocRoot/Layout/Main/index.tsx +61 -0
  257. package/src/theme/DocRoot/Layout/Sidebar/index.tsx +124 -0
  258. package/src/theme/DocRoot/Layout/index.tsx +72 -0
  259. package/src/theme/DocSidebarItem/Category/index.tsx +266 -0
  260. package/src/theme/DocSidebarItem/Link/index.tsx +86 -0
  261. package/src/theme/DocSidebarItem/index.tsx +29 -0
  262. package/src/theme/DocSidebarItems/index.tsx +30 -0
  263. package/src/theme/EditThisPage/index.tsx +50 -0
  264. package/src/theme/Footer/index.tsx +67 -0
  265. package/src/theme/Heading/index.tsx +94 -0
  266. package/src/theme/Logo/index.tsx +146 -0
  267. package/src/theme/MDXComponents/A.tsx +33 -0
  268. package/src/theme/MDXComponents/Blockquote.tsx +35 -0
  269. package/src/theme/MDXComponents/Code.tsx +60 -0
  270. package/src/theme/MDXComponents/Heading.tsx +16 -0
  271. package/src/theme/MDXComponents/ListItem.tsx +20 -0
  272. package/src/theme/MDXComponents/OrderedList.tsx +26 -0
  273. package/src/theme/MDXComponents/Paragraph.tsx +33 -0
  274. package/src/theme/MDXComponents/Table.tsx +16 -0
  275. package/src/theme/MDXComponents/TableBody.tsx +16 -0
  276. package/src/theme/MDXComponents/TableDataCell.tsx +20 -0
  277. package/src/theme/MDXComponents/TableHeader.tsx +16 -0
  278. package/src/theme/MDXComponents/TableHeaderCell.tsx +20 -0
  279. package/src/theme/MDXComponents/TableRow.tsx +16 -0
  280. package/src/theme/MDXComponents/UnorderedList.tsx +26 -0
  281. package/src/theme/MDXComponents/index.ts +61 -0
  282. package/src/theme/MDXContent/index.tsx +22 -0
  283. package/src/theme/Navbar/Content/index.tsx +262 -0
  284. package/src/theme/Navbar/Layout/index.tsx +100 -0
  285. package/src/theme/Navbar/MobileSidebar/Header/index.tsx +89 -0
  286. package/src/theme/Navbar/MobileSidebar/Layout/index.tsx +44 -0
  287. package/src/theme/Navbar/MobileSidebar/index.tsx +46 -0
  288. package/src/theme/NavbarItem/DropdownNavbarItem/index.tsx +200 -0
  289. package/src/theme/NavbarItem/NavbarNavLink.tsx +141 -0
  290. package/src/theme/PaginatorNavLink/index.tsx +72 -0
  291. package/src/theme/Root.styles.ts +122 -0
  292. package/src/theme/Root.tsx +106 -0
  293. package/src/theme/TOCCollapsible/CollapseButton/index.tsx +53 -0
  294. package/src/theme/TOCItems/Tree.tsx +114 -0
  295. package/src/theme/infima.styles.ts +1458 -0
  296. package/src/theme/reset.styles.ts +82 -0
  297. package/src/theme/theme.d.ts +598 -0
@@ -0,0 +1,144 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ import { type ReactNode, JSX } from 'react';
10
+ import clsx from 'clsx';
11
+ import { css } from '@emotion/react';
12
+ import { ThemeClassNames } from '@docusaurus/theme-common';
13
+ import { useSidebarBreadcrumbs } from '@docusaurus/plugin-content-docs/client';
14
+ import { useHomePageRoute } from '@docusaurus/theme-common/internal';
15
+ import Link from '@docusaurus/Link';
16
+ import { translate } from '@docusaurus/Translate';
17
+ import { EuiIcon, useEuiMemoizedStyles, UseEuiTheme } from '@elastic/eui';
18
+
19
+ import HomeBreadcrumbItem from './Items/Home';
20
+ import { getItemStyles } from './Items/item.styles';
21
+
22
+ // converted from css modules to Emotion
23
+ const getStyles = ({ euiTheme }: UseEuiTheme) => ({
24
+ breadcrumbsContainer: css`
25
+ --ifm-breadcrumb-size-multiplier: 0.8;
26
+
27
+ // align breadcrumb items with content
28
+ margin-inline-start: -${euiTheme.size.m};
29
+ `,
30
+ });
31
+
32
+ // TODO move to design system folder
33
+ function BreadcrumbsItemLink({
34
+ children,
35
+ href,
36
+ isLast,
37
+ }: {
38
+ children: ReactNode;
39
+ href: string | undefined;
40
+ isLast: boolean;
41
+ }): JSX.Element {
42
+ const className = 'breadcrumbs__link';
43
+ if (isLast) {
44
+ return (
45
+ <span className={className} itemProp="name">
46
+ {children}
47
+ </span>
48
+ );
49
+ }
50
+ return href ? (
51
+ <Link className={className} href={href} itemProp="item">
52
+ <span itemProp="name">{children}</span>
53
+ </Link>
54
+ ) : (
55
+ // TODO Google search console doesn't like breadcrumb items without href.
56
+ // The schema doesn't seem to require `id` for each `item`, although Google
57
+ // insist to infer one, even if it's invalid. Removing `itemProp="item
58
+ // name"` for now, since I don't know how to properly fix it.
59
+ // See https://github.com/facebook/docusaurus/issues/7241
60
+ <span className={className}>{children}</span>
61
+ );
62
+ }
63
+
64
+ function BreadcrumbsItem({
65
+ children,
66
+ active,
67
+ index,
68
+ addMicrodata,
69
+ }: {
70
+ children: ReactNode;
71
+ active?: boolean;
72
+ index: number;
73
+ addMicrodata: boolean;
74
+ }): JSX.Element {
75
+ const styles = useEuiMemoizedStyles(getItemStyles);
76
+
77
+ return (
78
+ <li
79
+ {...(addMicrodata && {
80
+ itemScope: true,
81
+ itemProp: 'itemListElement',
82
+ itemType: 'https://schema.org/ListItem',
83
+ })}
84
+ className={clsx('breadcrumbs__item', {
85
+ 'breadcrumbs__item--active': active,
86
+ })}
87
+ css={styles.item}
88
+ >
89
+ {children}
90
+ <meta itemProp="position" content={String(index + 1)} />
91
+ {!active && <EuiIcon type="arrowRight" css={styles.icon} />}
92
+ </li>
93
+ );
94
+ }
95
+
96
+ export default function DocBreadcrumbs(): JSX.Element | null {
97
+ const breadcrumbs = useSidebarBreadcrumbs();
98
+ const homePageRoute = useHomePageRoute();
99
+
100
+ const styles = useEuiMemoizedStyles(getStyles);
101
+
102
+ if (!breadcrumbs) {
103
+ return null;
104
+ }
105
+
106
+ return (
107
+ <nav
108
+ className={clsx(ThemeClassNames.docs.docBreadcrumbs)}
109
+ aria-label={translate({
110
+ id: 'theme.docs.breadcrumbs.navAriaLabel',
111
+ message: 'Breadcrumbs',
112
+ description: 'The ARIA label for the breadcrumbs',
113
+ })}
114
+ css={styles.breadcrumbsContainer}
115
+ >
116
+ <ul
117
+ className="breadcrumbs"
118
+ itemScope
119
+ itemType="https://schema.org/BreadcrumbList"
120
+ >
121
+ {homePageRoute && <HomeBreadcrumbItem />}
122
+ {breadcrumbs.map((item, idx) => {
123
+ const isLast = idx === breadcrumbs.length - 1;
124
+ const href =
125
+ item.type === 'category' && item.linkUnlisted
126
+ ? undefined
127
+ : item.href;
128
+ return (
129
+ <BreadcrumbsItem
130
+ key={idx}
131
+ active={isLast}
132
+ index={idx}
133
+ addMicrodata={!!href}
134
+ >
135
+ <BreadcrumbsItemLink href={href} isLast={isLast}>
136
+ {item.label}
137
+ </BreadcrumbsItemLink>
138
+ </BreadcrumbsItem>
139
+ );
140
+ })}
141
+ </ul>
142
+ </nav>
143
+ );
144
+ }
@@ -0,0 +1,75 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ import { JSX } from 'react';
10
+ import clsx from 'clsx';
11
+ import { css } from '@emotion/react';
12
+ import { ThemeClassNames } from '@docusaurus/theme-common';
13
+ import { useDoc } from '@docusaurus/plugin-content-docs/client';
14
+ import MDXContent from '@theme-original/MDXContent';
15
+ import {
16
+ EuiHorizontalRule,
17
+ useEuiMemoizedStyles,
18
+ UseEuiTheme,
19
+ } from '@elastic/eui';
20
+ import { Props } from '@theme-original/DocItem/Content';
21
+
22
+ import Heading from '../../MDXComponents/Heading';
23
+
24
+ /**
25
+ Title can be declared inside md content or declared through
26
+ front matter and added manually. To make both cases consistent,
27
+ the added title is added under the same div.markdown block
28
+ See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
29
+
30
+ We render a "synthetic title" if:
31
+ - user doesn't ask to hide it with front matter
32
+ - the markdown content does not already contain a top-level h1 heading
33
+ */
34
+ function useSyntheticTitle(): string | null {
35
+ const { metadata, frontMatter, contentTitle } = useDoc();
36
+ const shouldRender =
37
+ !frontMatter.hide_title && typeof contentTitle === 'undefined';
38
+ if (!shouldRender) {
39
+ return null;
40
+ }
41
+ return metadata.title;
42
+ }
43
+
44
+ const getContentStyles = ({ euiTheme }: UseEuiTheme) => {
45
+ return {
46
+ header: css`
47
+ // required specificity to override docusaurus styles
48
+ & > h1.euiTitle {
49
+ --ifm-h1-font-size: var(--eui-font-size-xxl);
50
+ --ifm-h1-vertical-rhythm-bottom: 1.2;
51
+
52
+ line-height: 2.8rem;
53
+ }
54
+ `,
55
+ };
56
+ };
57
+
58
+ export default function DocItemContent({ children }: Props): JSX.Element {
59
+ const syntheticTitle = useSyntheticTitle();
60
+ const styles = useEuiMemoizedStyles(getContentStyles);
61
+
62
+ return (
63
+ <div className={clsx(ThemeClassNames.docs.docMarkdown, 'markdown')}>
64
+ {syntheticTitle && (
65
+ <>
66
+ <header css={styles.header}>
67
+ <Heading as="h1">{syntheticTitle}</Heading>
68
+ </header>
69
+ <EuiHorizontalRule />
70
+ </>
71
+ )}
72
+ <MDXContent>{children}</MDXContent>
73
+ </div>
74
+ );
75
+ }
@@ -0,0 +1,59 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ import { JSX } from 'react';
10
+ import clsx from 'clsx';
11
+ import { ThemeClassNames } from '@docusaurus/theme-common';
12
+ import { useDoc } from '@docusaurus/plugin-content-docs/client';
13
+ import TagsListInline from '@theme-original/TagsListInline';
14
+
15
+ import EditMetaRow from '@theme-original/EditMetaRow';
16
+
17
+ export default function DocItemFooter(): JSX.Element | null {
18
+ const { metadata } = useDoc();
19
+ const { editUrl, lastUpdatedAt, lastUpdatedBy, tags } = metadata;
20
+
21
+ const canDisplayTagsRow = tags.length > 0;
22
+ const canDisplayEditMetaRow = !!(editUrl || lastUpdatedAt || lastUpdatedBy);
23
+
24
+ const canDisplayFooter = canDisplayTagsRow || canDisplayEditMetaRow;
25
+
26
+ if (!canDisplayFooter) {
27
+ return null;
28
+ }
29
+
30
+ return (
31
+ <footer
32
+ className={clsx(ThemeClassNames.docs.docFooter, 'docusaurus-mt-lg')}
33
+ >
34
+ {canDisplayTagsRow && (
35
+ <div
36
+ className={clsx(
37
+ 'row margin-top--sm',
38
+ ThemeClassNames.docs.docFooterTagsRow
39
+ )}
40
+ >
41
+ <div className="col">
42
+ <TagsListInline tags={tags} />
43
+ </div>
44
+ </div>
45
+ )}
46
+ {canDisplayEditMetaRow && (
47
+ <EditMetaRow
48
+ className={clsx(
49
+ 'margin-top--sm',
50
+ ThemeClassNames.docs.docFooterEditMetaRow
51
+ )}
52
+ editUrl={editUrl}
53
+ lastUpdatedAt={lastUpdatedAt}
54
+ lastUpdatedBy={lastUpdatedBy}
55
+ />
56
+ )}
57
+ </footer>
58
+ );
59
+ }
@@ -0,0 +1,112 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ import { JSX } from 'react';
10
+ import { EuiHorizontalRule } from '@elastic/eui';
11
+ import { css } from '@emotion/react';
12
+ import { useWindowSize } from '@docusaurus/theme-common';
13
+ import { useDoc } from '@docusaurus/plugin-content-docs/client';
14
+ import DocItemPaginator from '@theme-original/DocItem/Paginator';
15
+ import ContentVisibility from '@theme-original/ContentVisibility';
16
+ import DocVersionBanner from '@theme-original/DocVersionBanner';
17
+ import DocVersionBadge from '@theme-original/DocVersionBadge';
18
+ import * as Props from '@theme-original/DocItem/Layout';
19
+
20
+ import DocBreadcrumbs from '../../DocBreadcrumbs';
21
+ import DocItemTOCMobile from '../TOC/Mobile';
22
+ import DocItemTOCDesktop from '../TOC/Desktop';
23
+ import DocItemContent from '../Content';
24
+ import DocItemFooter from '../Footer';
25
+
26
+ // At 1280px there's enough space to show the TOC,
27
+ // until then we show the mobile/collapsible TOC
28
+ const BREAKPOINT_TOC = 1280;
29
+
30
+ // converted from css modules to emotion
31
+ const styles = {
32
+ docItemContainer: css`
33
+ & header + *,
34
+ & article > *:first-child {
35
+ margin-top: 0;
36
+ }
37
+ `,
38
+ docItemRow: css`
39
+ justify-content: center;
40
+ `,
41
+ docItemCol: css`
42
+ @media (min-width: 997px) {
43
+ font-size: 100%;
44
+ max-width: 94ch;
45
+ /* Ensure TOC won't wrap */
46
+ overflow-x: auto;
47
+ }
48
+ `,
49
+ docItemTOCDesktopContainter: css`
50
+ display: none;
51
+
52
+ @media (min-width: ${BREAKPOINT_TOC}px) {
53
+ display: block;
54
+ }
55
+ `,
56
+ docItemTOCMobileContainter: css`
57
+ @media (min-width: ${BREAKPOINT_TOC}px) {
58
+ display: none;
59
+ }
60
+ `,
61
+ };
62
+
63
+ /**
64
+ * Decide if the toc should be rendered, on mobile or desktop viewports
65
+ */
66
+ function useDocTOC() {
67
+ const { frontMatter, toc } = useDoc();
68
+ const windowSize = useWindowSize();
69
+
70
+ const hidden = frontMatter.hide_table_of_contents ?? false;
71
+ const canRender = !hidden && toc.length > 0;
72
+
73
+ // Hide/show for TOC elements is handled by media queries
74
+ const mobile = canRender ? <DocItemTOCMobile /> : undefined;
75
+ const desktop = canRender ? <DocItemTOCDesktop /> : undefined;
76
+
77
+ return {
78
+ hidden,
79
+ mobile,
80
+ desktop,
81
+ };
82
+ }
83
+
84
+ export default function DocItemLayout({ children }: typeof Props): JSX.Element {
85
+ const docTOC = useDocTOC();
86
+ const { metadata } = useDoc();
87
+
88
+ return (
89
+ <div className="row" css={styles.docItemRow}>
90
+ <div className="col" css={styles.docItemCol}>
91
+ <ContentVisibility metadata={metadata} />
92
+ <DocVersionBanner />
93
+ <div css={styles.docItemContainer}>
94
+ <article>
95
+ <DocBreadcrumbs />
96
+ <DocVersionBadge />
97
+ <div css={styles.docItemTOCMobileContainter}>{docTOC.mobile}</div>
98
+ <DocItemContent>{children}</DocItemContent>
99
+ <DocItemFooter />
100
+ </article>
101
+ <EuiHorizontalRule margin="xl" />
102
+ <DocItemPaginator />
103
+ </div>
104
+ </div>
105
+ {docTOC.desktop && (
106
+ <div className="col col--3" css={styles.docItemTOCDesktopContainter}>
107
+ {docTOC.desktop}
108
+ </div>
109
+ )}
110
+ </div>
111
+ );
112
+ }
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ import { JSX } from 'react';
10
+ import { PageMetadata } from '@docusaurus/theme-common';
11
+ import { useDoc } from '@docusaurus/plugin-content-docs/client';
12
+
13
+ export default function DocItemMetadata(): JSX.Element {
14
+ const { metadata, frontMatter, assets } = useDoc();
15
+ return (
16
+ <PageMetadata
17
+ title={metadata.title}
18
+ description={metadata.description}
19
+ keywords={frontMatter.keywords}
20
+ image={assets.image ?? frontMatter.image}
21
+ />
22
+ );
23
+ }
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ import { JSX } from 'react';
10
+ import { useDoc } from '@docusaurus/plugin-content-docs/client';
11
+ import DocPaginator from '@theme-original/DocPaginator';
12
+
13
+ /**
14
+ * This extra component is needed, because <DocPaginator> should remain generic.
15
+ * DocPaginator is used in non-docs contexts too: generated-index pages...
16
+ */
17
+ export default function DocItemPaginator(): JSX.Element {
18
+ const { metadata } = useDoc();
19
+ return <DocPaginator previous={metadata.previous} next={metadata.next} />;
20
+ }
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ import { JSX } from 'react';
10
+ import { ThemeClassNames } from '@docusaurus/theme-common';
11
+ import { useDoc } from '@docusaurus/plugin-content-docs/client';
12
+ import TOC from '@theme-original/TOC';
13
+
14
+ export default function DocItemTOCDesktop(): JSX.Element {
15
+ const { toc, frontMatter } = useDoc();
16
+ return (
17
+ <TOC
18
+ toc={toc}
19
+ minHeadingLevel={frontMatter.toc_min_heading_level}
20
+ maxHeadingLevel={frontMatter.toc_max_heading_level}
21
+ className={ThemeClassNames.docs.docTocDesktop}
22
+ />
23
+ );
24
+ }
@@ -0,0 +1,35 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ import { JSX } from 'react';
10
+ import { css } from '@emotion/react';
11
+ import { ThemeClassNames } from '@docusaurus/theme-common';
12
+ import { useDoc } from '@docusaurus/plugin-content-docs/client';
13
+ import TOCCollapsible from '@theme-original/TOCCollapsible';
14
+
15
+ // converted from css modules to emotion
16
+ const tocStyles = {
17
+ tocMobile: css`
18
+ @media print {
19
+ display: none;
20
+ }
21
+ `,
22
+ };
23
+
24
+ export default function DocItemTOCMobile(): JSX.Element {
25
+ const { toc, frontMatter } = useDoc();
26
+ return (
27
+ <TOCCollapsible
28
+ toc={toc}
29
+ minHeadingLevel={frontMatter.toc_min_heading_level}
30
+ maxHeadingLevel={frontMatter.toc_max_heading_level}
31
+ className={ThemeClassNames.docs.docTocMobile}
32
+ css={tocStyles.tocMobile}
33
+ />
34
+ );
35
+ }
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ import { JSX } from 'react';
10
+ import { HtmlClassNameProvider } from '@docusaurus/theme-common';
11
+ import { DocProvider } from '@docusaurus/plugin-content-docs/client';
12
+ import type { Props } from '@theme/DocItem';
13
+
14
+ import DocItemMetadata from './Metadata';
15
+ import DocItemLayout from './Layout';
16
+
17
+ export default function DocItem(props: Props): JSX.Element {
18
+ const docHtmlClassName = `docs-doc-id-${props.content.metadata.id}`;
19
+ const MDXComponent = props.content;
20
+ return (
21
+ <DocProvider content={props.content}>
22
+ <HtmlClassNameProvider className={docHtmlClassName}>
23
+ <DocItemMetadata />
24
+ <DocItemLayout>
25
+ <MDXComponent />
26
+ </DocItemLayout>
27
+ </HtmlClassNameProvider>
28
+ </DocProvider>
29
+ );
30
+ }
@@ -0,0 +1,64 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ import { JSX } from 'react';
10
+ import { css } from '@emotion/react';
11
+ import Translate, { translate } from '@docusaurus/Translate';
12
+ import PaginatorNavLink from '@theme-original/PaginatorNavLink';
13
+ import type { Props } from '@theme-original/DocPaginator';
14
+
15
+ const styles = {
16
+ pagination: css`
17
+ // docusaurus reset, we add spacing via the
18
+ // horizontal rule in Layout instead
19
+ margin-top: 0;
20
+ `,
21
+ };
22
+
23
+ export default function DocPaginator(props: Props): JSX.Element {
24
+ const { previous, next } = props;
25
+ return (
26
+ <nav
27
+ className="pagination-nav docusaurus-mt-lg"
28
+ css={styles.pagination}
29
+ aria-label={translate({
30
+ id: 'theme.docs.paginator.navAriaLabel',
31
+ message: 'Docs pages',
32
+ description: 'The ARIA label for the docs pagination',
33
+ })}
34
+ >
35
+ {previous && (
36
+ <PaginatorNavLink
37
+ {...previous}
38
+ subLabel={
39
+ <Translate
40
+ id="theme.docs.paginator.previous"
41
+ description="The label used to navigate to the previous doc"
42
+ >
43
+ Previous
44
+ </Translate>
45
+ }
46
+ />
47
+ )}
48
+ {next && (
49
+ <PaginatorNavLink
50
+ {...next}
51
+ subLabel={
52
+ <Translate
53
+ id="theme.docs.paginator.next"
54
+ description="The label used to navigate to the next doc"
55
+ >
56
+ Next
57
+ </Translate>
58
+ }
59
+ isNext
60
+ />
61
+ )}
62
+ </nav>
63
+ );
64
+ }
@@ -0,0 +1,61 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ import { JSX } from 'react';
10
+ import clsx from 'clsx';
11
+ import { css } from '@emotion/react';
12
+ import { useDocsSidebar } from '@docusaurus/plugin-content-docs/client';
13
+ import type { Props } from '@theme-original/DocRoot/Layout/Main';
14
+
15
+ // converted from css modules to Emotion
16
+ const styles = {
17
+ docMainContainer: css`
18
+ display: flex;
19
+ width: 100%;
20
+
21
+ @media (min-width: 997px) {
22
+ flex-grow: 1;
23
+ max-width: calc(100% - var(--doc-sidebar-width));
24
+ }
25
+ `,
26
+ docMainContainerEnhanced: css`
27
+ @media (min-width: 997px) {
28
+ max-width: calc(100% - var(--doc-sidebar-hidden-width));
29
+ }
30
+ `,
31
+ docItemWrapperEnhanced: css`
32
+ @media (min-width: 997px) {
33
+ max-width: calc(
34
+ var(--ifm-container-width) + var(--doc-sidebar-width)
35
+ ) !important;
36
+ }
37
+ `,
38
+ };
39
+
40
+ export default function DocRootLayoutMain({
41
+ hiddenSidebarContainer,
42
+ children,
43
+ }: Props): JSX.Element {
44
+ const sidebar = useDocsSidebar();
45
+ return (
46
+ <main
47
+ className={clsx(styles.docMainContainer)}
48
+ css={[
49
+ styles.docMainContainer,
50
+ (hiddenSidebarContainer || !sidebar) && styles.docMainContainerEnhanced,
51
+ ]}
52
+ >
53
+ <div
54
+ className="container padding-top--md padding-bottom--lg"
55
+ css={[hiddenSidebarContainer && styles.docItemWrapperEnhanced]}
56
+ >
57
+ {children}
58
+ </div>
59
+ </main>
60
+ );
61
+ }