@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,200 @@
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 { useState, useRef, useEffect, JSX } from 'react';
10
+ import clsx from 'clsx';
11
+ import { css } from '@emotion/react';
12
+ import {
13
+ isRegexpStringMatch,
14
+ useCollapsible,
15
+ Collapsible,
16
+ } from '@docusaurus/theme-common';
17
+ import {
18
+ isSamePath,
19
+ useLocalPathname,
20
+ } from '@docusaurus/theme-common/internal';
21
+ import NavbarNavLink from '@theme-original/NavbarItem/NavbarNavLink';
22
+ import NavbarItem, {
23
+ type LinkLikeNavbarItemProps,
24
+ } from '@theme-original/NavbarItem';
25
+ import type {
26
+ DesktopOrMobileNavBarItemProps,
27
+ Props,
28
+ } from '@theme-original/NavbarItem/DropdownNavbarItem';
29
+ import { EuiIcon } from '@elastic/eui';
30
+
31
+ const styles = {
32
+ dropdownNavbarItemMobile: css`
33
+ cursor: pointer;
34
+ `,
35
+ };
36
+
37
+ function isItemActive(
38
+ item: LinkLikeNavbarItemProps,
39
+ localPathname: string
40
+ ): boolean {
41
+ if (isSamePath(item.to, localPathname)) {
42
+ return true;
43
+ }
44
+ if (isRegexpStringMatch(item.activeBaseRegex, localPathname)) {
45
+ return true;
46
+ }
47
+ if (item.activeBasePath && localPathname.startsWith(item.activeBasePath)) {
48
+ return true;
49
+ }
50
+ return false;
51
+ }
52
+
53
+ function containsActiveItems(
54
+ items: readonly LinkLikeNavbarItemProps[],
55
+ localPathname: string
56
+ ): boolean {
57
+ return items.some((item) => isItemActive(item, localPathname));
58
+ }
59
+
60
+ function DropdownNavbarItemDesktop({
61
+ items,
62
+ position,
63
+ className,
64
+ onClick,
65
+ ...props
66
+ }: DesktopOrMobileNavBarItemProps) {
67
+ const dropdownRef = useRef<HTMLDivElement>(null);
68
+ const [showDropdown, setShowDropdown] = useState(false);
69
+
70
+ useEffect(() => {
71
+ const handleClickOutside = (
72
+ event: MouseEvent | TouchEvent | FocusEvent
73
+ ) => {
74
+ if (
75
+ !dropdownRef.current ||
76
+ dropdownRef.current.contains(event.target as Node)
77
+ ) {
78
+ return;
79
+ }
80
+ setShowDropdown(false);
81
+ };
82
+
83
+ document.addEventListener('mousedown', handleClickOutside);
84
+ document.addEventListener('touchstart', handleClickOutside);
85
+ document.addEventListener('focusin', handleClickOutside);
86
+
87
+ return () => {
88
+ document.removeEventListener('mousedown', handleClickOutside);
89
+ document.removeEventListener('touchstart', handleClickOutside);
90
+ document.removeEventListener('focusin', handleClickOutside);
91
+ };
92
+ }, [dropdownRef]);
93
+
94
+ return (
95
+ <div
96
+ ref={dropdownRef}
97
+ className={clsx('navbar__item', 'dropdown', 'dropdown--hoverable', {
98
+ 'dropdown--right': position === 'right',
99
+ 'dropdown--show': showDropdown,
100
+ })}
101
+ >
102
+ <NavbarNavLink
103
+ aria-haspopup="true"
104
+ aria-expanded={showDropdown}
105
+ role="button"
106
+ // # hash permits to make the <a> tag focusable in case no link target
107
+ // See https://github.com/facebook/docusaurus/pull/6003
108
+ // There's probably a better solution though...
109
+ href={props.to ? undefined : '#'}
110
+ className={clsx('navbar__link', className)}
111
+ {...props}
112
+ onClick={props.to ? undefined : (e) => e.preventDefault()}
113
+ onKeyDown={(e) => {
114
+ if (e.key === 'Enter') {
115
+ e.preventDefault();
116
+ setShowDropdown(!showDropdown);
117
+ }
118
+ }}
119
+ >
120
+ {props.children ?? props.label}
121
+ </NavbarNavLink>
122
+ <ul className="dropdown__menu">
123
+ {items.map((childItemProps, i) => (
124
+ <NavbarItem
125
+ isDropdownItem
126
+ activeClassName="dropdown__link--active"
127
+ {...childItemProps}
128
+ key={i}
129
+ />
130
+ ))}
131
+ </ul>
132
+ </div>
133
+ );
134
+ }
135
+
136
+ function DropdownNavbarItemMobile({
137
+ items,
138
+ className,
139
+ position, // Need to destructure position from props so that it doesn't get passed on.
140
+ onClick,
141
+ ...props
142
+ }: DesktopOrMobileNavBarItemProps) {
143
+ const localPathname = useLocalPathname();
144
+ const containsActive = containsActiveItems(items, localPathname);
145
+
146
+ const { collapsed, toggleCollapsed, setCollapsed } = useCollapsible({
147
+ initialState: () => !containsActive,
148
+ });
149
+
150
+ // Expand/collapse if any item active after a navigation
151
+ useEffect(() => {
152
+ if (containsActive) {
153
+ setCollapsed(!containsActive);
154
+ }
155
+ }, [localPathname, containsActive, setCollapsed]);
156
+
157
+ return (
158
+ <li
159
+ className={clsx('menu__list-item', {
160
+ 'menu__list-item--collapsed': collapsed,
161
+ })}
162
+ >
163
+ <NavbarNavLink
164
+ role="button"
165
+ className={clsx(
166
+ styles.dropdownNavbarItemMobile,
167
+ 'menu__link menu__link--sublist',
168
+ className
169
+ )}
170
+ {...props}
171
+ onClick={(e) => {
172
+ e.preventDefault();
173
+ toggleCollapsed();
174
+ }}
175
+ >
176
+ {props.children ?? props.label}
177
+ </NavbarNavLink>
178
+ <Collapsible lazy as="ul" className="menu__list" collapsed={collapsed}>
179
+ {items.map((childItemProps, i) => (
180
+ <NavbarItem
181
+ mobile
182
+ isDropdownItem
183
+ onClick={onClick}
184
+ activeClassName="menu__link--active"
185
+ {...childItemProps}
186
+ key={i}
187
+ />
188
+ ))}
189
+ </Collapsible>
190
+ </li>
191
+ );
192
+ }
193
+
194
+ export default function DropdownNavbarItem({
195
+ mobile = false,
196
+ ...props
197
+ }: Props): JSX.Element {
198
+ const Comp = mobile ? DropdownNavbarItemMobile : DropdownNavbarItemDesktop;
199
+ return <Comp {...props} />;
200
+ }
@@ -0,0 +1,141 @@
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 { FunctionComponent, JSX } from 'react';
10
+ import Link from '@docusaurus/Link';
11
+ import useBaseUrl from '@docusaurus/useBaseUrl';
12
+ import isInternalUrl from '@docusaurus/isInternalUrl';
13
+ import { isRegexpStringMatch } from '@docusaurus/theme-common';
14
+ import IconExternalLink from '@theme-original/Icon/ExternalLink';
15
+ import type { Props as NavbarNavLinkProps } from '@theme-original/NavbarItem/NavbarNavLink';
16
+ import { IconType } from '@elastic/eui';
17
+
18
+ import { NavbarItem } from '../../components/navbar_item';
19
+
20
+ const CUSTOM_LINK_COMPONENT_MAP: Record<
21
+ string,
22
+ { component: FunctionComponent<any>; icon: IconType }
23
+ > = {
24
+ github: {
25
+ component: NavbarItem,
26
+ icon: () => (
27
+ <svg
28
+ width="16"
29
+ height="16"
30
+ viewBox="0 0 16 16"
31
+ fill="none"
32
+ xmlns="http://www.w3.org/2000/svg"
33
+ >
34
+ <path
35
+ fill="currentColor"
36
+ d="M8 0C3.58203 0 0 3.67167 0 8.2002C0 11.8238 2.292 14.8969 5.47119 15.981C5.87109 16.0561 6.01709 15.8028 6.01709 15.5866C6.01709 15.3914 6.00977 14.7447 6.00586 14.0601C3.78125 14.5555 3.31103 13.0931 3.31103 13.0931C2.94678 12.1461 2.42284 11.8939 2.42284 11.8939C1.6958 11.3854 2.478 11.3954 2.478 11.3954C3.28122 11.4524 3.70409 12.2402 3.70409 12.2402C4.41797 13.4935 5.57714 13.1311 6.03222 12.9209C6.10494 12.3924 6.31197 12.03 6.54003 11.8258C4.76416 11.6186 2.896 10.9149 2.896 7.77276C2.896 6.87686 3.20802 6.14615 3.71875 5.57207C3.6372 5.36386 3.36181 4.52952 3.79784 3.4009C3.79784 3.4009 4.46875 3.18069 5.99803 4.24175C6.63572 4.05907 7.31981 3.96898 7.99998 3.96597C8.67967 3.96898 9.36423 4.06006 10.0029 4.24274C11.5293 3.18068 12.2012 3.4019 12.2012 3.4019C12.6387 4.53152 12.3633 5.36485 12.2812 5.57207C12.7939 6.14615 13.1035 6.87688 13.1035 7.77276C13.1035 10.9229 11.2324 11.6166 9.4502 11.8198C9.7383 12.0741 9.99317 12.5726 9.99317 13.3373C9.99317 14.4334 9.98242 15.3173 9.98242 15.5876C9.98242 15.8058 10.1279 16.0611 10.5332 15.981C13.71 14.8949 16 11.8218 16 8.2002C16 3.67167 12.418 0 8 0Z"
37
+ />
38
+ </svg>
39
+ ),
40
+ },
41
+ changelog: {
42
+ component: NavbarItem,
43
+ icon: 'cheer',
44
+ },
45
+ figma: {
46
+ component: NavbarItem,
47
+ icon: () => (
48
+ <svg
49
+ width="16"
50
+ height="16"
51
+ viewBox="0 0 17 17"
52
+ fill="none"
53
+ xmlns="http://www.w3.org/2000/svg"
54
+ >
55
+ <path
56
+ fill="currentColor"
57
+ d="M12.5 6.5A2.5 2.5 0 0 0 11 2H6.5A2.5 2.5 0 0 0 5 6.5a2.5 2.5 0 0 0 .085 4.063A2.75 2.75 0 1 0 9.5 12.75V10.5a2.5 2.5 0 0 0 3-4Zm0-2A1.5 1.5 0 0 1 11 6H9.5V3H11a1.5 1.5 0 0 1 1.5 1.5ZM5 4.5A1.5 1.5 0 0 1 6.5 3h2v3h-2A1.5 1.5 0 0 1 5 4.5ZM6.5 10a1.5 1.5 0 0 1 0-3h2v3h-2Zm2 2.75A1.75 1.75 0 1 1 6.75 11H8.5v1.75ZM11 10a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3Z"
58
+ />
59
+ </svg>
60
+ ),
61
+ },
62
+ };
63
+
64
+ type Props = NavbarNavLinkProps & {
65
+ component: string;
66
+ };
67
+
68
+ export default function NavbarNavLink({
69
+ activeBasePath,
70
+ activeBaseRegex,
71
+ to,
72
+ href,
73
+ label,
74
+ html,
75
+ isDropdownLink,
76
+ prependBaseUrlToHref,
77
+ component,
78
+ ...props
79
+ }: Props): JSX.Element {
80
+ // TODO all this seems hacky
81
+ // {to: 'version'} should probably be forbidden, in favor of {to: '/version'}
82
+ const toUrl = useBaseUrl(to);
83
+ const activeBaseUrl = useBaseUrl(activeBasePath);
84
+ const normalizedHref = useBaseUrl(href, { forcePrependBaseUrl: true });
85
+ const isExternalLink = label && href && !isInternalUrl(href);
86
+
87
+ if (component != null && CUSTOM_LINK_COMPONENT_MAP[component] !== undefined) {
88
+ const componentData = CUSTOM_LINK_COMPONENT_MAP[component]!;
89
+ const Element = componentData.component;
90
+ return (
91
+ <Element
92
+ href={href}
93
+ title={label}
94
+ icon={componentData.icon}
95
+ className={props.className}
96
+ showLabel
97
+ />
98
+ );
99
+ }
100
+
101
+ // Link content is set through html XOR label
102
+ const linkContentProps = html
103
+ ? { dangerouslySetInnerHTML: { __html: html } }
104
+ : {
105
+ children: (
106
+ <>
107
+ {label}
108
+ {isExternalLink && (
109
+ <IconExternalLink
110
+ {...(isDropdownLink && { width: 12, height: 12 })}
111
+ />
112
+ )}
113
+ </>
114
+ ),
115
+ };
116
+
117
+ if (href) {
118
+ return (
119
+ <Link
120
+ href={prependBaseUrlToHref ? normalizedHref : href}
121
+ {...props}
122
+ {...linkContentProps}
123
+ />
124
+ );
125
+ }
126
+
127
+ return (
128
+ <Link
129
+ to={toUrl}
130
+ isNavLink
131
+ {...((activeBasePath || activeBaseRegex) && {
132
+ isActive: (_match, location) =>
133
+ activeBaseRegex
134
+ ? isRegexpStringMatch(activeBaseRegex, location.pathname)
135
+ : location.pathname.startsWith(activeBaseUrl),
136
+ })}
137
+ {...props}
138
+ {...linkContentProps}
139
+ />
140
+ );
141
+ }
@@ -0,0 +1,72 @@
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 Link from '@docusaurus/Link';
13
+ import type { Props } from '@theme-original/PaginatorNavLink';
14
+ import { useEuiMemoizedStyles, UseEuiTheme, EuiIcon } from '@elastic/eui';
15
+
16
+ const getStyles = ({ euiTheme }: UseEuiTheme) => {
17
+ return {
18
+ link: css`
19
+ --ifm-pagination-nav-color-hover: ${euiTheme.colors.primary};
20
+
21
+ border: ${euiTheme.border.thin};
22
+
23
+ .pagination-nav__label {
24
+ display: flex;
25
+ align-items: center;
26
+
27
+ font-size: var(--eui-font-size-m);
28
+ line-height: var(--eui-line-height-l);
29
+ }
30
+
31
+ &.pagination-nav__link--next .pagination-nav__label {
32
+ justify-content: flex-end;
33
+ }
34
+
35
+ .pagination-nav__label::before,
36
+ .pagination-nav__label::after {
37
+ content: '';
38
+ }
39
+
40
+ .pagination-nav__sublabel {
41
+ margin-block-end: ${euiTheme.size.xs};
42
+ font-size: var(--eui-font-size-s);
43
+ line-height: var(--eui-line-height-l);
44
+ }
45
+ `,
46
+ };
47
+ };
48
+
49
+ export default function PaginatorNavLink(props: Props): JSX.Element {
50
+ const { permalink, title, subLabel, isNext } = props;
51
+ const isPrev = !isNext;
52
+ const styles = useEuiMemoizedStyles(getStyles);
53
+
54
+ return (
55
+ <Link
56
+ className={clsx(
57
+ 'pagination-nav__link',
58
+ isNext ? 'pagination-nav__link--next' : 'pagination-nav__link--prev'
59
+ )}
60
+ css={styles.link}
61
+ to={permalink}
62
+ >
63
+ {subLabel && <div className="pagination-nav__sublabel">{subLabel}</div>}
64
+
65
+ <div className="pagination-nav__label">
66
+ {isPrev && <EuiIcon type="arrowLeft" />}
67
+ {title}
68
+ {isNext && <EuiIcon type="arrowRight" />}
69
+ </div>
70
+ </Link>
71
+ );
72
+ }
@@ -0,0 +1,122 @@
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 {
10
+ euiFontSizeFromScale,
11
+ euiLineHeightFromBaseline,
12
+ UseEuiTheme,
13
+ } from '@elastic/eui';
14
+ import { css } from '@emotion/react';
15
+
16
+ // override docusaurus variables as needed
17
+ // NOTE: we use define variables with style calculations here
18
+ // on the global level to reduce how often they are called
19
+ export const getGlobalStyles = (theme: UseEuiTheme) => {
20
+ const { euiTheme } = theme;
21
+ const { font, base, colors, size, components } = euiTheme;
22
+ const fontBodyScale = font.scale[font.body.scale];
23
+ const fontBase = {
24
+ fontFamily: font.family,
25
+ fontSize: `${
26
+ font.defaultUnits === 'px' ? fontBodyScale * base : fontBodyScale
27
+ }${font.defaultUnits}`,
28
+ fontWeight: font.weight[font.body.weight],
29
+ };
30
+
31
+ const fontSizeXXL = euiFontSizeFromScale('xxl', euiTheme);
32
+ const fontSizeXL = euiFontSizeFromScale('xl', euiTheme);
33
+ const fontSizeL = euiFontSizeFromScale('l', euiTheme);
34
+ const fontSizeM = euiFontSizeFromScale('m', euiTheme);
35
+ const fontSizeS = euiFontSizeFromScale('s', euiTheme);
36
+ const fontSizeXS = euiFontSizeFromScale('xs', euiTheme);
37
+ const fontSizeXXS = euiFontSizeFromScale('xxs', euiTheme);
38
+
39
+ const lineHeightXXL = '2rem';
40
+ const lineHeightXL = '1.75rem';
41
+ const lineHeightL = euiLineHeightFromBaseline('s', euiTheme);
42
+ const lineHeightM = '1.5rem';
43
+ const lineHeightS = euiLineHeightFromBaseline('xs', euiTheme);
44
+ const lineHeightXS = '1.33rem';
45
+ const lineHeightXXS = euiLineHeightFromBaseline('xxs', euiTheme);
46
+
47
+ return css`
48
+ // color theme related variables
49
+ :root,
50
+ [data-theme='dark']:root {
51
+ /* EUI theme variables */
52
+ --eui-background-color-primary: ${colors.backgroundBasePrimary};
53
+ --eui-background-color-success: ${colors.backgroundBaseSuccess};
54
+ --eui-background-color-danger: ${colors.backgroundBaseDanger};
55
+ --eui-background-color-warning: ${colors.backgroundBaseWarning};
56
+ --eui-background-color-accent: ${colors.backgroundBaseAccent};
57
+
58
+ --eui-color-danger-text: ${colors.textDanger};
59
+
60
+ /* Docusaurus theme variables */
61
+ --ifm-background-color: ${colors.backgroundBasePlain};
62
+ --ifm-font-color-base: ${colors.textParagraph};
63
+ --ifm-link-color: ${colors.link};
64
+ --ifm-link-hover-color: ${colors.link};
65
+
66
+ --ifm-menu-color: ${colors.textParagraph};
67
+ --ifm-menu-color-background-active: ${colors.backgroundBaseSubdued};
68
+ --ifm-menu-color-background-hover: var(--eui-background-color-primary);
69
+
70
+ --ifm-pre-background: ${components.codeBackground};
71
+ }
72
+
73
+ :root {
74
+ /* EUI theme variables */
75
+ --eui-font-size-base: ${fontBase.fontSize};
76
+ --eui-font-size-xxl: ${fontSizeXXL};
77
+ --eui-font-size-xl: ${fontSizeXL};
78
+ --eui-font-size-l: ${fontSizeL};
79
+ --eui-font-size-m: ${fontSizeM};
80
+ --eui-font-size-s: ${fontSizeS};
81
+ --eui-font-size-xs: ${fontSizeXS};
82
+ --eui-font-size-xxs: ${fontSizeXXS};
83
+
84
+ --eui-line-height-base: ${lineHeightXL};
85
+ --eui-line-height-xxl: ${lineHeightXXL};
86
+ --eui-line-height-xl: ${lineHeightXL};
87
+ --eui-line-height-l: ${lineHeightL};
88
+ --eui-line-height-m: ${lineHeightM};
89
+ --eui-line-height-s: ${lineHeightS};
90
+ --eui-line-height-xs: ${lineHeightXS};
91
+ --eui-line-height-xxs: ${lineHeightXXS};
92
+
93
+ --eui-size-xs: ${size.xs};
94
+ --eui-size-s: ${size.s};
95
+ --eui-size-m: ${size.m};
96
+
97
+ --eui-border-color-primary: ${colors.borderStrongPrimary};
98
+
99
+ --eui-theme-content-vertical-spacing: ${size.base};
100
+
101
+ /* Docusaurus theme variables */
102
+ --ifm-font-family-base: ${fontBase.fontFamily};
103
+ --ifm-font-size-base: var(--eui-font-size-base);
104
+ --ifm-font-weight-base: ${fontBase.fontWeight};
105
+ --ifm-line-height-base: var(--eui-line-height-base);
106
+
107
+ --ifm-h1-font-size: var(--eui-font-size-xl);
108
+ --ifm-h2-font-size: var(--eui-font-size-l);
109
+ --ifm-h3-font-size: var(--eui-font-size-m);
110
+ --ifm-h4-font-size: var(--eui-font-size-s);
111
+ --ifm-h5-font-size: var(--eui-font-size-xs);
112
+ --ifm-h6-font-size: var(--eui-font-size-xxs);
113
+
114
+ --ifm-global-radius: ${euiTheme.border.radius.small};
115
+
116
+ --ifm-toc-border-color: ${euiTheme.border.color};
117
+
118
+ --doc-sidebar-width: 258px;
119
+ --doc-sidebar-hidden-width: 30px;
120
+ }
121
+ `;
122
+ };
@@ -0,0 +1,106 @@
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 {
10
+ FunctionComponent,
11
+ PropsWithChildren,
12
+ useEffect,
13
+ useState,
14
+ } from 'react';
15
+ import Head from '@docusaurus/Head';
16
+ import chartsDarkThemeUrl from '!file-loader!@elastic/charts/dist/theme_only_dark.css';
17
+ import chartsLightThemeUrl from '!file-loader!@elastic/charts/dist/theme_only_light.css';
18
+ import { CacheProvider, css, Global } from '@emotion/react';
19
+ import { Props } from '@theme/Root';
20
+ import { useEuiTheme } from '@elastic/eui';
21
+
22
+ import {
23
+ AppThemeProvider,
24
+ cssGlobalCache,
25
+ useAppTheme,
26
+ } from '../components/theme_context';
27
+ import { getGlobalStyles } from './Root.styles';
28
+ import { getResetStyles } from './reset.styles';
29
+ import { getInfimaStyles } from './infima.styles';
30
+
31
+ const styles = {
32
+ root: css`
33
+ display: flex;
34
+ flex-direction: column;
35
+ min-height: 100vh;
36
+ `,
37
+ };
38
+
39
+ const _Root: FunctionComponent<PropsWithChildren> = ({ children }) => {
40
+ const { colorMode } = useAppTheme();
41
+ const [mounted, setMounted] = useState(false);
42
+
43
+ const euiTheme = useEuiTheme();
44
+ const globalStyles = getGlobalStyles(euiTheme);
45
+ const resetStyles = getResetStyles(euiTheme);
46
+ const infimaStyles = getInfimaStyles();
47
+
48
+ // NOTE: This is a temp. solution
49
+ // Emotion styles are loaded dynamically on client in contrast
50
+ // to Docusaurus' SSR content. By rendering the content only
51
+ // after mount we can prevent some quite noticeable style updates
52
+ // and layout shifts. The drawback is that the page initially loads blank.
53
+ // TODO: remove this once we have an approach to inject HTML server-side
54
+ useEffect(() => {
55
+ if (!mounted) {
56
+ setMounted(true);
57
+ }
58
+ }, []);
59
+
60
+ // Load chart theme CSS based on color mode
61
+ useEffect(() => {
62
+ if (colorMode !== 'light' && colorMode !== 'dark') {
63
+ return;
64
+ }
65
+
66
+ const element = document.createElement('link');
67
+ element.rel = 'stylesheet';
68
+ element.href =
69
+ colorMode === 'light' ? chartsLightThemeUrl : chartsDarkThemeUrl;
70
+ element.dataset.elasticChartsTheme = 'true';
71
+ document.head.appendChild(element);
72
+
73
+ return () => {
74
+ document.head.removeChild(element);
75
+ };
76
+ }, [colorMode]);
77
+
78
+ return (
79
+ <>
80
+ <Head>
81
+ <link
82
+ href="https://fonts.googleapis.com/css2?family=Inter:wght@300..700&family=Roboto+Mono:ital,wght@0,400..700;1,400..700&display=swap"
83
+ rel="stylesheet"
84
+ />
85
+ </Head>
86
+ <CacheProvider value={cssGlobalCache}>
87
+ <Global styles={[resetStyles, infimaStyles, globalStyles]} />
88
+ </CacheProvider>
89
+ <div style={!mounted ? { display: 'none' } : undefined} css={styles.root}>
90
+ {children}
91
+ </div>
92
+ </>
93
+ );
94
+ };
95
+
96
+ // Wrap docusaurus root component with <EuiProvider>
97
+ // See https://docusaurus.io/docs/swizzling#wrapper-your-site-with-root
98
+ const Root = ({ children }: Props) => {
99
+ return (
100
+ <AppThemeProvider>
101
+ <_Root>{children}</_Root>
102
+ </AppThemeProvider>
103
+ );
104
+ };
105
+
106
+ export default Root;
@@ -0,0 +1,53 @@
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 Translate from '@docusaurus/Translate';
13
+ import type { Props } from '@theme-original/TOCCollapsible/CollapseButton';
14
+ import { EuiIcon, useEuiMemoizedStyles, UseEuiTheme } from '@elastic/eui';
15
+
16
+ // coverted from css modules to Emotion
17
+ const getStyles = ({ euiTheme }: UseEuiTheme) => {
18
+ return {
19
+ tocCollapsibleButton: css`
20
+ display: flex;
21
+ justify-content: space-between;
22
+ align-items: center;
23
+ width: 100%;
24
+ padding: ${euiTheme.size.s} ${euiTheme.size.m};
25
+ border-radius: ${euiTheme.border.radius.small};
26
+ font-size: inherit;
27
+ `,
28
+ };
29
+ };
30
+
31
+ export default function TOCCollapsibleCollapseButton({
32
+ collapsed,
33
+ ...props
34
+ }: Props): JSX.Element {
35
+ const styles = useEuiMemoizedStyles(getStyles);
36
+
37
+ return (
38
+ <button
39
+ type="button"
40
+ {...props}
41
+ className={clsx('clean-btn', props.className)}
42
+ css={styles.tocCollapsibleButton}
43
+ >
44
+ <Translate
45
+ id="theme.TOCCollapsible.toggleButtonLabel"
46
+ description="The label used by the button on the collapsible TOC component"
47
+ >
48
+ On this page
49
+ </Translate>
50
+ <EuiIcon type={collapsed ? 'arrowDown' : 'arrowUp'} />
51
+ </button>
52
+ );
53
+ }