@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
|
@@ -39,5 +39,5 @@ export default function PaginatorNavLink(props) {
|
|
|
39
39
|
const { permalink, title, subLabel, isNext } = props;
|
|
40
40
|
const isPrev = !isNext;
|
|
41
41
|
const styles = useEuiMemoizedStyles(getStyles);
|
|
42
|
-
return (_jsxs(Link, { className: clsx('pagination-nav__link', isNext ? 'pagination-nav__link--next' : 'pagination-nav__link--prev'), css: styles.link, to: permalink, children: [subLabel && _jsx("div", { className: "pagination-nav__sublabel", children: subLabel }), _jsxs("div", { className: "pagination-nav__label", children: [isPrev && _jsx(EuiIcon, { type: "
|
|
42
|
+
return (_jsxs(Link, { className: clsx('pagination-nav__link', isNext ? 'pagination-nav__link--next' : 'pagination-nav__link--prev'), css: styles.link, to: permalink, children: [subLabel && _jsx("div", { className: "pagination-nav__sublabel", children: subLabel }), _jsxs("div", { className: "pagination-nav__label", children: [isPrev && _jsx(EuiIcon, { type: "chevronSingleLeft" }), title, isNext && _jsx(EuiIcon, { type: "chevronSingleRight" })] })] }));
|
|
43
43
|
}
|
|
@@ -19,5 +19,5 @@ const getStyles = ({ euiTheme }) => {
|
|
|
19
19
|
};
|
|
20
20
|
export default function TOCCollapsibleCollapseButton({ collapsed, ...props }) {
|
|
21
21
|
const styles = useEuiMemoizedStyles(getStyles);
|
|
22
|
-
return (_jsxs("button", { type: "button", ...props, className: clsx('clean-btn', props.className), css: styles.tocCollapsibleButton, children: [_jsx(Translate, { id: "theme.TOCCollapsible.toggleButtonLabel", description: "The label used by the button on the collapsible TOC component", children: "On this page" }), _jsx(EuiIcon, { type: collapsed ? '
|
|
22
|
+
return (_jsxs("button", { type: "button", ...props, className: clsx('clean-btn', props.className), css: styles.tocCollapsibleButton, children: [_jsx(Translate, { id: "theme.TOCCollapsible.toggleButtonLabel", description: "The label used by the button on the collapsible TOC component", children: "On this page" }), _jsx(EuiIcon, { type: collapsed ? 'chevronSingleDown' : 'chevronSingleUp' })] }));
|
|
23
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elastic/eui-docusaurus-theme",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0-snapshot.1783939453438",
|
|
4
4
|
"description": "EUI theme for Docusaurus",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"scripts": {
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"@docusaurus/theme-common": "^3.7.0",
|
|
41
41
|
"@docusaurus/utils-validation": "^3.7.0",
|
|
42
42
|
"@elastic/datemath": "^5.0.3",
|
|
43
|
-
"@elastic/eui": "^
|
|
44
|
-
"@elastic/eui-theme-borealis": "^
|
|
43
|
+
"@elastic/eui": "^117.0.0-snapshot.1783939453438",
|
|
44
|
+
"@elastic/eui-theme-borealis": "^8.0.0-snapshot.1783939453438",
|
|
45
45
|
"@emotion/css": "^11.11.2",
|
|
46
46
|
"@emotion/react": "^11.11.4",
|
|
47
47
|
"@types/react-window": "^1.8.8",
|
|
48
48
|
"clsx": "^2.1.1",
|
|
49
|
-
"codesandbox": "^2.2.3",
|
|
50
49
|
"dedent": "^1.5.3",
|
|
50
|
+
"lz-string": "^1.5.0",
|
|
51
51
|
"moment": "^2.30.1",
|
|
52
52
|
"prism-react-renderer": "^2.3.1",
|
|
53
53
|
"react-is": "^18.3.1",
|
|
@@ -57,5 +57,6 @@
|
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"react": "^18.0.0",
|
|
59
59
|
"react-dom": "^18.0.0"
|
|
60
|
-
}
|
|
60
|
+
},
|
|
61
|
+
"stableVersion": "2.5.0"
|
|
61
62
|
}
|
|
@@ -23,6 +23,7 @@ export interface DemoActionsBarProps {
|
|
|
23
23
|
activeSource: DemoSourceMeta | null;
|
|
24
24
|
sources: DemoSourceMeta[];
|
|
25
25
|
extraFiles?: ExtraFiles;
|
|
26
|
+
previewWrapperSource?: string;
|
|
26
27
|
isSourceOpen: boolean;
|
|
27
28
|
setSourceOpen(isOpen: boolean): void;
|
|
28
29
|
onClickReloadExample(): void;
|
|
@@ -55,10 +56,13 @@ export const DemoActionsBar = ({
|
|
|
55
56
|
activeSource,
|
|
56
57
|
sources,
|
|
57
58
|
extraFiles,
|
|
59
|
+
previewWrapperSource,
|
|
58
60
|
onClickReloadExample,
|
|
59
61
|
onClickCopyToClipboard,
|
|
60
62
|
}: DemoActionsBarProps) => {
|
|
61
63
|
const styles = useEuiMemoizedStyles(getDemoActionsBarStyles);
|
|
64
|
+
const copyToClipboardLabel = 'Copy to clipboard';
|
|
65
|
+
const reloadExampleLabel = 'Reload example';
|
|
62
66
|
|
|
63
67
|
return (
|
|
64
68
|
<EuiFlexGroup alignItems="center" css={styles.actionsBar} gutterSize="s">
|
|
@@ -73,27 +77,29 @@ export const DemoActionsBar = ({
|
|
|
73
77
|
</EuiButton>
|
|
74
78
|
{extraActions.map((ActionComponent) => (
|
|
75
79
|
<ActionComponent
|
|
80
|
+
key={ActionComponent.displayName ?? ActionComponent.name}
|
|
76
81
|
sources={sources}
|
|
77
82
|
extraFiles={extraFiles}
|
|
83
|
+
previewWrapperSource={previewWrapperSource}
|
|
78
84
|
activeSource={activeSource}
|
|
79
85
|
/>
|
|
80
86
|
))}
|
|
81
|
-
<EuiToolTip content=
|
|
87
|
+
<EuiToolTip content={copyToClipboardLabel} disableScreenReaderOutput>
|
|
82
88
|
<EuiButtonIcon
|
|
83
89
|
size="s"
|
|
84
|
-
iconType="
|
|
90
|
+
iconType="copy"
|
|
85
91
|
color="text"
|
|
86
92
|
onClick={onClickCopyToClipboard}
|
|
87
|
-
aria-label=
|
|
93
|
+
aria-label={copyToClipboardLabel}
|
|
88
94
|
/>
|
|
89
95
|
</EuiToolTip>
|
|
90
|
-
<EuiToolTip content=
|
|
96
|
+
<EuiToolTip content={reloadExampleLabel} disableScreenReaderOutput>
|
|
91
97
|
<EuiButtonIcon
|
|
92
98
|
size="s"
|
|
93
99
|
iconType="refresh"
|
|
94
100
|
color="text"
|
|
95
101
|
onClick={onClickReloadExample}
|
|
96
|
-
aria-label=
|
|
102
|
+
aria-label={reloadExampleLabel}
|
|
97
103
|
/>
|
|
98
104
|
</EuiToolTip>
|
|
99
105
|
</EuiFlexGroup>
|
|
@@ -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
|
+
import { compressToBase64 } from 'lz-string';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Encodes sandbox parameters for CodeSandbox's `define` API.
|
|
13
|
+
*/
|
|
14
|
+
export const getParameters = (parameters: unknown): string => {
|
|
15
|
+
return compressToBase64(JSON.stringify(parameters))
|
|
16
|
+
.replace(/\+/g, '-')
|
|
17
|
+
.replace(/\//g, '_')
|
|
18
|
+
.replace(/=+$/, '');
|
|
19
|
+
};
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
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 type { ActionComponent } from '../../../theme/Demo/actions';
|
|
@@ -34,7 +34,8 @@ const indexTsxSource = dedent`
|
|
|
34
34
|
<EuiProvider cache={cache}>
|
|
35
35
|
<Demo />
|
|
36
36
|
</EuiProvider>
|
|
37
|
-
)
|
|
37
|
+
);
|
|
38
|
+
`;
|
|
38
39
|
|
|
39
40
|
const publicIndexHtmlSource = dedent`
|
|
40
41
|
<head>
|
|
@@ -69,12 +70,29 @@ export type Options = {
|
|
|
69
70
|
const processTsxSource = (source: string) => {
|
|
70
71
|
// jsxImportSource pragma is needed in CodeSandbox as it doesn't seem
|
|
71
72
|
// to support that setting via tsconfig.json
|
|
72
|
-
|
|
73
|
+
let processed = `/** @jsxImportSource @emotion/react */\n${source}`;
|
|
74
|
+
|
|
75
|
+
// Inject `@elastic/charts` CSS for demos that use the charts library,
|
|
76
|
+
// since CodeSandbox doesn't load it globally unlike the docs site
|
|
77
|
+
if (source.includes('@elastic/charts')) {
|
|
78
|
+
// Match the closing line of the @elastic/charts import (handles both
|
|
79
|
+
// single-line and multi-line imports, and both quote styles)
|
|
80
|
+
processed = processed.replace(
|
|
81
|
+
/^(.*from ['"]@elastic\/charts['"];)$/m,
|
|
82
|
+
[
|
|
83
|
+
'$1',
|
|
84
|
+
"import '@elastic/charts/dist/theme_only_light.css';",
|
|
85
|
+
"import '@elastic/charts/dist/theme_only_dark.css';",
|
|
86
|
+
].join('\n')
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return processed;
|
|
73
91
|
};
|
|
74
92
|
|
|
75
93
|
export const createOpenInCodeSandboxAction =
|
|
76
94
|
({ files = {}, dependencies }: Options): ActionComponent =>
|
|
77
|
-
({ extraFiles, activeSource }) => {
|
|
95
|
+
({ extraFiles, activeSource, previewWrapperSource }) => {
|
|
78
96
|
const parameters: string = useMemo(() => {
|
|
79
97
|
const source = activeSource?.code || '';
|
|
80
98
|
|
|
@@ -93,6 +111,24 @@ export const createOpenInCodeSandboxAction =
|
|
|
93
111
|
return getParameters({
|
|
94
112
|
files: {
|
|
95
113
|
...defaultCodeSandboxParameters.files,
|
|
114
|
+
...(previewWrapperSource
|
|
115
|
+
? {
|
|
116
|
+
'index.tsx': {
|
|
117
|
+
content: indexTsxSource
|
|
118
|
+
.replace(
|
|
119
|
+
"import Demo from './demo';",
|
|
120
|
+
"import Demo from './demo';\nimport PreviewWrapper from './preview_wrapper';"
|
|
121
|
+
)
|
|
122
|
+
.replace(
|
|
123
|
+
'<Demo />',
|
|
124
|
+
'<PreviewWrapper>\n <Demo />\n </PreviewWrapper>'
|
|
125
|
+
),
|
|
126
|
+
},
|
|
127
|
+
'preview_wrapper.tsx': {
|
|
128
|
+
content: processTsxSource(previewWrapperSource),
|
|
129
|
+
},
|
|
130
|
+
}
|
|
131
|
+
: {}),
|
|
96
132
|
'demo.tsx': {
|
|
97
133
|
content: processTsxSource(source),
|
|
98
134
|
},
|
|
@@ -106,8 +142,10 @@ export const createOpenInCodeSandboxAction =
|
|
|
106
142
|
},
|
|
107
143
|
...codeSandboxFiles,
|
|
108
144
|
},
|
|
109
|
-
}
|
|
110
|
-
}, [activeSource, extraFiles]);
|
|
145
|
+
});
|
|
146
|
+
}, [activeSource, extraFiles, previewWrapperSource]);
|
|
147
|
+
|
|
148
|
+
const openInCodeSandboxLabel = 'Open in CodeSandbox';
|
|
111
149
|
|
|
112
150
|
return (
|
|
113
151
|
<form
|
|
@@ -121,13 +159,13 @@ export const createOpenInCodeSandboxAction =
|
|
|
121
159
|
name="query"
|
|
122
160
|
value={`module=/demo.tsx&view=split`}
|
|
123
161
|
/>
|
|
124
|
-
<EuiToolTip content=
|
|
162
|
+
<EuiToolTip content={openInCodeSandboxLabel} disableScreenReaderOutput>
|
|
125
163
|
<EuiButtonIcon
|
|
126
164
|
type="submit"
|
|
127
165
|
size="s"
|
|
128
166
|
iconType={CodeSandboxIcon}
|
|
129
167
|
color="text"
|
|
130
|
-
aria-label=
|
|
168
|
+
aria-label={openInCodeSandboxLabel}
|
|
131
169
|
/>
|
|
132
170
|
</EuiToolTip>
|
|
133
171
|
</form>
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
useEuiMemoizedStyles,
|
|
21
21
|
copyToClipboard,
|
|
22
22
|
UseEuiTheme,
|
|
23
|
+
useIsDarkMode,
|
|
23
24
|
} from '@elastic/eui';
|
|
24
25
|
import { css } from '@emotion/react';
|
|
25
26
|
import { demoDefaultScope } from '@theme/Demo/default_scope';
|
|
@@ -79,6 +80,7 @@ export interface DemoProps extends PropsWithChildren {
|
|
|
79
80
|
extraFiles?: ExtraFiles;
|
|
80
81
|
previewPadding?: DemoPreviewProps['padding'];
|
|
81
82
|
previewWrapper?: DemoPreviewProps['wrapperComponent'];
|
|
83
|
+
previewWrapperSource?: string;
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
const getDemoStyles = (euiTheme: UseEuiTheme) => ({
|
|
@@ -100,11 +102,14 @@ export const Demo = ({
|
|
|
100
102
|
isSourceOpen: _isSourceOpen = false,
|
|
101
103
|
previewPadding,
|
|
102
104
|
previewWrapper,
|
|
105
|
+
previewWrapperSource,
|
|
103
106
|
}: DemoProps) => {
|
|
104
107
|
const styles = useEuiMemoizedStyles(getDemoStyles);
|
|
108
|
+
const isDarkMode = useIsDarkMode();
|
|
105
109
|
const [sources, setSources] = useState<DemoSourceMeta[]>([]);
|
|
106
110
|
const [isSourceOpen, setIsSourceOpen] = useState<boolean>(_isSourceOpen);
|
|
107
111
|
const activeSource = sources[0] || null;
|
|
112
|
+
const prismTheme = isDarkMode ? prismThemes.dracula : prismThemes.github;
|
|
108
113
|
|
|
109
114
|
// liveProviderKey restarts the demo to its initial state
|
|
110
115
|
const [liveProviderKey, setLiveProviderKey] = useState<number>(0);
|
|
@@ -140,7 +145,7 @@ export const Demo = ({
|
|
|
140
145
|
key={liveProviderKey}
|
|
141
146
|
code={activeSource?.code || ''}
|
|
142
147
|
transformCode={demoCodeTransformer}
|
|
143
|
-
theme={
|
|
148
|
+
theme={prismTheme}
|
|
144
149
|
scope={finalScope}
|
|
145
150
|
>
|
|
146
151
|
<DemoPreview
|
|
@@ -153,6 +158,7 @@ export const Demo = ({
|
|
|
153
158
|
activeSource={activeSource}
|
|
154
159
|
extraFiles={extraFiles}
|
|
155
160
|
sources={sources}
|
|
161
|
+
previewWrapperSource={previewWrapperSource}
|
|
156
162
|
onClickCopyToClipboard={onClickCopyToClipboard}
|
|
157
163
|
onClickReloadExample={onClickReloadExample}
|
|
158
164
|
/>
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
UseEuiTheme,
|
|
22
22
|
useEuiTheme,
|
|
23
23
|
EuiPaddingSize,
|
|
24
|
+
EuiThemeProvider,
|
|
24
25
|
euiPaddingSize,
|
|
25
26
|
} from '@elastic/eui';
|
|
26
27
|
|
|
@@ -65,9 +66,14 @@ export const DemoPreview = ({
|
|
|
65
66
|
)}
|
|
66
67
|
>
|
|
67
68
|
<div css={styles.previewWrapper} style={style}>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
{/* Use the theme's actual default instead of docs global `lineHeightMultiplier` override */}
|
|
70
|
+
<EuiThemeProvider
|
|
71
|
+
modify={{ font: { lineHeightMultiplier: 1.5 } }}
|
|
72
|
+
>
|
|
73
|
+
<WrapperComponent>
|
|
74
|
+
<LivePreview />
|
|
75
|
+
</WrapperComponent>
|
|
76
|
+
</EuiThemeProvider>
|
|
71
77
|
</div>
|
|
72
78
|
</ErrorBoundary>
|
|
73
79
|
</>
|
|
@@ -12,9 +12,9 @@ import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
|
12
12
|
import {
|
|
13
13
|
CommonProps,
|
|
14
14
|
EuiIcon,
|
|
15
|
+
EuiToolTip,
|
|
15
16
|
ExclusiveUnion,
|
|
16
17
|
IconType,
|
|
17
|
-
mathWithUnits,
|
|
18
18
|
PropsForAnchor,
|
|
19
19
|
PropsForButton,
|
|
20
20
|
useEuiMemoizedStyles,
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
} from '@elastic/eui';
|
|
23
23
|
|
|
24
24
|
import { AppThemeContext } from '../theme_context';
|
|
25
|
+
import { getNavbarBreakpoint } from '../../theme/Navbar/breakpoint';
|
|
25
26
|
|
|
26
27
|
type SharedProps = {
|
|
27
28
|
icon: IconType;
|
|
@@ -36,55 +37,63 @@ type Props = ExclusiveUnion<
|
|
|
36
37
|
>;
|
|
37
38
|
|
|
38
39
|
// converted from css modules to Emotion
|
|
39
|
-
export const getStyles = (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
`,
|
|
59
|
-
menuItem: css`
|
|
60
|
-
justify-content: flex-start;
|
|
61
|
-
gap: ${euiTheme.size.s};
|
|
62
|
-
|
|
63
|
-
@media (min-width: 997px) {
|
|
40
|
+
export const getStyles = (euiThemeContext: UseEuiTheme) => {
|
|
41
|
+
const { euiTheme } = euiThemeContext;
|
|
42
|
+
const { desktopMediaQuery } = getNavbarBreakpoint(euiThemeContext);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
item: css`
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
flex-shrink: 0;
|
|
49
|
+
|
|
50
|
+
-webkit-tap-highlight-color: transparent;
|
|
51
|
+
transition: background var(--ifm-transition-fast);
|
|
52
|
+
|
|
53
|
+
&:hover {
|
|
54
|
+
background-color: ${euiTheme.components.buttons.backgroundTextHover};
|
|
55
|
+
color: currentColor;
|
|
56
|
+
}
|
|
57
|
+
`,
|
|
58
|
+
navItem: css`
|
|
64
59
|
justify-content: center;
|
|
65
60
|
width: ${euiTheme.size.xl};
|
|
66
61
|
height: ${euiTheme.size.xl};
|
|
67
62
|
border-radius: 50%;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
63
|
+
`,
|
|
64
|
+
menuItem: css`
|
|
65
|
+
justify-content: flex-start;
|
|
66
|
+
gap: ${euiTheme.size.s};
|
|
67
|
+
|
|
68
|
+
${desktopMediaQuery} {
|
|
69
|
+
justify-content: center;
|
|
70
|
+
width: ${euiTheme.size.xl};
|
|
71
|
+
height: ${euiTheme.size.xl};
|
|
72
|
+
border-radius: 50%;
|
|
73
|
+
}
|
|
74
|
+
`,
|
|
75
|
+
darkMode: css`
|
|
76
|
+
&:hover {
|
|
77
|
+
color: currentColor;
|
|
78
|
+
}
|
|
79
|
+
`,
|
|
80
|
+
disabled: css`
|
|
81
|
+
cursor: not-allowed;
|
|
82
|
+
`,
|
|
83
|
+
selected: css`
|
|
84
|
+
background-color: ${euiTheme.colors.backgroundFilledText};
|
|
85
|
+
color: ${euiTheme.colors.textInverse};
|
|
86
|
+
`,
|
|
87
|
+
title: css`
|
|
88
|
+
${desktopMediaQuery} {
|
|
89
|
+
display: none;
|
|
90
|
+
}
|
|
91
|
+
`,
|
|
92
|
+
tooltipAnchor: css`
|
|
93
|
+
display: inline-flex;
|
|
94
|
+
`,
|
|
95
|
+
};
|
|
96
|
+
};
|
|
88
97
|
|
|
89
98
|
// using a type guard to ensure proper typing from ExclusiveUnion
|
|
90
99
|
const isAnchorClick = (
|
|
@@ -118,6 +127,7 @@ export const NavbarItem = (props: Props) => {
|
|
|
118
127
|
!isBrowser && styles.disabled,
|
|
119
128
|
isSelected && styles.selected,
|
|
120
129
|
isDarkMode && styles.darkMode,
|
|
130
|
+
css,
|
|
121
131
|
];
|
|
122
132
|
|
|
123
133
|
const content = showLabel ? (
|
|
@@ -129,31 +139,25 @@ export const NavbarItem = (props: Props) => {
|
|
|
129
139
|
<EuiIcon type={icon} />
|
|
130
140
|
);
|
|
131
141
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
</a>
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return (
|
|
142
|
+
const control = isAnchorClick(onClick, href) ? (
|
|
143
|
+
<a
|
|
144
|
+
href={href}
|
|
145
|
+
target={target ?? '_blank'}
|
|
146
|
+
className={className}
|
|
147
|
+
css={cssStyles}
|
|
148
|
+
onClick={onClick}
|
|
149
|
+
aria-label={title}
|
|
150
|
+
aria-live="polite"
|
|
151
|
+
>
|
|
152
|
+
{content}
|
|
153
|
+
</a>
|
|
154
|
+
) : (
|
|
150
155
|
<button
|
|
151
156
|
type="button"
|
|
152
157
|
disabled={!isBrowser}
|
|
153
158
|
className={className}
|
|
154
159
|
css={cssStyles}
|
|
155
160
|
onClick={onClick}
|
|
156
|
-
title={title}
|
|
157
161
|
aria-label={title}
|
|
158
162
|
aria-live="polite"
|
|
159
163
|
aria-pressed={isSelected != null ? isSelected : undefined}
|
|
@@ -161,4 +165,19 @@ export const NavbarItem = (props: Props) => {
|
|
|
161
165
|
{content}
|
|
162
166
|
</button>
|
|
163
167
|
);
|
|
168
|
+
|
|
169
|
+
if (!title) {
|
|
170
|
+
return control;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
<EuiToolTip
|
|
175
|
+
content={title}
|
|
176
|
+
disableScreenReaderOutput
|
|
177
|
+
repositionOnScroll
|
|
178
|
+
anchorProps={{ css: styles.tooltipAnchor }}
|
|
179
|
+
>
|
|
180
|
+
{control}
|
|
181
|
+
</EuiToolTip>
|
|
182
|
+
);
|
|
164
183
|
};
|
|
@@ -123,7 +123,7 @@ export const VersionSwitcher = ({
|
|
|
123
123
|
<EuiButtonEmpty
|
|
124
124
|
size="s"
|
|
125
125
|
color="text"
|
|
126
|
-
iconType="
|
|
126
|
+
iconType="chevronSingleDown"
|
|
127
127
|
iconSide="right"
|
|
128
128
|
css={styles.button}
|
|
129
129
|
onClick={() => setPopoverOpen((isOpen) => !isOpen)}
|
|
@@ -157,15 +157,15 @@ export const VersionSwitcher = ({
|
|
|
157
157
|
const isCurrentVersion = version === currentVersion;
|
|
158
158
|
const screenReaderVersion = pronounceVersion(version!);
|
|
159
159
|
|
|
160
|
-
const url =
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
const url =
|
|
161
|
+
version === latestVersion
|
|
162
|
+
? `${previousVersionUrl}/`
|
|
163
|
+
: `${previousVersionUrl}/v${version}/`;
|
|
163
164
|
|
|
164
165
|
return (
|
|
165
166
|
<EuiListGroupItem
|
|
166
167
|
css={styles.listItem}
|
|
167
168
|
style={style}
|
|
168
|
-
size="xs"
|
|
169
169
|
label={`v${version}`}
|
|
170
170
|
aria-label={screenReaderVersion}
|
|
171
171
|
href={url}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { css } from '@emotion/react';
|
|
10
|
-
import { EuiCallOut
|
|
10
|
+
import { EuiCallOut } from '@elastic/eui';
|
|
11
11
|
import type { Props } from '@theme-original/Admonition';
|
|
12
12
|
import type AdmonitionTypes from '@theme-original/Admonition/Types';
|
|
13
13
|
|
|
@@ -22,17 +22,17 @@ type CalloutVariant =
|
|
|
22
22
|
| 'important'
|
|
23
23
|
| 'success'
|
|
24
24
|
| 'caution';
|
|
25
|
-
type VariantColor = '
|
|
25
|
+
type VariantColor = 'primary' | 'success' | 'warning' | 'danger';
|
|
26
26
|
|
|
27
27
|
const VARIANT_TO_PROPS_MAP: Record<
|
|
28
28
|
CalloutVariant,
|
|
29
29
|
{ iconType?: string; color?: VariantColor }
|
|
30
30
|
> = {
|
|
31
|
-
note: { iconType: 'paperClip', color: '
|
|
31
|
+
note: { iconType: 'paperClip', color: 'primary' },
|
|
32
32
|
tip: { iconType: 'faceHappy', color: 'success' },
|
|
33
33
|
info: { iconType: 'info', color: 'primary' },
|
|
34
34
|
accessibility: { iconType: 'accessibility', color: 'primary' },
|
|
35
|
-
warning: { iconType: '
|
|
35
|
+
warning: { iconType: 'warning', color: 'warning' },
|
|
36
36
|
danger: { iconType: 'error', color: 'danger' },
|
|
37
37
|
// Undocumented legacy admonition type aliases
|
|
38
38
|
secondary: {},
|
|
@@ -56,7 +56,6 @@ const Callout = ({ title, type, children }: Props) => {
|
|
|
56
56
|
return (
|
|
57
57
|
<EuiCallOut
|
|
58
58
|
title={title}
|
|
59
|
-
iconType="info"
|
|
60
59
|
color="primary"
|
|
61
60
|
{...variantProps}
|
|
62
61
|
css={css`
|
|
@@ -8,11 +8,18 @@
|
|
|
8
8
|
|
|
9
9
|
import React, { isValidElement, type ReactNode, JSX } from 'react';
|
|
10
10
|
import { css } from '@emotion/react';
|
|
11
|
-
import { EuiCodeBlock } from '@elastic/eui';
|
|
11
|
+
import { EuiCodeBlock, useEuiMemoizedStyles, UseEuiTheme } from '@elastic/eui';
|
|
12
12
|
import type { Props } from '@theme/CodeBlock';
|
|
13
13
|
|
|
14
14
|
import { Demo } from '../../components/demo';
|
|
15
15
|
|
|
16
|
+
const getStyles = ({ euiTheme }: UseEuiTheme) => ({
|
|
17
|
+
codeBlock: css`
|
|
18
|
+
margin-block: ${euiTheme.size.base};
|
|
19
|
+
word-break: break-word;
|
|
20
|
+
`,
|
|
21
|
+
});
|
|
22
|
+
|
|
16
23
|
/**
|
|
17
24
|
* Best attempt to make the children a plain string so it is copyable. If there
|
|
18
25
|
* are react elements, we will not be able to copy the content, and it will
|
|
@@ -35,21 +42,24 @@ export default function CodeBlock({
|
|
|
35
42
|
}: Props): JSX.Element {
|
|
36
43
|
const children = maybeStringifyChildren(rawChildren);
|
|
37
44
|
const language = className?.replace('language-', '') || undefined;
|
|
45
|
+
const styles = useEuiMemoizedStyles(getStyles);
|
|
38
46
|
|
|
39
47
|
if (metastring?.startsWith('interactive')) {
|
|
40
48
|
return <Demo {...props}>{children}</Demo>;
|
|
41
49
|
}
|
|
42
50
|
|
|
51
|
+
// Don't show the fullscreen button for one-liner snippets
|
|
52
|
+
const isOneLiner =
|
|
53
|
+
typeof children === 'string' && !children.trim().includes('\n');
|
|
54
|
+
|
|
43
55
|
return (
|
|
44
56
|
<EuiCodeBlock
|
|
45
57
|
{...props}
|
|
46
58
|
fontSize="m"
|
|
47
|
-
overflowHeight={450}
|
|
59
|
+
overflowHeight={isOneLiner ? undefined : 450}
|
|
48
60
|
language={language}
|
|
49
61
|
isCopyable
|
|
50
|
-
css={
|
|
51
|
-
word-break: break-word;
|
|
52
|
-
`}
|
|
62
|
+
css={styles.codeBlock}
|
|
53
63
|
>
|
|
54
64
|
{children}
|
|
55
65
|
</EuiCodeBlock>
|
|
@@ -88,7 +88,7 @@ function BreadcrumbsItem({
|
|
|
88
88
|
>
|
|
89
89
|
{children}
|
|
90
90
|
<meta itemProp="position" content={String(index + 1)} />
|
|
91
|
-
{!active && <EuiIcon type="
|
|
91
|
+
{!active && <EuiIcon type="chevronSingleRight" css={styles.icon} />}
|
|
92
92
|
</li>
|
|
93
93
|
);
|
|
94
94
|
}
|
|
@@ -75,8 +75,8 @@ function CardCategory({ item }: { item: PropSidebarItemCategory }): ReactNode {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
function CardLink({ item }: { item: PropSidebarItemLink }): ReactNode {
|
|
78
|
-
// We update Docusaurus `link` icon to EUI `
|
|
79
|
-
const icon = isInternalUrl(item.href) ? 'document' : '
|
|
78
|
+
// We update Docusaurus `link` icon to EUI `external` icon
|
|
79
|
+
const icon = isInternalUrl(item.href) ? 'document' : 'external';
|
|
80
80
|
const doc = useDocById(item.docId ?? undefined);
|
|
81
81
|
return (
|
|
82
82
|
<CardLayout
|