Skip to content

Commit 977029b

Browse files
authored
Merge branch 'elastic:main' into main
2 parents ee97aa8 + e36e441 commit 977029b

File tree

142 files changed

+3806
-2897
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+3806
-2897
lines changed

packages/docusaurus-theme/src/components/call_out/index.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { css } from '@emotion/react';
2-
import { EuiText, useEuiMemoizedStyles, UseEuiTheme } from '@elastic/eui';
2+
import {
3+
EuiText,
4+
useEuiMemoizedStyles,
5+
UseEuiTheme,
6+
euiFontSize,
7+
} from '@elastic/eui';
38
import { FunctionComponent, PropsWithChildren } from 'react';
49

510
type VARIANTS = 'info' | 'tip' | 'note' | 'danger' | 'warning';
@@ -31,7 +36,8 @@ const VARIANT_TO_COLOR_MAP: Record<
3136
},
3237
};
3338

34-
const getStyles = ({ euiTheme }: UseEuiTheme, variant: VARIANTS) => {
39+
const getStyles = (theme: UseEuiTheme, variant: VARIANTS) => {
40+
const { euiTheme } = theme;
3541
const colorKey = VARIANT_TO_COLOR_MAP[variant].colorKey;
3642
const color = euiTheme.colors[colorKey];
3743

@@ -50,13 +56,18 @@ const getStyles = ({ euiTheme }: UseEuiTheme, variant: VARIANTS) => {
5056
--ifm-alert-border-width: ${euiTheme.border.width.thin};
5157
--ifm-alert-border-left-width: ${euiTheme.border.width.thin};
5258
--ifm-alert-border-color: ${color};
59+
--ifm-alert-shadow: none;
5360
5461
[class^='admonitionHeading'] {
5562
--ifm-alert-foreground-color: ${color};
5663
5764
color: var(--ifm-alert-foreground-color);
5865
}
5966
}
67+
68+
p {
69+
${euiFontSize(theme, 's')}
70+
}
6071
`,
6172
};
6273
};

packages/docusaurus-theme/src/theme/DocItem/Layout/index.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
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+
19
import React from 'react';
10+
import { EuiHorizontalRule } from '@elastic/eui';
211
import { css } from '@emotion/react';
312
import { useWindowSize } from '@docusaurus/theme-common';
413
import { useDoc } from '@docusaurus/theme-common/internal';
@@ -7,25 +16,27 @@ import Unlisted from '@theme-original/Unlisted';
716
import DocVersionBanner from '@theme-original/DocVersionBanner';
817
import DocVersionBadge from '@theme-original/DocVersionBadge';
918
import * as Props from '@theme-original/DocItem/Layout';
10-
import { EuiHorizontalRule } from '@elastic/eui';
1119

1220
import DocBreadcrumbs from '../../DocBreadcrumbs';
13-
import DocItemContent from '../Content';
1421
import DocItemTOCMobile from '../TOC/Mobile';
1522
import DocItemTOCDesktop from '../TOC/Desktop';
23+
import DocItemContent from '../Content';
1624
import DocItemFooter from '../Footer';
1725

1826
// converted from css modules to emotion
19-
const layoutStyles = {
27+
const styles = {
2028
docItemContainer: css`
2129
& header + *,
2230
& article > *:first-child {
2331
margin-top: 0;
2432
}
2533
`,
34+
docItemRow: css`
35+
justify-content: center;
36+
`,
2637
docItemCol: css`
2738
@media (min-width: 997px) {
28-
max-width: 764px;
39+
max-width: 830px;
2940
}
3041
`,
3142
};
@@ -60,11 +71,11 @@ export default function DocItemLayout({ children }: typeof Props): JSX.Element {
6071
metadata: { unlisted },
6172
} = useDoc();
6273
return (
63-
<div className="row">
64-
<div className="col" css={layoutStyles.docItemCol}>
74+
<div className="row" css={styles.docItemRow}>
75+
<div className="col" css={styles.docItemCol}>
6576
{unlisted && <Unlisted />}
6677
<DocVersionBanner />
67-
<div css={layoutStyles.docItemContainer}>
78+
<div css={styles.docItemContainer}>
6879
<article>
6980
<DocBreadcrumbs />
7081
<DocVersionBadge />
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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 useBrokenLinks from '@docusaurus/useBrokenLinks';
10+
import { Props as HeadingProps } from '@theme/Heading';
11+
import {
12+
EuiTitle,
13+
EuiButtonIcon,
14+
UseEuiTheme,
15+
EuiTitleProps,
16+
useEuiMemoizedStyles,
17+
} from '@elastic/eui';
18+
import { css } from '@emotion/react';
19+
20+
const TAG_TO_TITLE_SIZE_MAP: Record<string, EuiTitleProps['size']> = {
21+
h6: 'xxxs',
22+
h5: 'xxs',
23+
h4: 'xs',
24+
h3: 's',
25+
h2: 'm',
26+
h1: 'l',
27+
};
28+
29+
const getHeadingStyles = ({ euiTheme }: UseEuiTheme) => ({
30+
heading: css`
31+
margin-block-start: calc(var(--eui-theme-content-vertical-spacing) * 2.5);
32+
margin-block-end: var(--eui-theme-content-vertical-spacing);
33+
scroll-margin-block-start: calc(var(--ifm-navbar-height) + 1rem);
34+
35+
&:first-child {
36+
margin-block-start: var(--eui-theme-content-vertical-spacing);
37+
}
38+
`,
39+
40+
anchor: css`
41+
margin-inline-start: ${euiTheme.size.s};
42+
opacity: 0;
43+
44+
&:focus,
45+
.heading:hover & {
46+
opacity: 1;
47+
}
48+
`,
49+
});
50+
51+
const Heading = ({
52+
as: Component,
53+
children,
54+
id,
55+
...restProps
56+
}: HeadingProps) => {
57+
const brokenLinks = useBrokenLinks();
58+
const styles = useEuiMemoizedStyles(getHeadingStyles);
59+
60+
brokenLinks.collectAnchor(id);
61+
62+
const anchorTitle = `Direct link to ${
63+
typeof children === 'string' ? children : id
64+
}`;
65+
66+
// We don't want to show section links on document title headings
67+
const shouldShowSectionLink = Component !== 'h1';
68+
69+
return (
70+
<EuiTitle size={TAG_TO_TITLE_SIZE_MAP[Component]}>
71+
<Component
72+
{...restProps}
73+
className="heading anchor"
74+
css={styles.heading}
75+
id={id}
76+
>
77+
{children}
78+
{shouldShowSectionLink && (
79+
<EuiButtonIcon
80+
css={styles.anchor}
81+
href={`#${id}`}
82+
aria-label={anchorTitle}
83+
title={anchorTitle}
84+
iconType="link"
85+
color="text"
86+
size="xs"
87+
/>
88+
)}
89+
</Component>
90+
</EuiTitle>
91+
);
92+
};
93+
94+
export default Heading;

packages/docusaurus-theme/src/theme/MDXComponents/A.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
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+
19
import type AType from '@theme-init/MDXComponents/A';
210
import type { WrapperProps } from '@docusaurus/types';
311
import { css } from '@emotion/react';
@@ -8,7 +16,9 @@ type Props = WrapperProps<typeof AType>;
816
const getStyles = ({ euiTheme }: UseEuiTheme) => {
917
return {
1018
link: css`
19+
font-weight: ${euiTheme.font.weight.bold};
1120
text-decoration: underline;
21+
text-decoration-color: currentColor;
1222
`,
1323
};
1424
};

packages/docusaurus-theme/src/theme/MDXComponents/Code.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
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+
19
import React from 'react';
210
import type CodeType from '@theme-init/MDXComponents/Code';
311
import CodeBlock from '@theme/CodeBlock';
Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,15 @@
1-
import OriginalHeading from '@theme-init/MDXComponents/Heading';
2-
import type HeadingType from '@theme-init/MDXComponents/Heading';
3-
import type { WrapperProps } from '@docusaurus/types';
4-
import { EuiTitle, EuiTitleSize } from '@elastic/eui';
5-
import { FunctionComponent } from 'react';
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+
*/
68

7-
type Props = WrapperProps<typeof HeadingType>;
9+
import Heading, { Props as HeadingProps } from '@theme/Heading';
810

9-
const SIZE_TO_LEVEL_MAP: Record<string, EuiTitleSize> = {
10-
h6: 'xxxs',
11-
h5: 'xxs',
12-
h4: 'xs',
13-
h3: 's',
14-
h2: 'm',
15-
h1: 'l',
16-
};
11+
const MDXHeading = (props: HeadingProps): JSX.Element => (
12+
<Heading {...props} />
13+
);
1714

18-
const Heading: FunctionComponent<Omit<Props, 'as'> & { as: string }> = ({
19-
as,
20-
...rest
21-
}): JSX.Element => {
22-
return (
23-
<EuiTitle size={SIZE_TO_LEVEL_MAP[as]}>
24-
<OriginalHeading as={as} {...rest} />
25-
</EuiTitle>
26-
);
27-
};
28-
29-
export default Heading;
15+
export default MDXHeading;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 { HTMLAttributes } from 'react';
10+
import { EuiText } from '@elastic/eui';
11+
12+
export const ListItem = ({ children, ...props }: HTMLAttributes<HTMLLIElement>) => {
13+
return (
14+
<li>
15+
<EuiText size="m">
16+
{children}
17+
</EuiText>
18+
</li>
19+
);
20+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 { HTMLAttributes } from 'react';
10+
import { useEuiMemoizedStyles, UseEuiTheme } from '@elastic/eui';
11+
import { css } from '@emotion/react';
12+
13+
const getOrderedListStyles = ({ euiTheme }: UseEuiTheme) => css`
14+
margin-inline-start: ${euiTheme.size.l};
15+
`;
16+
17+
export const OrderedList = ({ children, ...restProps }: HTMLAttributes<HTMLUListElement>) => {
18+
const styles = useEuiMemoizedStyles(getOrderedListStyles);
19+
20+
return (
21+
<ol {...restProps} css={styles}>
22+
{children}
23+
</ol>
24+
);
25+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
import { HTMLAttributes } from 'react';
10+
import { EuiText, useEuiMemoizedStyles } from '@elastic/eui';
11+
import { css } from '@emotion/react';
12+
13+
const getParagraphStyles = () => css`
14+
margin-block: var(--eui-theme-content-vertical-spacing);
15+
16+
&:first-child {
17+
margin-block-start: 0;
18+
}
19+
20+
&:last-child {
21+
margin-block-end: 0;
22+
}
23+
`;
24+
25+
export const Paragraph = ({ children }: HTMLAttributes<HTMLParagraphElement>) => {
26+
const styles = useEuiMemoizedStyles(getParagraphStyles);
27+
28+
return (
29+
<EuiText size="m" css={styles}>
30+
<p>
31+
{children}
32+
</p>
33+
</EuiText>
34+
);
35+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 { HTMLAttributes } from 'react';
10+
import { useEuiMemoizedStyles, UseEuiTheme } from '@elastic/eui';
11+
import { css } from '@emotion/react';
12+
13+
const getUnorderedListStyles = ({ euiTheme }: UseEuiTheme) => css`
14+
margin-inline-start: ${euiTheme.size.l};
15+
`;
16+
17+
export const UnorderedList = ({ children, ...restProps }: HTMLAttributes<HTMLUListElement>) => {
18+
const styles = useEuiMemoizedStyles(getUnorderedListStyles);
19+
20+
return (
21+
<ul {...restProps} css={styles}>
22+
{children}
23+
</ul>
24+
);
25+
};

0 commit comments

Comments
 (0)