@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.
- package/LICENSE.txt +6 -0
- package/README.md +292 -0
- package/lib/.tsbuildinfo-client +1 -0
- package/lib/components/badge/index.d.ts +1 -0
- package/lib/components/badge/index.js +9 -0
- package/lib/components/codesandbox_icon/codesandbox_icon.d.ts +4 -0
- package/lib/components/codesandbox_icon/codesandbox_icon.js +2 -0
- package/lib/components/codesandbox_icon/index.d.ts +1 -0
- package/lib/components/codesandbox_icon/index.js +8 -0
- package/lib/components/demo/actions_bar/actions_bar.d.ts +10 -0
- package/lib/components/demo/actions_bar/actions_bar.js +34 -0
- package/lib/components/demo/actions_bar/index.d.ts +1 -0
- package/lib/components/demo/actions_bar/index.js +8 -0
- package/lib/components/demo/code_transformer.d.ts +18 -0
- package/lib/components/demo/code_transformer.js +39 -0
- package/lib/components/demo/codesandbox/find_external_dependencies.d.ts +5 -0
- package/lib/components/demo/codesandbox/find_external_dependencies.js +30 -0
- package/lib/components/demo/codesandbox/index.d.ts +1 -0
- package/lib/components/demo/codesandbox/index.js +8 -0
- package/lib/components/demo/codesandbox/open_action.d.ts +16 -0
- package/lib/components/demo/codesandbox/open_action.js +91 -0
- package/lib/components/demo/context.d.ts +14 -0
- package/lib/components/demo/context.js +13 -0
- package/lib/components/demo/create_demo.d.ts +5 -0
- package/lib/components/demo/create_demo.js +13 -0
- package/lib/components/demo/demo.d.ts +23 -0
- package/lib/components/demo/demo.js +61 -0
- package/lib/components/demo/editor/editor.d.ts +1 -0
- package/lib/components/demo/editor/editor.js +39 -0
- package/lib/components/demo/editor/index.d.ts +1 -0
- package/lib/components/demo/editor/index.js +8 -0
- package/lib/components/demo/index.d.ts +3 -0
- package/lib/components/demo/index.js +10 -0
- package/lib/components/demo/preview/index.d.ts +1 -0
- package/lib/components/demo/preview/index.js +8 -0
- package/lib/components/demo/preview/preview.d.ts +7 -0
- package/lib/components/demo/preview/preview.js +36 -0
- package/lib/components/demo/scope.d.ts +1 -0
- package/lib/components/demo/scope.js +12 -0
- package/lib/components/demo/source/get_source_from_children.d.ts +11 -0
- package/lib/components/demo/source/get_source_from_children.js +42 -0
- package/lib/components/demo/source/index.d.ts +1 -0
- package/lib/components/demo/source/index.js +8 -0
- package/lib/components/demo/source/source.d.ts +6 -0
- package/lib/components/demo/source/source.js +25 -0
- package/lib/components/figma_embed/index.d.ts +5 -0
- package/lib/components/figma_embed/index.js +36 -0
- package/lib/components/guideline/guideline.d.ts +10 -0
- package/lib/components/guideline/guideline.js +68 -0
- package/lib/components/guideline/guideline_text.d.ts +6 -0
- package/lib/components/guideline/guideline_text.js +28 -0
- package/lib/components/guideline/index.d.ts +2 -0
- package/lib/components/guideline/index.js +9 -0
- package/lib/components/guideline/types.d.ts +1 -0
- package/lib/components/guideline/types.js +8 -0
- package/lib/components/high_contrast_mode_toggle/index.d.ts +1 -0
- package/lib/components/high_contrast_mode_toggle/index.js +15 -0
- package/lib/components/icon/index.d.ts +1 -0
- package/lib/components/icon/index.js +9 -0
- package/lib/components/index.d.ts +7 -0
- package/lib/components/index.js +14 -0
- package/lib/components/navbar_item/index.d.ts +19 -0
- package/lib/components/navbar_item/index.js +84 -0
- package/lib/components/prop_table/definition_types.d.ts +43 -0
- package/lib/components/prop_table/definition_types.js +8 -0
- package/lib/components/prop_table/extended_types.d.ts +5 -0
- package/lib/components/prop_table/extended_types.js +27 -0
- package/lib/components/prop_table/extended_types_info.d.ts +26 -0
- package/lib/components/prop_table/extended_types_info.js +34 -0
- package/lib/components/prop_table/index.d.ts +1 -0
- package/lib/components/prop_table/index.js +8 -0
- package/lib/components/prop_table/prop_table.d.ts +8 -0
- package/lib/components/prop_table/prop_table.js +115 -0
- package/lib/components/theme_context/index.d.ts +16 -0
- package/lib/components/theme_context/index.js +103 -0
- package/lib/components/theme_context/theme_overrides.d.ts +2 -0
- package/lib/components/theme_context/theme_overrides.js +12 -0
- package/lib/components/version_switcher/index.d.ts +23 -0
- package/lib/components/version_switcher/index.js +51 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +19 -0
- package/lib/index.js.map +1 -0
- package/lib/theme/Admonition/Types.d.ts +3 -0
- package/lib/theme/Admonition/Types.js +51 -0
- package/lib/theme/CodeBlock/index.d.ts +3 -0
- package/lib/theme/CodeBlock/index.js +35 -0
- package/lib/theme/ColorModeToggle/index.d.ts +10 -0
- package/lib/theme/ColorModeToggle/index.js +51 -0
- package/lib/theme/Demo/actions.d.ts +8 -0
- package/lib/theme/Demo/actions.js +8 -0
- package/lib/theme/Demo/default_scope.d.ts +3 -0
- package/lib/theme/Demo/default_scope.js +17 -0
- package/lib/theme/DocBreadcrumbs/Items/Home/index.d.ts +2 -0
- package/lib/theme/DocBreadcrumbs/Items/Home/index.js +15 -0
- package/lib/theme/DocBreadcrumbs/Items/item.styles.d.ts +5 -0
- package/lib/theme/DocBreadcrumbs/Items/item.styles.js +40 -0
- package/lib/theme/DocBreadcrumbs/index.d.ts +2 -0
- package/lib/theme/DocBreadcrumbs/index.js +63 -0
- package/lib/theme/DocItem/Content/index.d.ts +3 -0
- package/lib/theme/DocItem/Content/index.js +44 -0
- package/lib/theme/DocItem/Footer/index.d.ts +2 -0
- package/lib/theme/DocItem/Footer/index.js +17 -0
- package/lib/theme/DocItem/Layout/index.d.ts +3 -0
- package/lib/theme/DocItem/Layout/index.js +71 -0
- package/lib/theme/DocItem/Metadata/index.d.ts +2 -0
- package/lib/theme/DocItem/Metadata/index.js +7 -0
- package/lib/theme/DocItem/Paginator/index.d.ts +6 -0
- package/lib/theme/DocItem/Paginator/index.js +11 -0
- package/lib/theme/DocItem/TOC/Desktop/index.d.ts +2 -0
- package/lib/theme/DocItem/TOC/Desktop/index.js +8 -0
- package/lib/theme/DocItem/TOC/Mobile/index.d.ts +2 -0
- package/lib/theme/DocItem/TOC/Mobile/index.js +17 -0
- package/lib/theme/DocItem/index.d.ts +3 -0
- package/lib/theme/DocItem/index.js +10 -0
- package/lib/theme/DocPaginator/index.d.ts +3 -0
- package/lib/theme/DocPaginator/index.js +19 -0
- package/lib/theme/DocRoot/Layout/Main/index.d.ts +3 -0
- package/lib/theme/DocRoot/Layout/Main/index.js +35 -0
- package/lib/theme/DocRoot/Layout/Sidebar/index.d.ts +3 -0
- package/lib/theme/DocRoot/Layout/Sidebar/index.js +81 -0
- package/lib/theme/DocRoot/Layout/index.d.ts +3 -0
- package/lib/theme/DocRoot/Layout/index.js +47 -0
- package/lib/theme/DocSidebarItem/Category/index.d.ts +3 -0
- package/lib/theme/DocSidebarItem/Category/index.js +146 -0
- package/lib/theme/DocSidebarItem/Link/index.d.ts +3 -0
- package/lib/theme/DocSidebarItem/Link/index.js +39 -0
- package/lib/theme/DocSidebarItem/index.d.ts +3 -0
- package/lib/theme/DocSidebarItem/index.js +15 -0
- package/lib/theme/DocSidebarItems/index.d.ts +5 -0
- package/lib/theme/DocSidebarItems/index.js +17 -0
- package/lib/theme/EditThisPage/index.d.ts +3 -0
- package/lib/theme/EditThisPage/index.js +17 -0
- package/lib/theme/Footer/index.d.ts +2 -0
- package/lib/theme/Footer/index.js +43 -0
- package/lib/theme/Heading/index.d.ts +3 -0
- package/lib/theme/Heading/index.js +49 -0
- package/lib/theme/Logo/index.d.ts +3 -0
- package/lib/theme/Logo/index.js +80 -0
- package/lib/theme/MDXComponents/A.d.ts +6 -0
- package/lib/theme/MDXComponents/A.js +17 -0
- package/lib/theme/MDXComponents/Blockquote.d.ts +2 -0
- package/lib/theme/MDXComponents/Blockquote.js +18 -0
- package/lib/theme/MDXComponents/Code.d.ts +6 -0
- package/lib/theme/MDXComponents/Code.js +35 -0
- package/lib/theme/MDXComponents/Heading.d.ts +4 -0
- package/lib/theme/MDXComponents/Heading.js +4 -0
- package/lib/theme/MDXComponents/ListItem.d.ts +2 -0
- package/lib/theme/MDXComponents/ListItem.js +5 -0
- package/lib/theme/MDXComponents/OrderedList.d.ts +2 -0
- package/lib/theme/MDXComponents/OrderedList.js +11 -0
- package/lib/theme/MDXComponents/Paragraph.d.ts +2 -0
- package/lib/theme/MDXComponents/Paragraph.js +18 -0
- package/lib/theme/MDXComponents/Table.d.ts +2 -0
- package/lib/theme/MDXComponents/Table.js +3 -0
- package/lib/theme/MDXComponents/TableBody.d.ts +2 -0
- package/lib/theme/MDXComponents/TableBody.js +3 -0
- package/lib/theme/MDXComponents/TableDataCell.d.ts +2 -0
- package/lib/theme/MDXComponents/TableDataCell.js +3 -0
- package/lib/theme/MDXComponents/TableHeader.d.ts +2 -0
- package/lib/theme/MDXComponents/TableHeader.js +3 -0
- package/lib/theme/MDXComponents/TableHeaderCell.d.ts +2 -0
- package/lib/theme/MDXComponents/TableHeaderCell.js +3 -0
- package/lib/theme/MDXComponents/TableRow.d.ts +2 -0
- package/lib/theme/MDXComponents/TableRow.js +3 -0
- package/lib/theme/MDXComponents/UnorderedList.d.ts +2 -0
- package/lib/theme/MDXComponents/UnorderedList.js +11 -0
- package/lib/theme/MDXComponents/index.d.ts +2 -0
- package/lib/theme/MDXComponents/index.js +46 -0
- package/lib/theme/MDXContent/index.d.ts +6 -0
- package/lib/theme/MDXContent/index.js +4 -0
- package/lib/theme/Navbar/Content/index.d.ts +7 -0
- package/lib/theme/Navbar/Content/index.js +149 -0
- package/lib/theme/Navbar/Layout/index.d.ts +6 -0
- package/lib/theme/Navbar/Layout/index.js +59 -0
- package/lib/theme/Navbar/MobileSidebar/Header/index.d.ts +7 -0
- package/lib/theme/Navbar/MobileSidebar/Header/index.js +46 -0
- package/lib/theme/Navbar/MobileSidebar/Layout/index.d.ts +6 -0
- package/lib/theme/Navbar/MobileSidebar/Layout/index.js +26 -0
- package/lib/theme/Navbar/MobileSidebar/index.d.ts +7 -0
- package/lib/theme/Navbar/MobileSidebar/index.js +14 -0
- package/lib/theme/NavbarItem/DropdownNavbarItem/index.d.ts +3 -0
- package/lib/theme/NavbarItem/DropdownNavbarItem/index.js +94 -0
- package/lib/theme/NavbarItem/NavbarNavLink.d.ts +7 -0
- package/lib/theme/NavbarItem/NavbarNavLink.js +48 -0
- package/lib/theme/PaginatorNavLink/index.d.ts +3 -0
- package/lib/theme/PaginatorNavLink/index.js +43 -0
- package/lib/theme/Root.d.ts +3 -0
- package/lib/theme/Root.js +66 -0
- package/lib/theme/Root.styles.d.ts +2 -0
- package/lib/theme/Root.styles.js +111 -0
- package/lib/theme/TOCCollapsible/CollapseButton/index.d.ts +3 -0
- package/lib/theme/TOCCollapsible/CollapseButton/index.js +23 -0
- package/lib/theme/TOCItems/Tree.d.ts +5 -0
- package/lib/theme/TOCItems/Tree.js +80 -0
- package/lib/theme/infima.styles.d.ts +1 -0
- package/lib/theme/infima.styles.js +1456 -0
- package/lib/theme/reset.styles.d.ts +2 -0
- package/lib/theme/reset.styles.js +79 -0
- package/package.json +61 -0
- package/src/components/badge/index.ts +11 -0
- package/src/components/codesandbox_icon/codesandbox_icon.tsx +24 -0
- package/src/components/codesandbox_icon/index.ts +9 -0
- package/src/components/demo/actions_bar/actions_bar.tsx +95 -0
- package/src/components/demo/actions_bar/index.ts +9 -0
- package/src/components/demo/code_transformer.ts +44 -0
- package/src/components/demo/codesandbox/find_external_dependencies.ts +34 -0
- package/src/components/demo/codesandbox/index.ts +9 -0
- package/src/components/demo/codesandbox/open_action.tsx +132 -0
- package/src/components/demo/context.ts +30 -0
- package/src/components/demo/create_demo.tsx +17 -0
- package/src/components/demo/demo.tsx +143 -0
- package/src/components/demo/editor/editor.tsx +51 -0
- package/src/components/demo/editor/index.ts +9 -0
- package/src/components/demo/index.ts +11 -0
- package/src/components/demo/preview/index.ts +9 -0
- package/src/components/demo/preview/preview.tsx +77 -0
- package/src/components/demo/scope.ts +14 -0
- package/src/components/demo/source/get_source_from_children.ts +59 -0
- package/src/components/demo/source/index.ts +9 -0
- package/src/components/demo/source/source.tsx +36 -0
- package/src/components/figma_embed/index.tsx +57 -0
- package/src/components/guideline/guideline.tsx +121 -0
- package/src/components/guideline/guideline_text.tsx +51 -0
- package/src/components/guideline/index.ts +10 -0
- package/src/components/guideline/types.ts +9 -0
- package/src/components/high_contrast_mode_toggle/index.tsx +28 -0
- package/src/components/icon/index.ts +11 -0
- package/src/components/index.ts +15 -0
- package/src/components/navbar_item/index.tsx +164 -0
- package/src/components/prop_table/definition_types.ts +53 -0
- package/src/components/prop_table/extended_types.tsx +66 -0
- package/src/components/prop_table/extended_types_info.ts +35 -0
- package/src/components/prop_table/index.ts +9 -0
- package/src/components/prop_table/prop_table.tsx +235 -0
- package/src/components/theme_context/index.tsx +156 -0
- package/src/components/theme_context/theme_overrides.ts +15 -0
- package/src/components/version_switcher/index.tsx +144 -0
- package/src/index.ts +21 -0
- package/src/theme/Admonition/Types.tsx +85 -0
- package/src/theme/CodeBlock/index.tsx +57 -0
- package/src/theme/ColorModeToggle/index.tsx +93 -0
- package/src/theme/Demo/actions.tsx +20 -0
- package/src/theme/Demo/default_scope.ts +19 -0
- package/src/theme/DocBreadcrumbs/Items/Home/index.tsx +38 -0
- package/src/theme/DocBreadcrumbs/Items/item.styles.ts +43 -0
- package/src/theme/DocBreadcrumbs/index.tsx +144 -0
- package/src/theme/DocItem/Content/index.tsx +75 -0
- package/src/theme/DocItem/Footer/index.tsx +59 -0
- package/src/theme/DocItem/Layout/index.tsx +112 -0
- package/src/theme/DocItem/Metadata/index.tsx +23 -0
- package/src/theme/DocItem/Paginator/index.tsx +20 -0
- package/src/theme/DocItem/TOC/Desktop/index.tsx +24 -0
- package/src/theme/DocItem/TOC/Mobile/index.tsx +35 -0
- package/src/theme/DocItem/index.tsx +30 -0
- package/src/theme/DocPaginator/index.tsx +64 -0
- package/src/theme/DocRoot/Layout/Main/index.tsx +61 -0
- package/src/theme/DocRoot/Layout/Sidebar/index.tsx +124 -0
- package/src/theme/DocRoot/Layout/index.tsx +72 -0
- package/src/theme/DocSidebarItem/Category/index.tsx +266 -0
- package/src/theme/DocSidebarItem/Link/index.tsx +86 -0
- package/src/theme/DocSidebarItem/index.tsx +29 -0
- package/src/theme/DocSidebarItems/index.tsx +30 -0
- package/src/theme/EditThisPage/index.tsx +50 -0
- package/src/theme/Footer/index.tsx +67 -0
- package/src/theme/Heading/index.tsx +94 -0
- package/src/theme/Logo/index.tsx +146 -0
- package/src/theme/MDXComponents/A.tsx +33 -0
- package/src/theme/MDXComponents/Blockquote.tsx +35 -0
- package/src/theme/MDXComponents/Code.tsx +60 -0
- package/src/theme/MDXComponents/Heading.tsx +16 -0
- package/src/theme/MDXComponents/ListItem.tsx +20 -0
- package/src/theme/MDXComponents/OrderedList.tsx +26 -0
- package/src/theme/MDXComponents/Paragraph.tsx +33 -0
- package/src/theme/MDXComponents/Table.tsx +16 -0
- package/src/theme/MDXComponents/TableBody.tsx +16 -0
- package/src/theme/MDXComponents/TableDataCell.tsx +20 -0
- package/src/theme/MDXComponents/TableHeader.tsx +16 -0
- package/src/theme/MDXComponents/TableHeaderCell.tsx +20 -0
- package/src/theme/MDXComponents/TableRow.tsx +16 -0
- package/src/theme/MDXComponents/UnorderedList.tsx +26 -0
- package/src/theme/MDXComponents/index.ts +61 -0
- package/src/theme/MDXContent/index.tsx +22 -0
- package/src/theme/Navbar/Content/index.tsx +262 -0
- package/src/theme/Navbar/Layout/index.tsx +100 -0
- package/src/theme/Navbar/MobileSidebar/Header/index.tsx +89 -0
- package/src/theme/Navbar/MobileSidebar/Layout/index.tsx +44 -0
- package/src/theme/Navbar/MobileSidebar/index.tsx +46 -0
- package/src/theme/NavbarItem/DropdownNavbarItem/index.tsx +200 -0
- package/src/theme/NavbarItem/NavbarNavLink.tsx +141 -0
- package/src/theme/PaginatorNavLink/index.tsx +72 -0
- package/src/theme/Root.styles.ts +122 -0
- package/src/theme/Root.tsx +106 -0
- package/src/theme/TOCCollapsible/CollapseButton/index.tsx +53 -0
- package/src/theme/TOCItems/Tree.tsx +114 -0
- package/src/theme/infima.styles.ts +1458 -0
- package/src/theme/reset.styles.ts +82 -0
- package/src/theme/theme.d.ts +598 -0
|
@@ -0,0 +1,156 @@
|
|
|
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
|
+
createContext,
|
|
11
|
+
FunctionComponent,
|
|
12
|
+
PropsWithChildren,
|
|
13
|
+
useContext,
|
|
14
|
+
useEffect,
|
|
15
|
+
useState,
|
|
16
|
+
} from 'react';
|
|
17
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
18
|
+
import createCache from '@emotion/cache';
|
|
19
|
+
import { CacheProvider } from '@emotion/react';
|
|
20
|
+
import { EuiProvider, EuiThemeColorMode } from '@elastic/eui';
|
|
21
|
+
import { EuiThemeBorealis } from '@elastic/eui-theme-borealis';
|
|
22
|
+
import { type EUI_THEME } from '@elastic/eui-theme-common';
|
|
23
|
+
|
|
24
|
+
import { EuiThemeOverrides } from './theme_overrides';
|
|
25
|
+
|
|
26
|
+
export const AVAILABLE_THEMES: EUI_THEME[] = [
|
|
27
|
+
{
|
|
28
|
+
text: 'Borealis',
|
|
29
|
+
value: EuiThemeBorealis.key,
|
|
30
|
+
provider: EuiThemeBorealis,
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const EUI_COLOR_MODES = ['light', 'dark'] as const;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Get the initial color mode: localStorage | light
|
|
38
|
+
*/
|
|
39
|
+
const getInitialColorMode = (): EuiThemeColorMode => {
|
|
40
|
+
const storedColorMode = localStorage.getItem('colorMode');
|
|
41
|
+
|
|
42
|
+
if (storedColorMode === 'light' || storedColorMode === 'dark') {
|
|
43
|
+
return storedColorMode;
|
|
44
|
+
} else {
|
|
45
|
+
return defaultState.colorMode;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export interface AppThemeContextData {
|
|
50
|
+
colorMode: EuiThemeColorMode;
|
|
51
|
+
highContrastMode: boolean | undefined;
|
|
52
|
+
theme: EUI_THEME;
|
|
53
|
+
changeColorMode: (colorMode: EuiThemeColorMode) => void;
|
|
54
|
+
changeHighContrastMode: (highContrastMode: boolean) => void;
|
|
55
|
+
changeTheme: (themeValue: string) => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const defaultState: AppThemeContextData = {
|
|
59
|
+
colorMode: EUI_COLOR_MODES[0],
|
|
60
|
+
highContrastMode: undefined,
|
|
61
|
+
theme: AVAILABLE_THEMES[0] as EUI_THEME,
|
|
62
|
+
changeColorMode: () => {},
|
|
63
|
+
changeHighContrastMode: () => {},
|
|
64
|
+
changeTheme: () => {},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Creating a cache and passing it to EuiProvider ensures that injected
|
|
69
|
+
* Emotion style tags dev mode are in an expected order (global css before component css).
|
|
70
|
+
* This only applies for @emotion/react css styles, @emotion/css styles are separate.
|
|
71
|
+
*/
|
|
72
|
+
const cssCache = createCache({
|
|
73
|
+
key: 'website-css',
|
|
74
|
+
prepend: false,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export const cssGlobalCache = createCache({
|
|
78
|
+
key: 'website-css',
|
|
79
|
+
prepend: true,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export const AppThemeContext = createContext<AppThemeContextData>(defaultState);
|
|
83
|
+
|
|
84
|
+
export const useAppTheme: () => AppThemeContextData = () => {
|
|
85
|
+
return useContext(AppThemeContext);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const AppThemeProvider: FunctionComponent<PropsWithChildren> = ({
|
|
89
|
+
children,
|
|
90
|
+
}) => {
|
|
91
|
+
const isBrowser = useIsBrowser();
|
|
92
|
+
|
|
93
|
+
const [colorMode, setColorMode] = useState<EuiThemeColorMode>(() => {
|
|
94
|
+
if (isBrowser) return getInitialColorMode();
|
|
95
|
+
return defaultState.colorMode;
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const [highContrastMode, setHighContrastMode] = useState<boolean | undefined>(
|
|
99
|
+
false
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const getHighContrastModeSetting = () => {
|
|
103
|
+
return localStorage?.getItem('highContrastMode')
|
|
104
|
+
? localStorage?.getItem('highContrastMode') === 'true'
|
|
105
|
+
: defaultState.highContrastMode;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (isBrowser) {
|
|
110
|
+
setHighContrastMode(getHighContrastModeSetting());
|
|
111
|
+
}
|
|
112
|
+
}, [isBrowser]);
|
|
113
|
+
|
|
114
|
+
const [theme, setTheme] = useState<EUI_THEME>(defaultState.theme);
|
|
115
|
+
|
|
116
|
+
const handleChangeTheme = (themeValue: string) => {
|
|
117
|
+
const matchedTheme = AVAILABLE_THEMES.find((t) => t.value === themeValue);
|
|
118
|
+
setTheme((currentTheme) => matchedTheme ?? currentTheme);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const handleChangeHighContrastMode = (highContrastMode: boolean) => {
|
|
122
|
+
localStorage.setItem('highContrastMode', highContrastMode.toString());
|
|
123
|
+
setHighContrastMode(highContrastMode);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const handleColorMode = (colorMode: EuiThemeColorMode) => {
|
|
127
|
+
localStorage.setItem('colorMode', colorMode);
|
|
128
|
+
setColorMode(colorMode);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<AppThemeContext.Provider
|
|
133
|
+
value={{
|
|
134
|
+
colorMode,
|
|
135
|
+
highContrastMode,
|
|
136
|
+
theme,
|
|
137
|
+
changeColorMode: handleColorMode,
|
|
138
|
+
changeHighContrastMode: handleChangeHighContrastMode,
|
|
139
|
+
changeTheme: handleChangeTheme,
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
<EuiProvider
|
|
143
|
+
modify={EuiThemeOverrides}
|
|
144
|
+
colorMode={colorMode}
|
|
145
|
+
theme={theme.provider}
|
|
146
|
+
highContrastMode={highContrastMode}
|
|
147
|
+
cache={{
|
|
148
|
+
default: cssCache,
|
|
149
|
+
global: cssGlobalCache,
|
|
150
|
+
}}
|
|
151
|
+
>
|
|
152
|
+
<CacheProvider value={cssCache}>{children}</CacheProvider>
|
|
153
|
+
</EuiProvider>
|
|
154
|
+
</AppThemeContext.Provider>
|
|
155
|
+
);
|
|
156
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
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 { EuiThemeModifications } from '@elastic/eui';
|
|
10
|
+
|
|
11
|
+
export const EuiThemeOverrides: EuiThemeModifications = {
|
|
12
|
+
font: {
|
|
13
|
+
lineHeightMultiplier: 1.75,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
@@ -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 { ComponentProps, useState } from 'react';
|
|
10
|
+
import { css } from '@emotion/react';
|
|
11
|
+
import { FixedSizeList } from 'react-window';
|
|
12
|
+
import {
|
|
13
|
+
EuiButtonEmpty,
|
|
14
|
+
euiFocusRing,
|
|
15
|
+
EuiListGroupItem,
|
|
16
|
+
EuiPopover,
|
|
17
|
+
useEuiMemoizedStyles,
|
|
18
|
+
UseEuiTheme,
|
|
19
|
+
} from '@elastic/eui';
|
|
20
|
+
|
|
21
|
+
const getStyles = (euiThemeContext: UseEuiTheme) => {
|
|
22
|
+
const { euiTheme } = euiThemeContext;
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
button: css`
|
|
26
|
+
font-weight: ${euiTheme.font.weight.bold};
|
|
27
|
+
color: ${euiTheme.colors.primary};
|
|
28
|
+
`,
|
|
29
|
+
listItem: css`
|
|
30
|
+
.euiListGroupItem__button:focus-visible {
|
|
31
|
+
// overriding the global "outset" style to ensure the focus style is not cut off
|
|
32
|
+
${euiFocusRing(euiThemeContext, 'inset', {
|
|
33
|
+
color: euiTheme.colors.primary,
|
|
34
|
+
})};
|
|
35
|
+
}
|
|
36
|
+
`,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Addresses NVDA pronunciation issue
|
|
42
|
+
*/
|
|
43
|
+
const pronounceVersion = (version: string) => {
|
|
44
|
+
return `version ${version.replaceAll('.', ' point ')}`;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type VersionSwitcherProps = {
|
|
48
|
+
/**
|
|
49
|
+
* Aria label for the version switcher popover
|
|
50
|
+
*/
|
|
51
|
+
ariaLabel: string;
|
|
52
|
+
/*
|
|
53
|
+
* The current version of the documentation
|
|
54
|
+
*/
|
|
55
|
+
currentVersion: string;
|
|
56
|
+
/**
|
|
57
|
+
* Extra action to be displayed in the version switcher
|
|
58
|
+
*/
|
|
59
|
+
extraAction?: (
|
|
60
|
+
version?: string
|
|
61
|
+
) => ComponentProps<typeof EuiListGroupItem>['extraAction'];
|
|
62
|
+
/**
|
|
63
|
+
* URL to the previous version of the documentation
|
|
64
|
+
* E.g. https://eui.elastic.co
|
|
65
|
+
*/
|
|
66
|
+
previousVersionUrl?: string;
|
|
67
|
+
/**
|
|
68
|
+
* List of available versions to switch to
|
|
69
|
+
*/
|
|
70
|
+
versions: string[];
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const VersionSwitcher = ({
|
|
74
|
+
ariaLabel,
|
|
75
|
+
currentVersion,
|
|
76
|
+
extraAction,
|
|
77
|
+
previousVersionUrl,
|
|
78
|
+
versions,
|
|
79
|
+
}: VersionSwitcherProps) => {
|
|
80
|
+
const [isPopoverOpen, setPopoverOpen] = useState(false);
|
|
81
|
+
const styles = useEuiMemoizedStyles(getStyles);
|
|
82
|
+
|
|
83
|
+
if (!versions) return null;
|
|
84
|
+
|
|
85
|
+
const button = (
|
|
86
|
+
<EuiButtonEmpty
|
|
87
|
+
size="s"
|
|
88
|
+
color="text"
|
|
89
|
+
iconType="arrowDown"
|
|
90
|
+
iconSide="right"
|
|
91
|
+
css={styles.button}
|
|
92
|
+
onClick={() => setPopoverOpen((isOpen) => !isOpen)}
|
|
93
|
+
aria-label={`${pronounceVersion(
|
|
94
|
+
currentVersion
|
|
95
|
+
)}. Click to switch versions`}
|
|
96
|
+
>
|
|
97
|
+
v{currentVersion}
|
|
98
|
+
</EuiButtonEmpty>
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<EuiPopover
|
|
103
|
+
isOpen={isPopoverOpen}
|
|
104
|
+
closePopover={() => setPopoverOpen(false)}
|
|
105
|
+
button={button}
|
|
106
|
+
repositionOnScroll
|
|
107
|
+
panelPaddingSize="xs"
|
|
108
|
+
aria-label={ariaLabel}
|
|
109
|
+
>
|
|
110
|
+
<FixedSizeList
|
|
111
|
+
className="eui-yScroll"
|
|
112
|
+
itemCount={versions.length}
|
|
113
|
+
itemSize={24}
|
|
114
|
+
height={200}
|
|
115
|
+
width={120}
|
|
116
|
+
innerElementType="ul"
|
|
117
|
+
>
|
|
118
|
+
{({ index, style }) => {
|
|
119
|
+
const version = versions[index];
|
|
120
|
+
const isCurrentVersion = version === currentVersion;
|
|
121
|
+
const screenReaderVersion = pronounceVersion(version!);
|
|
122
|
+
|
|
123
|
+
const url = isCurrentVersion
|
|
124
|
+
? '/'
|
|
125
|
+
: `${previousVersionUrl}/v${version}/`;
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<EuiListGroupItem
|
|
129
|
+
css={styles.listItem}
|
|
130
|
+
style={style}
|
|
131
|
+
size="xs"
|
|
132
|
+
label={`v${version}`}
|
|
133
|
+
aria-label={screenReaderVersion}
|
|
134
|
+
href={url}
|
|
135
|
+
isActive={isCurrentVersion}
|
|
136
|
+
color={isCurrentVersion ? 'primary' : 'text'}
|
|
137
|
+
extraAction={extraAction?.(version)}
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
140
|
+
}}
|
|
141
|
+
</FixedSizeList>
|
|
142
|
+
</EuiPopover>
|
|
143
|
+
);
|
|
144
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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 { Plugin } from '@docusaurus/types';
|
|
10
|
+
|
|
11
|
+
export default function euiDocusaurusTheme(): Plugin<void> {
|
|
12
|
+
return {
|
|
13
|
+
name: 'eui-docusaurus-theme',
|
|
14
|
+
getThemePath() {
|
|
15
|
+
return '../lib/theme';
|
|
16
|
+
},
|
|
17
|
+
getTypeScriptThemePath() {
|
|
18
|
+
return '../src/theme';
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
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 { css } from '@emotion/react';
|
|
10
|
+
import { EuiCallOut, EuiText } from '@elastic/eui';
|
|
11
|
+
import type { Props } from '@theme-original/Admonition';
|
|
12
|
+
import type AdmonitionTypes from '@theme-original/Admonition/Types';
|
|
13
|
+
|
|
14
|
+
type CalloutVariant =
|
|
15
|
+
| 'note'
|
|
16
|
+
| 'tip'
|
|
17
|
+
| 'info'
|
|
18
|
+
| 'accessibility'
|
|
19
|
+
| 'warning'
|
|
20
|
+
| 'danger'
|
|
21
|
+
| 'secondary'
|
|
22
|
+
| 'important'
|
|
23
|
+
| 'success'
|
|
24
|
+
| 'caution';
|
|
25
|
+
type VariantColor = 'accent' | 'primary' | 'success' | 'warning' | 'danger';
|
|
26
|
+
|
|
27
|
+
const VARIANT_TO_PROPS_MAP: Record<
|
|
28
|
+
CalloutVariant,
|
|
29
|
+
{ iconType?: string; color?: VariantColor }
|
|
30
|
+
> = {
|
|
31
|
+
note: { iconType: 'paperClip', color: 'accent' },
|
|
32
|
+
tip: { iconType: 'faceHappy', color: 'success' },
|
|
33
|
+
info: { iconType: 'info', color: 'primary' },
|
|
34
|
+
accessibility: { iconType: 'accessibility', color: 'primary' },
|
|
35
|
+
warning: { iconType: 'alert', color: 'warning' },
|
|
36
|
+
danger: { iconType: 'error', color: 'danger' },
|
|
37
|
+
// Undocumented legacy admonition type aliases
|
|
38
|
+
secondary: {},
|
|
39
|
+
important: {},
|
|
40
|
+
success: {},
|
|
41
|
+
caution: {},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// MDXComponents/Paragraph wraps <p> in <EuiText>,
|
|
45
|
+
// this is a workaround to keep styles from <EuiText> in the admonition
|
|
46
|
+
const nestedParagraphStyleReset = css`
|
|
47
|
+
p.euiText {
|
|
48
|
+
font-size: inherit;
|
|
49
|
+
line-height: inherit;
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
const Callout = ({ title, type, children }: Props) => {
|
|
54
|
+
const variantProps = VARIANT_TO_PROPS_MAP[type as CalloutVariant];
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<EuiCallOut
|
|
58
|
+
title={title}
|
|
59
|
+
iconType="info"
|
|
60
|
+
color="primary"
|
|
61
|
+
{...variantProps}
|
|
62
|
+
css={css`
|
|
63
|
+
margin-block: var(--eui-theme-content-vertical-spacing);
|
|
64
|
+
${nestedParagraphStyleReset}
|
|
65
|
+
`}
|
|
66
|
+
>
|
|
67
|
+
{children}
|
|
68
|
+
</EuiCallOut>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const admonitionTypes: typeof AdmonitionTypes = {
|
|
73
|
+
note: Callout,
|
|
74
|
+
tip: Callout,
|
|
75
|
+
info: Callout,
|
|
76
|
+
accessibility: Callout,
|
|
77
|
+
warning: Callout,
|
|
78
|
+
danger: Callout,
|
|
79
|
+
secondary: Callout,
|
|
80
|
+
important: Callout,
|
|
81
|
+
success: Callout,
|
|
82
|
+
caution: Callout,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default admonitionTypes;
|
|
@@ -0,0 +1,57 @@
|
|
|
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 React, { isValidElement, type ReactNode, JSX } from 'react';
|
|
10
|
+
import { css } from '@emotion/react';
|
|
11
|
+
import { EuiCodeBlock } from '@elastic/eui';
|
|
12
|
+
import type { Props } from '@theme/CodeBlock';
|
|
13
|
+
|
|
14
|
+
import { Demo } from '../../components/demo';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Best attempt to make the children a plain string so it is copyable. If there
|
|
18
|
+
* are react elements, we will not be able to copy the content, and it will
|
|
19
|
+
* return `children` as-is; otherwise, it concatenates the string children
|
|
20
|
+
* together.
|
|
21
|
+
*/
|
|
22
|
+
function maybeStringifyChildren(children: ReactNode): ReactNode {
|
|
23
|
+
if (React.Children.toArray(children).some((el) => isValidElement(el))) {
|
|
24
|
+
return children;
|
|
25
|
+
}
|
|
26
|
+
// The children is now guaranteed to be one/more plain strings
|
|
27
|
+
return Array.isArray(children) ? children.join('') : (children as string);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default function CodeBlock({
|
|
31
|
+
children: rawChildren,
|
|
32
|
+
metastring,
|
|
33
|
+
className,
|
|
34
|
+
...props
|
|
35
|
+
}: Props): JSX.Element {
|
|
36
|
+
const children = maybeStringifyChildren(rawChildren);
|
|
37
|
+
const language = className?.replace('language-', '') || undefined;
|
|
38
|
+
|
|
39
|
+
if (metastring?.startsWith('interactive')) {
|
|
40
|
+
return <Demo {...props}>{children}</Demo>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<EuiCodeBlock
|
|
45
|
+
{...props}
|
|
46
|
+
fontSize="m"
|
|
47
|
+
overflowHeight={450}
|
|
48
|
+
language={language}
|
|
49
|
+
isCopyable
|
|
50
|
+
css={css`
|
|
51
|
+
word-break: break-word;
|
|
52
|
+
`}
|
|
53
|
+
>
|
|
54
|
+
{children}
|
|
55
|
+
</EuiCodeBlock>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
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 React, { useCallback, useContext, useEffect, JSX } from 'react';
|
|
10
|
+
import type ColorModeToggleType from '@theme-init/ColorModeToggle';
|
|
11
|
+
import type { Props } from '@theme-original/ColorModeToggle';
|
|
12
|
+
import type { WrapperProps } from '@docusaurus/types';
|
|
13
|
+
import { EuiThemeColorMode } from '@elastic/eui';
|
|
14
|
+
import { translate } from '@docusaurus/Translate';
|
|
15
|
+
|
|
16
|
+
import { NavbarItem } from '../../components/navbar_item';
|
|
17
|
+
import { AppThemeContext } from '../../components/theme_context';
|
|
18
|
+
|
|
19
|
+
type WrappedProps = WrapperProps<typeof ColorModeToggleType>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Additional wrapper to connect Docusaurus color mode with EUI theme
|
|
23
|
+
*/
|
|
24
|
+
function ColorModeToggle({
|
|
25
|
+
value,
|
|
26
|
+
onChange,
|
|
27
|
+
...rest
|
|
28
|
+
}: WrappedProps): JSX.Element {
|
|
29
|
+
const { colorMode, changeColorMode } = useContext(AppThemeContext);
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
changeColorMode(value);
|
|
33
|
+
}, [value, colorMode, changeColorMode]);
|
|
34
|
+
|
|
35
|
+
const handleOnChange = (colorMode: EuiThemeColorMode) => {
|
|
36
|
+
changeColorMode(colorMode);
|
|
37
|
+
onChange?.(colorMode);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<OriginalColorModeToggle
|
|
42
|
+
value={colorMode}
|
|
43
|
+
onChange={handleOnChange}
|
|
44
|
+
{...rest}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function OriginalColorModeToggle({
|
|
50
|
+
className,
|
|
51
|
+
value,
|
|
52
|
+
onChange,
|
|
53
|
+
}: Props): JSX.Element {
|
|
54
|
+
const isDarkMode = value === 'dark';
|
|
55
|
+
|
|
56
|
+
const title = translate(
|
|
57
|
+
{
|
|
58
|
+
message: 'Switch between dark and light mode (currently {mode})',
|
|
59
|
+
id: 'theme.colorToggle.ariaLabel',
|
|
60
|
+
description: 'The ARIA label for the navbar color mode toggle',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
mode:
|
|
64
|
+
value === 'dark'
|
|
65
|
+
? translate({
|
|
66
|
+
message: 'dark mode',
|
|
67
|
+
id: 'theme.colorToggle.ariaLabel.mode.dark',
|
|
68
|
+
description: 'The name for the dark color mode',
|
|
69
|
+
})
|
|
70
|
+
: translate({
|
|
71
|
+
message: 'light mode',
|
|
72
|
+
id: 'theme.colorToggle.ariaLabel.mode.light',
|
|
73
|
+
description: 'The name for the light color mode',
|
|
74
|
+
}),
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const handleOnChange = useCallback(() => {
|
|
79
|
+
onChange(value === 'dark' ? 'light' : 'dark');
|
|
80
|
+
}, [value, onChange]);
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<NavbarItem
|
|
84
|
+
className={className}
|
|
85
|
+
title={title}
|
|
86
|
+
icon={isDarkMode ? 'sun' : 'moon'}
|
|
87
|
+
isMenuItem={false}
|
|
88
|
+
onClick={handleOnChange}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export default React.memo(ColorModeToggle);
|
|
@@ -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 { ComponentType } from 'react';
|
|
10
|
+
|
|
11
|
+
import { DemoSourceMeta } from '../../components/demo/demo';
|
|
12
|
+
|
|
13
|
+
export type ActionComponentProps = {
|
|
14
|
+
activeSource: DemoSourceMeta | null;
|
|
15
|
+
sources: DemoSourceMeta[];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type ActionComponent = ComponentType<ActionComponentProps>;
|
|
19
|
+
|
|
20
|
+
export const extraActions: ActionComponent[] = [];
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
/**
|
|
10
|
+
* A custom client-side require() alternative to inform users it's not available
|
|
11
|
+
* in our demo environment
|
|
12
|
+
*/
|
|
13
|
+
const clientSideRequire = () => {
|
|
14
|
+
throw new Error('require() is not accessible in the interactive demo environment! All EUI and React exports are available in the global scope for you to use without the need to import them.');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const demoDefaultScope = {
|
|
18
|
+
require: clientSideRequire,
|
|
19
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
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 Link from '@docusaurus/Link';
|
|
11
|
+
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
12
|
+
import { translate } from '@docusaurus/Translate';
|
|
13
|
+
import { EuiIcon, useEuiMemoizedStyles } from '@elastic/eui';
|
|
14
|
+
|
|
15
|
+
import { getItemStyles } from '../item.styles';
|
|
16
|
+
|
|
17
|
+
export default function HomeBreadcrumbItem(): JSX.Element {
|
|
18
|
+
const homeHref = useBaseUrl('/');
|
|
19
|
+
|
|
20
|
+
const styles = useEuiMemoizedStyles(getItemStyles);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<li className="breadcrumbs__item" css={styles.item}>
|
|
24
|
+
<Link
|
|
25
|
+
aria-label={translate({
|
|
26
|
+
id: 'theme.docs.breadcrumbs.home',
|
|
27
|
+
message: 'Home page',
|
|
28
|
+
description: 'The ARIA label for the home page in the breadcrumbs',
|
|
29
|
+
})}
|
|
30
|
+
className="breadcrumbs__link"
|
|
31
|
+
href={homeHref}
|
|
32
|
+
>
|
|
33
|
+
EUI
|
|
34
|
+
</Link>
|
|
35
|
+
<EuiIcon type="arrowRight" size="s" css={styles.icon} />
|
|
36
|
+
</li>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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 { css } from '@emotion/react';
|
|
10
|
+
import { UseEuiTheme } from '@elastic/eui';
|
|
11
|
+
|
|
12
|
+
export const getItemStyles = ({ euiTheme }: UseEuiTheme) => ({
|
|
13
|
+
item: css`
|
|
14
|
+
--ifm-breadcrumb-item-background: transparent;
|
|
15
|
+
--ifm-breadcrumb-item-background-active: transparent;
|
|
16
|
+
|
|
17
|
+
// overwrite global styles
|
|
18
|
+
&.breadcrumbs__item:not(:last-child):after {
|
|
19
|
+
content: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.breadcrumbs__link {
|
|
23
|
+
padding: 0 ${euiTheme.size.m};
|
|
24
|
+
font-size: var(--eui-font-size-xs);
|
|
25
|
+
line-height: var(--eui-line-height-m);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
a.breadcrumbs__link {
|
|
29
|
+
color: ${euiTheme.colors.link};
|
|
30
|
+
font-weight: ${euiTheme.font.weight.bold};
|
|
31
|
+
text-decoration: underline;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&.breadcrumbs__item--active .breadcrumbs__link {
|
|
35
|
+
color: ${euiTheme.colors.text};
|
|
36
|
+
}
|
|
37
|
+
`,
|
|
38
|
+
icon: css`
|
|
39
|
+
block-size: ${euiTheme.size.s};
|
|
40
|
+
inline-size: ${euiTheme.size.s};
|
|
41
|
+
fill: ${euiTheme.colors.text};
|
|
42
|
+
`,
|
|
43
|
+
});
|