@elastic/eui-docusaurus-theme 2.3.0 → 2.5.0-snapshot.1783939453438
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/lib/.tsbuildinfo-client +1 -1
- package/lib/components/demo/actions_bar/actions_bar.d.ts +2 -1
- package/lib/components/demo/actions_bar/actions_bar.js +4 -2
- package/lib/components/demo/codesandbox/get_parameters.d.ts +4 -0
- package/lib/components/demo/codesandbox/get_parameters.js +17 -0
- package/lib/components/demo/codesandbox/open_action.js +32 -6
- package/lib/components/demo/demo.d.ts +2 -1
- package/lib/components/demo/demo.js +5 -3
- package/lib/components/demo/preview/preview.js +2 -2
- package/lib/components/navbar_item/index.d.ts +2 -1
- package/lib/components/navbar_item/index.js +57 -47
- package/lib/components/version_switcher/index.js +2 -2
- package/lib/theme/Admonition/Types.js +3 -3
- package/lib/theme/CodeBlock/index.js +11 -4
- package/lib/theme/Demo/actions.d.ts +1 -0
- package/lib/theme/DocBreadcrumbs/Items/Home/index.js +1 -1
- package/lib/theme/DocBreadcrumbs/index.js +1 -1
- package/lib/theme/DocCard/index.js +2 -2
- package/lib/theme/DocSidebarItem/Category/index.js +1 -1
- package/lib/theme/Heading/index.js +2 -2
- package/lib/theme/Navbar/Content/index.js +12 -10
- package/lib/theme/Navbar/MobileSidebar/index.js +25 -2
- package/lib/theme/Navbar/breakpoint.d.ts +7 -0
- package/lib/theme/Navbar/breakpoint.js +18 -0
- package/lib/theme/NavbarItem/NavbarNavLink.js +1 -1
- package/lib/theme/PaginatorNavLink/index.js +1 -1
- package/lib/theme/TOCCollapsible/CollapseButton/index.js +1 -1
- package/package.json +6 -5
- package/src/components/demo/actions_bar/actions_bar.tsx +11 -5
- package/src/components/demo/codesandbox/get_parameters.ts +19 -0
- package/src/components/demo/codesandbox/open_action.tsx +46 -8
- package/src/components/demo/demo.tsx +7 -1
- package/src/components/demo/preview/preview.tsx +9 -3
- package/src/components/navbar_item/index.tsx +84 -65
- package/src/components/version_switcher/index.tsx +5 -5
- package/src/theme/Admonition/Types.tsx +4 -5
- package/src/theme/CodeBlock/index.tsx +15 -5
- package/src/theme/Demo/actions.tsx +1 -0
- package/src/theme/DocBreadcrumbs/Items/Home/index.tsx +1 -1
- package/src/theme/DocBreadcrumbs/index.tsx +1 -1
- package/src/theme/DocCard/index.tsx +2 -2
- package/src/theme/DocSidebarItem/Category/index.tsx +1 -1
- package/src/theme/Heading/index.tsx +11 -9
- package/src/theme/Navbar/Content/index.tsx +13 -10
- package/src/theme/Navbar/MobileSidebar/index.tsx +26 -3
- package/src/theme/Navbar/breakpoint.ts +23 -0
- package/src/theme/NavbarItem/NavbarNavLink.tsx +1 -1
- package/src/theme/PaginatorNavLink/index.tsx +2 -2
- package/src/theme/TOCCollapsible/CollapseButton/index.tsx +1 -1
- package/src/theme/theme.d.ts +1 -0
|
@@ -3,9 +3,10 @@ export interface DemoActionsBarProps {
|
|
|
3
3
|
activeSource: DemoSourceMeta | null;
|
|
4
4
|
sources: DemoSourceMeta[];
|
|
5
5
|
extraFiles?: ExtraFiles;
|
|
6
|
+
previewWrapperSource?: string;
|
|
6
7
|
isSourceOpen: boolean;
|
|
7
8
|
setSourceOpen(isOpen: boolean): void;
|
|
8
9
|
onClickReloadExample(): void;
|
|
9
10
|
onClickCopyToClipboard(): void;
|
|
10
11
|
}
|
|
11
|
-
export declare const DemoActionsBar: ({ isSourceOpen, setSourceOpen, activeSource, sources, extraFiles, onClickReloadExample, onClickCopyToClipboard, }: DemoActionsBarProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const DemoActionsBar: ({ isSourceOpen, setSourceOpen, activeSource, sources, extraFiles, previewWrapperSource, onClickReloadExample, onClickCopyToClipboard, }: DemoActionsBarProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -28,7 +28,9 @@ const getDemoActionsBarStyles = (euiTheme) => {
|
|
|
28
28
|
`,
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
|
-
export const DemoActionsBar = ({ isSourceOpen, setSourceOpen, activeSource, sources, extraFiles, onClickReloadExample, onClickCopyToClipboard, }) => {
|
|
31
|
+
export const DemoActionsBar = ({ isSourceOpen, setSourceOpen, activeSource, sources, extraFiles, previewWrapperSource, onClickReloadExample, onClickCopyToClipboard, }) => {
|
|
32
32
|
const styles = useEuiMemoizedStyles(getDemoActionsBarStyles);
|
|
33
|
-
|
|
33
|
+
const copyToClipboardLabel = 'Copy to clipboard';
|
|
34
|
+
const reloadExampleLabel = 'Reload example';
|
|
35
|
+
return (_jsxs(EuiFlexGroup, { alignItems: "center", css: styles.actionsBar, gutterSize: "s", children: [_jsx(EuiButton, { css: styles.button, onClick: () => setSourceOpen(!isSourceOpen), size: "s", color: "text", minWidth: false, children: isSourceOpen ? 'Hide source' : 'Show source' }), extraActions.map((ActionComponent) => (_jsx(ActionComponent, { sources: sources, extraFiles: extraFiles, previewWrapperSource: previewWrapperSource, activeSource: activeSource }, ActionComponent.displayName ?? ActionComponent.name))), _jsx(EuiToolTip, { content: copyToClipboardLabel, disableScreenReaderOutput: true, children: _jsx(EuiButtonIcon, { size: "s", iconType: "copy", color: "text", onClick: onClickCopyToClipboard, "aria-label": copyToClipboardLabel }) }), _jsx(EuiToolTip, { content: reloadExampleLabel, disableScreenReaderOutput: true, children: _jsx(EuiButtonIcon, { size: "s", iconType: "refresh", color: "text", onClick: onClickReloadExample, "aria-label": reloadExampleLabel }) })] }));
|
|
34
36
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
import { compressToBase64 } from 'lz-string';
|
|
9
|
+
/**
|
|
10
|
+
* Encodes sandbox parameters for CodeSandbox's `define` API.
|
|
11
|
+
*/
|
|
12
|
+
export const getParameters = (parameters) => {
|
|
13
|
+
return compressToBase64(JSON.stringify(parameters))
|
|
14
|
+
.replace(/\+/g, '-')
|
|
15
|
+
.replace(/\//g, '_')
|
|
16
|
+
.replace(/=+$/, '');
|
|
17
|
+
};
|
|
@@ -7,7 +7,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
|
7
7
|
* Side Public License, v 1.
|
|
8
8
|
*/
|
|
9
9
|
import { useMemo } from 'react';
|
|
10
|
-
import { getParameters } from '
|
|
10
|
+
import { getParameters } from './get_parameters';
|
|
11
11
|
import dedent from 'dedent';
|
|
12
12
|
import { EuiButtonIcon, EuiToolTip } from '@elastic/eui';
|
|
13
13
|
import { CodeSandboxIcon } from '../../codesandbox_icon';
|
|
@@ -32,7 +32,8 @@ const indexTsxSource = dedent `
|
|
|
32
32
|
<EuiProvider cache={cache}>
|
|
33
33
|
<Demo />
|
|
34
34
|
</EuiProvider>
|
|
35
|
-
)
|
|
35
|
+
);
|
|
36
|
+
`;
|
|
36
37
|
const publicIndexHtmlSource = dedent `
|
|
37
38
|
<head>
|
|
38
39
|
<title>@elastic/eui component demo</title>
|
|
@@ -59,9 +60,21 @@ export const defaultCodeSandboxParameters = {
|
|
|
59
60
|
const processTsxSource = (source) => {
|
|
60
61
|
// jsxImportSource pragma is needed in CodeSandbox as it doesn't seem
|
|
61
62
|
// to support that setting via tsconfig.json
|
|
62
|
-
|
|
63
|
+
let processed = `/** @jsxImportSource @emotion/react */\n${source}`;
|
|
64
|
+
// Inject `@elastic/charts` CSS for demos that use the charts library,
|
|
65
|
+
// since CodeSandbox doesn't load it globally unlike the docs site
|
|
66
|
+
if (source.includes('@elastic/charts')) {
|
|
67
|
+
// Match the closing line of the @elastic/charts import (handles both
|
|
68
|
+
// single-line and multi-line imports, and both quote styles)
|
|
69
|
+
processed = processed.replace(/^(.*from ['"]@elastic\/charts['"];)$/m, [
|
|
70
|
+
'$1',
|
|
71
|
+
"import '@elastic/charts/dist/theme_only_light.css';",
|
|
72
|
+
"import '@elastic/charts/dist/theme_only_dark.css';",
|
|
73
|
+
].join('\n'));
|
|
74
|
+
}
|
|
75
|
+
return processed;
|
|
63
76
|
};
|
|
64
|
-
export const createOpenInCodeSandboxAction = ({ files = {}, dependencies }) => ({ extraFiles, activeSource }) => {
|
|
77
|
+
export const createOpenInCodeSandboxAction = ({ files = {}, dependencies }) => ({ extraFiles, activeSource, previewWrapperSource }) => {
|
|
65
78
|
const parameters = useMemo(() => {
|
|
66
79
|
const source = activeSource?.code || '';
|
|
67
80
|
// Compute list of extra files that may be passed
|
|
@@ -75,6 +88,18 @@ export const createOpenInCodeSandboxAction = ({ files = {}, dependencies }) => (
|
|
|
75
88
|
return getParameters({
|
|
76
89
|
files: {
|
|
77
90
|
...defaultCodeSandboxParameters.files,
|
|
91
|
+
...(previewWrapperSource
|
|
92
|
+
? {
|
|
93
|
+
'index.tsx': {
|
|
94
|
+
content: indexTsxSource
|
|
95
|
+
.replace("import Demo from './demo';", "import Demo from './demo';\nimport PreviewWrapper from './preview_wrapper';")
|
|
96
|
+
.replace('<Demo />', '<PreviewWrapper>\n <Demo />\n </PreviewWrapper>'),
|
|
97
|
+
},
|
|
98
|
+
'preview_wrapper.tsx': {
|
|
99
|
+
content: processTsxSource(previewWrapperSource),
|
|
100
|
+
},
|
|
101
|
+
}
|
|
102
|
+
: {}),
|
|
78
103
|
'demo.tsx': {
|
|
79
104
|
content: processTsxSource(source),
|
|
80
105
|
},
|
|
@@ -89,6 +114,7 @@ export const createOpenInCodeSandboxAction = ({ files = {}, dependencies }) => (
|
|
|
89
114
|
...codeSandboxFiles,
|
|
90
115
|
},
|
|
91
116
|
});
|
|
92
|
-
}, [activeSource, extraFiles]);
|
|
93
|
-
|
|
117
|
+
}, [activeSource, extraFiles, previewWrapperSource]);
|
|
118
|
+
const openInCodeSandboxLabel = 'Open in CodeSandbox';
|
|
119
|
+
return (_jsxs("form", { action: "https://codesandbox.io/api/v1/sandboxes/define", method: "POST", target: "_blank", children: [_jsx("input", { type: "hidden", name: "parameters", value: parameters }), _jsx("input", { type: "hidden", name: "query", value: `module=/demo.tsx&view=split` }), _jsx(EuiToolTip, { content: openInCodeSandboxLabel, disableScreenReaderOutput: true, children: _jsx(EuiButtonIcon, { type: "submit", size: "s", iconType: CodeSandboxIcon, color: "text", "aria-label": openInCodeSandboxLabel }) })] }));
|
|
94
120
|
};
|
|
@@ -45,5 +45,6 @@ export interface DemoProps extends PropsWithChildren {
|
|
|
45
45
|
extraFiles?: ExtraFiles;
|
|
46
46
|
previewPadding?: DemoPreviewProps['padding'];
|
|
47
47
|
previewWrapper?: DemoPreviewProps['wrapperComponent'];
|
|
48
|
+
previewWrapperSource?: string;
|
|
48
49
|
}
|
|
49
|
-
export declare const Demo: ({ children, scope, extraFiles, isSourceOpen: _isSourceOpen, previewPadding, previewWrapper, }: DemoProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
50
|
+
export declare const Demo: ({ children, scope, extraFiles, isSourceOpen: _isSourceOpen, previewPadding, previewWrapper, previewWrapperSource, }: DemoProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -10,7 +10,7 @@ import { Children, useCallback, useMemo, useState, } from 'react';
|
|
|
10
10
|
import { isElement } from 'react-is';
|
|
11
11
|
import { LiveProvider } from 'react-live';
|
|
12
12
|
import { themes as prismThemes } from 'prism-react-renderer';
|
|
13
|
-
import { useEuiMemoizedStyles, copyToClipboard, } from '@elastic/eui';
|
|
13
|
+
import { useEuiMemoizedStyles, copyToClipboard, useIsDarkMode, } from '@elastic/eui';
|
|
14
14
|
import { css } from '@emotion/react';
|
|
15
15
|
import { demoDefaultScope } from '@theme/Demo/default_scope';
|
|
16
16
|
import { DemoContext } from './context';
|
|
@@ -31,11 +31,13 @@ const getDemoStyles = (euiTheme) => ({
|
|
|
31
31
|
word-break: break-word;
|
|
32
32
|
`,
|
|
33
33
|
});
|
|
34
|
-
export const Demo = ({ children, scope, extraFiles, isSourceOpen: _isSourceOpen = false, previewPadding, previewWrapper, }) => {
|
|
34
|
+
export const Demo = ({ children, scope, extraFiles, isSourceOpen: _isSourceOpen = false, previewPadding, previewWrapper, previewWrapperSource, }) => {
|
|
35
35
|
const styles = useEuiMemoizedStyles(getDemoStyles);
|
|
36
|
+
const isDarkMode = useIsDarkMode();
|
|
36
37
|
const [sources, setSources] = useState([]);
|
|
37
38
|
const [isSourceOpen, setIsSourceOpen] = useState(_isSourceOpen);
|
|
38
39
|
const activeSource = sources[0] || null;
|
|
40
|
+
const prismTheme = isDarkMode ? prismThemes.dracula : prismThemes.github;
|
|
39
41
|
// liveProviderKey restarts the demo to its initial state
|
|
40
42
|
const [liveProviderKey, setLiveProviderKey] = useState(0);
|
|
41
43
|
const finalScope = useMemo(() => ({
|
|
@@ -52,7 +54,7 @@ export const Demo = ({ children, scope, extraFiles, isSourceOpen: _isSourceOpen
|
|
|
52
54
|
const onClickReloadExample = useCallback(() => {
|
|
53
55
|
setLiveProviderKey((liveProviderKey) => liveProviderKey + 1);
|
|
54
56
|
}, []);
|
|
55
|
-
return (_jsx("div", { css: styles.demo, children: _jsxs(DemoContext.Provider, { value: { sources, addSource }, children: [_jsxs(LiveProvider, { code: activeSource?.code || '', transformCode: demoCodeTransformer, theme:
|
|
57
|
+
return (_jsx("div", { css: styles.demo, children: _jsxs(DemoContext.Provider, { value: { sources, addSource }, children: [_jsxs(LiveProvider, { code: activeSource?.code || '', transformCode: demoCodeTransformer, theme: prismTheme, scope: finalScope, children: [_jsx(DemoPreview, { padding: previewPadding, wrapperComponent: previewWrapper }), _jsx(DemoActionsBar, { isSourceOpen: isSourceOpen, setSourceOpen: setIsSourceOpen, activeSource: activeSource, extraFiles: extraFiles, sources: sources, previewWrapperSource: previewWrapperSource, onClickCopyToClipboard: onClickCopyToClipboard, onClickReloadExample: onClickReloadExample }), isSourceOpen && _jsx(DemoEditor, {})] }, liveProviderKey), Children.map(children, (child, index) => {
|
|
56
58
|
if (isElement(child) && child.type === DemoSource) {
|
|
57
59
|
return child;
|
|
58
60
|
}
|
|
@@ -12,7 +12,7 @@ import { Fragment, } from 'react';
|
|
|
12
12
|
import BrowserOnly from '@docusaurus/BrowserOnly';
|
|
13
13
|
import ErrorBoundary from '@docusaurus/ErrorBoundary';
|
|
14
14
|
import { ErrorBoundaryErrorMessageFallback } from '@docusaurus/theme-common';
|
|
15
|
-
import { useEuiTheme, euiPaddingSize, } from '@elastic/eui';
|
|
15
|
+
import { useEuiTheme, EuiThemeProvider, euiPaddingSize, } from '@elastic/eui';
|
|
16
16
|
const getPreviewStyles = (euiTheme) => ({
|
|
17
17
|
previewWrapper: css `
|
|
18
18
|
padding: var(--docs-demo-preview-padding);
|
|
@@ -32,5 +32,5 @@ export const DemoPreview = ({ padding = 'l', wrapperComponent: WrapperComponent
|
|
|
32
32
|
const style = {
|
|
33
33
|
'--docs-demo-preview-padding': paddingSize,
|
|
34
34
|
};
|
|
35
|
-
return (_jsx(BrowserOnly, { fallback: _jsx(PreviewLoader, {}), children: () => (_jsx(_Fragment, { children: _jsx(ErrorBoundary, { fallback: (params) => (_jsx(ErrorBoundaryErrorMessageFallback, { ...params })), children: _jsx("div", { css: styles.previewWrapper, style: style, children: _jsx(WrapperComponent, { children: _jsx(LivePreview, {}) }) }) }) })) }));
|
|
35
|
+
return (_jsx(BrowserOnly, { fallback: _jsx(PreviewLoader, {}), children: () => (_jsx(_Fragment, { children: _jsx(ErrorBoundary, { fallback: (params) => (_jsx(ErrorBoundaryErrorMessageFallback, { ...params })), children: _jsx("div", { css: styles.previewWrapper, style: style, children: _jsx(EuiThemeProvider, { modify: { font: { lineHeightMultiplier: 1.5 } }, children: _jsx(WrapperComponent, { children: _jsx(LivePreview, {}) }) }) }) }) })) }));
|
|
36
36
|
};
|
|
@@ -6,7 +6,7 @@ type SharedProps = {
|
|
|
6
6
|
isSelected?: boolean;
|
|
7
7
|
} & CommonProps;
|
|
8
8
|
type Props = ExclusiveUnion<PropsForAnchor<SharedProps>, PropsForButton<SharedProps>>;
|
|
9
|
-
export declare const getStyles: (
|
|
9
|
+
export declare const getStyles: (euiThemeContext: UseEuiTheme) => {
|
|
10
10
|
item: import("@emotion/react").SerializedStyles;
|
|
11
11
|
navItem: import("@emotion/react").SerializedStyles;
|
|
12
12
|
menuItem: import("@emotion/react").SerializedStyles;
|
|
@@ -14,6 +14,7 @@ export declare const getStyles: ({ euiTheme }: UseEuiTheme) => {
|
|
|
14
14
|
disabled: import("@emotion/react").SerializedStyles;
|
|
15
15
|
selected: import("@emotion/react").SerializedStyles;
|
|
16
16
|
title: import("@emotion/react").SerializedStyles;
|
|
17
|
+
tooltipAnchor: import("@emotion/react").SerializedStyles;
|
|
17
18
|
};
|
|
18
19
|
export declare const NavbarItem: (props: Props) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
19
20
|
export {};
|
|
@@ -9,58 +9,66 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/reac
|
|
|
9
9
|
import { useContext } from 'react';
|
|
10
10
|
import { css } from '@emotion/react';
|
|
11
11
|
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
12
|
-
import { EuiIcon, useEuiMemoizedStyles, } from '@elastic/eui';
|
|
12
|
+
import { EuiIcon, EuiToolTip, useEuiMemoizedStyles, } from '@elastic/eui';
|
|
13
13
|
import { AppThemeContext } from '../theme_context';
|
|
14
|
+
import { getNavbarBreakpoint } from '../../theme/Navbar/breakpoint';
|
|
14
15
|
// converted from css modules to Emotion
|
|
15
|
-
export const getStyles = (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
export const getStyles = (euiThemeContext) => {
|
|
17
|
+
const { euiTheme } = euiThemeContext;
|
|
18
|
+
const { desktopMediaQuery } = getNavbarBreakpoint(euiThemeContext);
|
|
19
|
+
return {
|
|
20
|
+
item: css `
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
flex-shrink: 0;
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
-webkit-tap-highlight-color: transparent;
|
|
26
|
+
transition: background var(--ifm-transition-fast);
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
justify-content: center;
|
|
31
|
-
width: ${euiTheme.size.xl};
|
|
32
|
-
height: ${euiTheme.size.xl};
|
|
33
|
-
border-radius: 50%;
|
|
34
|
-
`,
|
|
35
|
-
menuItem: css `
|
|
36
|
-
justify-content: flex-start;
|
|
37
|
-
gap: ${euiTheme.size.s};
|
|
38
|
-
|
|
39
|
-
@media (min-width: 997px) {
|
|
28
|
+
&:hover {
|
|
29
|
+
background-color: ${euiTheme.components.buttons.backgroundTextHover};
|
|
30
|
+
color: currentColor;
|
|
31
|
+
}
|
|
32
|
+
`,
|
|
33
|
+
navItem: css `
|
|
40
34
|
justify-content: center;
|
|
41
35
|
width: ${euiTheme.size.xl};
|
|
42
36
|
height: ${euiTheme.size.xl};
|
|
43
37
|
border-radius: 50%;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
38
|
+
`,
|
|
39
|
+
menuItem: css `
|
|
40
|
+
justify-content: flex-start;
|
|
41
|
+
gap: ${euiTheme.size.s};
|
|
42
|
+
|
|
43
|
+
${desktopMediaQuery} {
|
|
44
|
+
justify-content: center;
|
|
45
|
+
width: ${euiTheme.size.xl};
|
|
46
|
+
height: ${euiTheme.size.xl};
|
|
47
|
+
border-radius: 50%;
|
|
48
|
+
}
|
|
49
|
+
`,
|
|
50
|
+
darkMode: css `
|
|
51
|
+
&:hover {
|
|
52
|
+
color: currentColor;
|
|
53
|
+
}
|
|
54
|
+
`,
|
|
55
|
+
disabled: css `
|
|
56
|
+
cursor: not-allowed;
|
|
57
|
+
`,
|
|
58
|
+
selected: css `
|
|
59
|
+
background-color: ${euiTheme.colors.backgroundFilledText};
|
|
60
|
+
color: ${euiTheme.colors.textInverse};
|
|
61
|
+
`,
|
|
62
|
+
title: css `
|
|
63
|
+
${desktopMediaQuery} {
|
|
64
|
+
display: none;
|
|
65
|
+
}
|
|
66
|
+
`,
|
|
67
|
+
tooltipAnchor: css `
|
|
68
|
+
display: inline-flex;
|
|
69
|
+
`,
|
|
70
|
+
};
|
|
71
|
+
};
|
|
64
72
|
// using a type guard to ensure proper typing from ExclusiveUnion
|
|
65
73
|
const isAnchorClick = (onClick, href) => href != null;
|
|
66
74
|
export const NavbarItem = (props) => {
|
|
@@ -75,10 +83,12 @@ export const NavbarItem = (props) => {
|
|
|
75
83
|
!isBrowser && styles.disabled,
|
|
76
84
|
isSelected && styles.selected,
|
|
77
85
|
isDarkMode && styles.darkMode,
|
|
86
|
+
css,
|
|
78
87
|
];
|
|
79
88
|
const content = showLabel ? (_jsxs(_Fragment, { children: [_jsx(EuiIcon, { type: icon }), _jsx("span", { css: styles.title, children: title })] })) : (_jsx(EuiIcon, { type: icon }));
|
|
80
|
-
|
|
81
|
-
|
|
89
|
+
const control = isAnchorClick(onClick, href) ? (_jsx("a", { href: href, target: target ?? '_blank', className: className, css: cssStyles, onClick: onClick, "aria-label": title, "aria-live": "polite", children: content })) : (_jsx("button", { type: "button", disabled: !isBrowser, className: className, css: cssStyles, onClick: onClick, "aria-label": title, "aria-live": "polite", "aria-pressed": isSelected != null ? isSelected : undefined, children: content }));
|
|
90
|
+
if (!title) {
|
|
91
|
+
return control;
|
|
82
92
|
}
|
|
83
|
-
return (_jsx(
|
|
93
|
+
return (_jsx(EuiToolTip, { content: title, disableScreenReaderOutput: true, repositionOnScroll: true, anchorProps: { css: styles.tooltipAnchor }, children: control }));
|
|
84
94
|
};
|
|
@@ -66,7 +66,7 @@ export const VersionSwitcher = ({ ariaLabel, currentVersion, extraAction, previo
|
|
|
66
66
|
if (!allVersions?.length)
|
|
67
67
|
return null;
|
|
68
68
|
const latestVersion = allVersions[0];
|
|
69
|
-
const button = (_jsxs(EuiButtonEmpty, { size: "s", color: "text", iconType: "
|
|
69
|
+
const button = (_jsxs(EuiButtonEmpty, { size: "s", color: "text", iconType: "chevronSingleDown", iconSide: "right", css: styles.button, onClick: () => setPopoverOpen((isOpen) => !isOpen), "aria-label": `${pronounceVersion(currentVersion)}. Click to switch versions`, children: ["v", currentVersion] }));
|
|
70
70
|
return (_jsx(EuiPopover, { isOpen: isPopoverOpen, closePopover: () => setPopoverOpen(false), button: button, repositionOnScroll: true, panelPaddingSize: "xs", "aria-label": ariaLabel, children: _jsx(FixedSizeList, { className: "eui-yScroll", itemCount: allVersions.length, itemSize: 24, height: 200, width: 120, innerElementType: "ul", children: ({ index, style }) => {
|
|
71
71
|
const version = allVersions[index];
|
|
72
72
|
const isCurrentVersion = version === currentVersion;
|
|
@@ -74,6 +74,6 @@ export const VersionSwitcher = ({ ariaLabel, currentVersion, extraAction, previo
|
|
|
74
74
|
const url = version === latestVersion
|
|
75
75
|
? `${previousVersionUrl}/`
|
|
76
76
|
: `${previousVersionUrl}/v${version}/`;
|
|
77
|
-
return (_jsx(EuiListGroupItem, { css: styles.listItem, style: style,
|
|
77
|
+
return (_jsx(EuiListGroupItem, { css: styles.listItem, style: style, label: `v${version}`, "aria-label": screenReaderVersion, href: url, isActive: isCurrentVersion, color: isCurrentVersion ? 'primary' : 'text', extraAction: extraAction?.(version) }));
|
|
78
78
|
} }) }));
|
|
79
79
|
};
|
|
@@ -9,11 +9,11 @@ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
|
9
9
|
import { css } from '@emotion/react';
|
|
10
10
|
import { EuiCallOut } from '@elastic/eui';
|
|
11
11
|
const VARIANT_TO_PROPS_MAP = {
|
|
12
|
-
note: { iconType: 'paperClip', color: '
|
|
12
|
+
note: { iconType: 'paperClip', color: 'primary' },
|
|
13
13
|
tip: { iconType: 'faceHappy', color: 'success' },
|
|
14
14
|
info: { iconType: 'info', color: 'primary' },
|
|
15
15
|
accessibility: { iconType: 'accessibility', color: 'primary' },
|
|
16
|
-
warning: { iconType: '
|
|
16
|
+
warning: { iconType: 'warning', color: 'warning' },
|
|
17
17
|
danger: { iconType: 'error', color: 'danger' },
|
|
18
18
|
// Undocumented legacy admonition type aliases
|
|
19
19
|
secondary: {},
|
|
@@ -31,7 +31,7 @@ const nestedParagraphStyleReset = css `
|
|
|
31
31
|
`;
|
|
32
32
|
const Callout = ({ title, type, children }) => {
|
|
33
33
|
const variantProps = VARIANT_TO_PROPS_MAP[type];
|
|
34
|
-
return (_jsx(EuiCallOut, { title: title,
|
|
34
|
+
return (_jsx(EuiCallOut, { title: title, color: "primary", ...variantProps, css: css `
|
|
35
35
|
margin-block: var(--eui-theme-content-vertical-spacing);
|
|
36
36
|
${nestedParagraphStyleReset}
|
|
37
37
|
`, children: children }));
|
|
@@ -8,8 +8,14 @@ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
|
8
8
|
*/
|
|
9
9
|
import React, { isValidElement } from 'react';
|
|
10
10
|
import { css } from '@emotion/react';
|
|
11
|
-
import { EuiCodeBlock } from '@elastic/eui';
|
|
11
|
+
import { EuiCodeBlock, useEuiMemoizedStyles } from '@elastic/eui';
|
|
12
12
|
import { Demo } from '../../components/demo';
|
|
13
|
+
const getStyles = ({ euiTheme }) => ({
|
|
14
|
+
codeBlock: css `
|
|
15
|
+
margin-block: ${euiTheme.size.base};
|
|
16
|
+
word-break: break-word;
|
|
17
|
+
`,
|
|
18
|
+
});
|
|
13
19
|
/**
|
|
14
20
|
* Best attempt to make the children a plain string so it is copyable. If there
|
|
15
21
|
* are react elements, we will not be able to copy the content, and it will
|
|
@@ -26,10 +32,11 @@ function maybeStringifyChildren(children) {
|
|
|
26
32
|
export default function CodeBlock({ children: rawChildren, metastring, className, ...props }) {
|
|
27
33
|
const children = maybeStringifyChildren(rawChildren);
|
|
28
34
|
const language = className?.replace('language-', '') || undefined;
|
|
35
|
+
const styles = useEuiMemoizedStyles(getStyles);
|
|
29
36
|
if (metastring?.startsWith('interactive')) {
|
|
30
37
|
return _jsx(Demo, { ...props, children: children });
|
|
31
38
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
// Don't show the fullscreen button for one-liner snippets
|
|
40
|
+
const isOneLiner = typeof children === 'string' && !children.trim().includes('\n');
|
|
41
|
+
return (_jsx(EuiCodeBlock, { ...props, fontSize: "m", overflowHeight: isOneLiner ? undefined : 450, language: language, isCopyable: true, css: styles.codeBlock, children: children }));
|
|
35
42
|
}
|
|
@@ -4,6 +4,7 @@ export type ActionComponentProps = {
|
|
|
4
4
|
activeSource: DemoSourceMeta | null;
|
|
5
5
|
sources: DemoSourceMeta[];
|
|
6
6
|
extraFiles?: ExtraFiles;
|
|
7
|
+
previewWrapperSource?: string;
|
|
7
8
|
};
|
|
8
9
|
export type ActionComponent = ComponentType<ActionComponentProps>;
|
|
9
10
|
export declare const extraActions: ActionComponent[];
|
|
@@ -14,5 +14,5 @@ export default function HomeBreadcrumbItem() {
|
|
|
14
14
|
id: 'theme.docs.breadcrumbs.home',
|
|
15
15
|
message: 'Home page',
|
|
16
16
|
description: 'The ARIA label for the home page in the breadcrumbs',
|
|
17
|
-
}), className: "breadcrumbs__link", href: homeHref, children: title }), _jsx(EuiIcon, { type: "
|
|
17
|
+
}), className: "breadcrumbs__link", href: homeHref, children: title }), _jsx(EuiIcon, { type: "chevronSingleRight", size: "s", css: styles.icon })] }));
|
|
18
18
|
}
|
|
@@ -40,7 +40,7 @@ function BreadcrumbsItem({ children, active, index, addMicrodata, }) {
|
|
|
40
40
|
itemType: 'https://schema.org/ListItem',
|
|
41
41
|
}), className: clsx('breadcrumbs__item', {
|
|
42
42
|
'breadcrumbs__item--active': active,
|
|
43
|
-
}), css: styles.item, children: [children, _jsx("meta", { itemProp: "position", content: String(index + 1) }), !active && _jsx(EuiIcon, { type: "
|
|
43
|
+
}), css: styles.item, children: [children, _jsx("meta", { itemProp: "position", content: String(index + 1) }), !active && _jsx(EuiIcon, { type: "chevronSingleRight", css: styles.icon })] }));
|
|
44
44
|
}
|
|
45
45
|
export default function DocBreadcrumbs() {
|
|
46
46
|
const breadcrumbs = useSidebarBreadcrumbs();
|
|
@@ -27,8 +27,8 @@ function CardCategory({ item }) {
|
|
|
27
27
|
icon: "folderOpen", title: item.label, description: item.description ?? categoryItemsPlural(item.items.length) }));
|
|
28
28
|
}
|
|
29
29
|
function CardLink({ item }) {
|
|
30
|
-
// We update Docusaurus `link` icon to EUI `
|
|
31
|
-
const icon = isInternalUrl(item.href) ? 'document' : '
|
|
30
|
+
// We update Docusaurus `link` icon to EUI `external` icon
|
|
31
|
+
const icon = isInternalUrl(item.href) ? 'document' : 'external';
|
|
32
32
|
const doc = useDocById(item.docId ?? undefined);
|
|
33
33
|
return (_jsx(CardLayout, { href: item.href, icon: icon, title: item.label, description: item.description ?? doc?.description }));
|
|
34
34
|
}
|
|
@@ -85,7 +85,7 @@ function CollapseButton({ collapsed, categoryLabel, onClick, ...rest }) {
|
|
|
85
85
|
id: 'theme.DocSidebarItem.collapseCategoryAriaLabel',
|
|
86
86
|
message: "Collapse sidebar category '{label}'",
|
|
87
87
|
description: 'The ARIA label to collapse the sidebar category',
|
|
88
|
-
}, { label: categoryLabel }), "aria-expanded": !collapsed, type: "button", className: "clean-btn", onClick: onClick, ...rest, children: _jsx(EuiIcon, { size: "s", type: collapsed ? '
|
|
88
|
+
}, { label: categoryLabel }), "aria-expanded": !collapsed, type: "button", className: "clean-btn", onClick: onClick, ...rest, children: _jsx(EuiIcon, { size: "s", type: collapsed ? 'chevronSingleRight' : 'chevronSingleDown' }) }));
|
|
89
89
|
}
|
|
90
90
|
export default function DocSidebarItemCategory({ item, onItemClick, activePath, level, index, ...props }) {
|
|
91
91
|
const { items, label, collapsible, className, href } = item;
|
|
@@ -7,7 +7,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
|
7
7
|
* Side Public License, v 1.
|
|
8
8
|
*/
|
|
9
9
|
import useBrokenLinks from '@docusaurus/useBrokenLinks';
|
|
10
|
-
import { EuiTitle, EuiButtonIcon, useEuiMemoizedStyles, } from '@elastic/eui';
|
|
10
|
+
import { EuiTitle, EuiButtonIcon, EuiToolTip, useEuiMemoizedStyles, } from '@elastic/eui';
|
|
11
11
|
import { css } from '@emotion/react';
|
|
12
12
|
const TAG_TO_TITLE_SIZE_MAP = {
|
|
13
13
|
h6: 'xxxs',
|
|
@@ -44,6 +44,6 @@ const Heading = ({ as: Component, children, id, ...restProps }) => {
|
|
|
44
44
|
const anchorTitle = `Direct link to ${typeof children === 'string' ? children : id}`;
|
|
45
45
|
// We don't want to show section links on document title headings
|
|
46
46
|
const shouldShowSectionLink = Component !== 'h1';
|
|
47
|
-
return (_jsx(EuiTitle, { size: TAG_TO_TITLE_SIZE_MAP[Component], children: _jsxs(Component, { ...restProps, className: "heading anchor", css: styles.heading, id: id, children: [children, shouldShowSectionLink && (_jsx(EuiButtonIcon, { css: styles.anchor, href: `#${id}`, "aria-label": anchorTitle,
|
|
47
|
+
return (_jsx(EuiTitle, { size: TAG_TO_TITLE_SIZE_MAP[Component], children: _jsxs(Component, { ...restProps, className: "heading anchor", css: styles.heading, id: id, children: [children, shouldShowSectionLink && (_jsx(EuiToolTip, { content: anchorTitle, disableScreenReaderOutput: true, children: _jsx(EuiButtonIcon, { css: styles.anchor, href: `#${id}`, "aria-label": anchorTitle, iconType: "link", color: "text", size: "xs" }) }))] }) }));
|
|
48
48
|
};
|
|
49
49
|
export default Heading;
|
|
@@ -16,6 +16,7 @@ import { euiFormControlText, euiFormVariables,
|
|
|
16
16
|
} from '@elastic/eui/lib/components/form/form.styles';
|
|
17
17
|
import { VersionSwitcher, } from '../../../components/version_switcher';
|
|
18
18
|
import { HighContrastModeToggle } from '../../../components/high_contrast_mode_toggle';
|
|
19
|
+
import { getNavbarBreakpoint } from '../breakpoint';
|
|
19
20
|
const DOCS_PATH = '/docs';
|
|
20
21
|
const placeHolderStyles = (content) => `
|
|
21
22
|
&::-webkit-input-placeholder { ${content} }
|
|
@@ -27,6 +28,7 @@ const getStyles = (euiThemeContext) => {
|
|
|
27
28
|
const { euiTheme } = euiThemeContext;
|
|
28
29
|
const form = euiFormVariables(euiThemeContext);
|
|
29
30
|
const iconColor = encodeURIComponent(euiTheme.colors.text);
|
|
31
|
+
const { desktopMediaQuery, mobileMediaQuery } = getNavbarBreakpoint(euiThemeContext);
|
|
30
32
|
return {
|
|
31
33
|
navbarItems: css `
|
|
32
34
|
--ifm-navbar-item-padding-horizontal: 0;
|
|
@@ -34,7 +36,7 @@ const getStyles = (euiThemeContext) => {
|
|
|
34
36
|
|
|
35
37
|
.navbar__item,
|
|
36
38
|
[class*='colorModeToggle'] {
|
|
37
|
-
|
|
39
|
+
${mobileMediaQuery} {
|
|
38
40
|
display: none;
|
|
39
41
|
}
|
|
40
42
|
}
|
|
@@ -46,12 +48,16 @@ const getStyles = (euiThemeContext) => {
|
|
|
46
48
|
background-color: var(--ifm-color-emphasis-200);
|
|
47
49
|
color: currentColor;
|
|
48
50
|
}
|
|
51
|
+
|
|
52
|
+
${mobileMediaQuery} {
|
|
53
|
+
display: inherit;
|
|
54
|
+
}
|
|
49
55
|
}
|
|
50
56
|
`,
|
|
51
57
|
navbarItemsLeft: css `
|
|
52
58
|
gap: ${euiTheme.size.s};
|
|
53
59
|
|
|
54
|
-
|
|
60
|
+
${desktopMediaQuery} {
|
|
55
61
|
gap: ${euiTheme.size.l};
|
|
56
62
|
}
|
|
57
63
|
|
|
@@ -63,7 +69,7 @@ const getStyles = (euiThemeContext) => {
|
|
|
63
69
|
gap: ${euiTheme.size.s};
|
|
64
70
|
`,
|
|
65
71
|
actions: css `
|
|
66
|
-
|
|
72
|
+
${mobileMediaQuery} {
|
|
67
73
|
display: none;
|
|
68
74
|
}
|
|
69
75
|
`,
|
|
@@ -102,22 +108,18 @@ const getStyles = (euiThemeContext) => {
|
|
|
102
108
|
max-inline-size: 25rem;
|
|
103
109
|
}
|
|
104
110
|
|
|
105
|
-
|
|
111
|
+
${desktopMediaQuery} {
|
|
106
112
|
min-inline-size: 15rem;
|
|
107
113
|
}
|
|
108
|
-
|
|
109
|
-
@media (min-width: 1200px) {
|
|
110
|
-
min-inline-size: 25rem;
|
|
111
|
-
}
|
|
112
114
|
}
|
|
113
115
|
`,
|
|
114
116
|
versionSwitcher: css `
|
|
115
|
-
|
|
117
|
+
${mobileMediaQuery} {
|
|
116
118
|
display: none;
|
|
117
119
|
}
|
|
118
120
|
`,
|
|
119
121
|
themeSwitcher: css `
|
|
120
|
-
|
|
122
|
+
${mobileMediaQuery} {
|
|
121
123
|
display: none;
|
|
122
124
|
}
|
|
123
125
|
`,
|
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
4
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
5
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
6
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
7
|
+
* Side Public License, v 1.
|
|
8
|
+
*/
|
|
9
|
+
import { useEffect } from 'react';
|
|
10
|
+
import { useWindowSize } from '@docusaurus/theme-common';
|
|
2
11
|
import { useLockBodyScroll, useNavbarMobileSidebar, } from '@docusaurus/theme-common/internal';
|
|
3
12
|
import NavbarMobileSidebarLayout from '@theme-original/Navbar/MobileSidebar/Layout';
|
|
4
13
|
import NavbarMobileSidebarHeader from './Header';
|
|
5
14
|
import NavbarMobileSidebarPrimaryMenu from '@theme-original/Navbar/MobileSidebar/PrimaryMenu';
|
|
6
15
|
import NavbarMobileSidebarSecondaryMenu from '@theme-original/Navbar/MobileSidebar/SecondaryMenu';
|
|
16
|
+
import { useEuiTheme } from '@elastic/eui';
|
|
17
|
+
import { getNavbarBreakpoint } from '../breakpoint';
|
|
7
18
|
export default function NavbarMobileSidebar({ versionSwitcherOptions, }) {
|
|
8
19
|
const mobileSidebar = useNavbarMobileSidebar();
|
|
9
|
-
|
|
10
|
-
|
|
20
|
+
const { disabled, shouldRender: shouldRenderDefault, shown, toggle, } = mobileSidebar;
|
|
21
|
+
const euiThemeContext = useEuiTheme();
|
|
22
|
+
const { mobileBreakpoint } = getNavbarBreakpoint(euiThemeContext);
|
|
23
|
+
const windowSize = useWindowSize({
|
|
24
|
+
desktopBreakpoint: mobileBreakpoint,
|
|
25
|
+
});
|
|
26
|
+
const shouldRender = shouldRenderDefault || (!disabled && windowSize === 'mobile');
|
|
27
|
+
useLockBodyScroll(shouldRender && shown);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (windowSize === 'desktop' && shown) {
|
|
30
|
+
toggle();
|
|
31
|
+
}
|
|
32
|
+
}, [shown, toggle, windowSize]);
|
|
33
|
+
if (!shouldRender) {
|
|
11
34
|
return null;
|
|
12
35
|
}
|
|
13
36
|
return (_jsx(NavbarMobileSidebarLayout, { header: _jsx(NavbarMobileSidebarHeader, { versionSwitcherOptions: versionSwitcherOptions }), primaryMenu: _jsx(NavbarMobileSidebarPrimaryMenu, {}), secondaryMenu: _jsx(NavbarMobileSidebarSecondaryMenu, {}) }));
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
const NAVBAR_MOBILE_BREAKPOINT_KEY = 'xl';
|
|
9
|
+
export const getNavbarBreakpoint = ({ euiTheme }) => {
|
|
10
|
+
const mobileBreakpoint = euiTheme.breakpoint[NAVBAR_MOBILE_BREAKPOINT_KEY];
|
|
11
|
+
const desktopBreakpoint = mobileBreakpoint + 1;
|
|
12
|
+
return {
|
|
13
|
+
desktopBreakpoint,
|
|
14
|
+
desktopMediaQuery: `@media (min-width: ${desktopBreakpoint}px)`,
|
|
15
|
+
mobileBreakpoint,
|
|
16
|
+
mobileMediaQuery: `@media (max-width: ${mobileBreakpoint}px)`,
|
|
17
|
+
};
|
|
18
|
+
};
|