Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into add-window-provider…
Browse files Browse the repository at this point in the history
…-update
  • Loading branch information
stil committed Sep 5, 2024
2 parents a9a2388 + bdff5bd commit 6ec4cf0
Show file tree
Hide file tree
Showing 107 changed files with 2,573 additions and 1,099 deletions.
41 changes: 30 additions & 11 deletions .buildkite/scripts/pipelines/pipeline_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,80 @@

set -euo pipefail

# include utils
source .buildkite/scripts/common/utils.sh

buildkite_analytics_vault="secret/ci/elastic-eui/buildkite-test-analytics"

DOCKER_OPTIONS=(
-i --rm
--env GIT_COMMITTER_NAME=test
--env GIT_COMMITTER_EMAIL=test
--env HOME=/tmp
--env BUILDKITE_BRANCH
--env BUILDKITE_BUILD_ID
--env BUILDKITE_BUILD_NUMBER
--env BUILDKITE_BUILD_URL
--env BUILDKITE_COMMIT
--env BUILDKITE_JOB_ID
--env BUILDKITE_MESSAGE
--user="$(id -u):$(id -g)"
--volume="$(pwd):/app"
--workdir=/app
"$DOCKER_BASE_IMAGE"
)

COMMAND=""

case $TEST_TYPE in
lint)
echo "[TASK]: Running linters"
DOCKER_OPTIONS+=(bash -c "/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui lint")
COMMAND="/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui lint"
;;

unit:ts)
echo "[TASK]: Running .ts and .js unit tests"
DOCKER_OPTIONS+=(bash -c "/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui test-unit --node-options=--max_old_space_size=2048 --testMatch=non-react")
COMMAND="/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui test-unit --node-options=--max_old_space_size=2048 --testMatch=non-react"
;;

unit:tsx:16)
echo "[TASK]: Running Jest .tsx tests against React 16"
DOCKER_OPTIONS+=(bash -c "/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui test-unit --node-options=--max_old_space_size=2048 --react-version=16 --testMatch=react")
DOCKER_OPTIONS+=(--env BUILDKITE_ANALYTICS_TOKEN="$(retry 5 vault read -field=jest_token_react16 "${buildkite_analytics_vault}")")
COMMAND="/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui test-unit --node-options=--max_old_space_size=2048 --react-version=16 --testMatch=react"
;;

unit:tsx:17)
echo "[TASK]: Running Jest .tsx tests against React 17"
DOCKER_OPTIONS+=(bash -c "/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui test-unit --node-options=--max_old_space_size=2048 --react-version=17 --testMatch=react")
DOCKER_OPTIONS+=(--env BUILDKITE_ANALYTICS_TOKEN="$(retry 5 vault read -field=jest_token_react17 "${buildkite_analytics_vault}")")
COMMAND="/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui test-unit --node-options=--max_old_space_size=2048 --react-version=17 --testMatch=react"
;;

unit:tsx)
echo "[TASK]: Running Jest .tsx tests against React 18"
DOCKER_OPTIONS+=(bash -c "/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui test-unit --node-options=--max_old_space_size=2048 --testMatch=react")
DOCKER_OPTIONS+=(--env BUILDKITE_ANALYTICS_TOKEN="$(retry 5 vault read -field=jest_token_react18 "${buildkite_analytics_vault}")")
COMMAND="/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui test-unit --node-options=--max_old_space_size=2048 --testMatch=react"
;;

cypress:16)
echo "[TASK]: Running Cypress tests against React 16"
DOCKER_OPTIONS+=(bash -c "/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui cypress install && yarn --cwd packages/eui test-cypress --node-options=--max_old_space_size=2048 --react-version=16")
DOCKER_OPTIONS+=(--env BUILDKITE_ANALYTICS_TOKEN="$(retry 5 vault read -field=cypress_token_react16 "${buildkite_analytics_vault}")")
COMMAND="/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui cypress install && yarn --cwd packages/eui test-cypress --node-options=--max_old_space_size=2048 --react-version=16"
;;

cypress:17)
echo "[TASK]: Running Cypress tests against React 17"
DOCKER_OPTIONS+=(bash -c "/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui cypress install && yarn --cwd packages/eui test-cypress --node-options=--max_old_space_size=2048 --react-version=17")
DOCKER_OPTIONS+=(--env BUILDKITE_ANALYTICS_TOKEN="$(retry 5 vault read -field=cypress_token_react17 "${buildkite_analytics_vault}")")
COMMAND="/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui cypress install && yarn --cwd packages/eui test-cypress --node-options=--max_old_space_size=2048 --react-version=17"
;;

cypress:18)
echo "[TASK]: Running Cypress tests against React 18"
DOCKER_OPTIONS+=(bash -c "/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui cypress install && yarn --cwd packages/eui test-cypress --node-options=--max_old_space_size=2048")
DOCKER_OPTIONS+=(--env BUILDKITE_ANALYTICS_TOKEN="$(retry 5 vault read -field=cypress_token_react18 "${buildkite_analytics_vault}")")
COMMAND="/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui cypress install && yarn --cwd packages/eui test-cypress --node-options=--max_old_space_size=2048"
;;

cypress:a11y)
echo "[TASK]: Running Cypress accessibility tests against React 18"
DOCKER_OPTIONS+=(bash -c "/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui cypress install && yarn --cwd packages/eui run test-cypress-a11y --node-options=--max_old_space_size=2048")
COMMAND="/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui cypress install && yarn --cwd packages/eui run test-cypress-a11y --node-options=--max_old_space_size=2048"
;;

*)
Expand All @@ -66,4 +85,4 @@ case $TEST_TYPE in
;;
esac

docker run "${DOCKER_OPTIONS[@]}"
docker run "${DOCKER_OPTIONS[@]}" "${DOCKER_BASE_IMAGE}" bash -c "${COMMAND}"
15 changes: 13 additions & 2 deletions packages/docusaurus-theme/src/components/call_out/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { css } from '@emotion/react';
import { EuiText, useEuiMemoizedStyles, UseEuiTheme } from '@elastic/eui';
import {
EuiText,
useEuiMemoizedStyles,
UseEuiTheme,
euiFontSize,
} from '@elastic/eui';
import { FunctionComponent, PropsWithChildren } from 'react';

type VARIANTS = 'info' | 'tip' | 'note' | 'danger' | 'warning';
Expand Down Expand Up @@ -31,7 +36,8 @@ const VARIANT_TO_COLOR_MAP: Record<
},
};

const getStyles = ({ euiTheme }: UseEuiTheme, variant: VARIANTS) => {
const getStyles = (theme: UseEuiTheme, variant: VARIANTS) => {
const { euiTheme } = theme;
const colorKey = VARIANT_TO_COLOR_MAP[variant].colorKey;
const color = euiTheme.colors[colorKey];

Expand All @@ -50,13 +56,18 @@ const getStyles = ({ euiTheme }: UseEuiTheme, variant: VARIANTS) => {
--ifm-alert-border-width: ${euiTheme.border.width.thin};
--ifm-alert-border-left-width: ${euiTheme.border.width.thin};
--ifm-alert-border-color: ${color};
--ifm-alert-shadow: none;
[class^='admonitionHeading'] {
--ifm-alert-foreground-color: ${color};
color: var(--ifm-alert-foreground-color);
}
}
p {
${euiFontSize(theme, 's')}
}
`,
};
};
Expand Down
25 changes: 18 additions & 7 deletions packages/docusaurus-theme/src/theme/DocItem/Layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React from 'react';
import { EuiHorizontalRule } from '@elastic/eui';
import { css } from '@emotion/react';
import { useWindowSize } from '@docusaurus/theme-common';
import { useDoc } from '@docusaurus/theme-common/internal';
Expand All @@ -7,25 +16,27 @@ import Unlisted from '@theme-original/Unlisted';
import DocVersionBanner from '@theme-original/DocVersionBanner';
import DocVersionBadge from '@theme-original/DocVersionBadge';
import * as Props from '@theme-original/DocItem/Layout';
import { EuiHorizontalRule } from '@elastic/eui';

import DocBreadcrumbs from '../../DocBreadcrumbs';
import DocItemContent from '../Content';
import DocItemTOCMobile from '../TOC/Mobile';
import DocItemTOCDesktop from '../TOC/Desktop';
import DocItemContent from '../Content';
import DocItemFooter from '../Footer';

// converted from css modules to emotion
const layoutStyles = {
const styles = {
docItemContainer: css`
& header + *,
& article > *:first-child {
margin-top: 0;
}
`,
docItemRow: css`
justify-content: center;
`,
docItemCol: css`
@media (min-width: 997px) {
max-width: 764px;
max-width: 830px;
}
`,
};
Expand Down Expand Up @@ -60,11 +71,11 @@ export default function DocItemLayout({ children }: typeof Props): JSX.Element {
metadata: { unlisted },
} = useDoc();
return (
<div className="row">
<div className="col" css={layoutStyles.docItemCol}>
<div className="row" css={styles.docItemRow}>
<div className="col" css={styles.docItemCol}>
{unlisted && <Unlisted />}
<DocVersionBanner />
<div css={layoutStyles.docItemContainer}>
<div css={styles.docItemContainer}>
<article>
<DocBreadcrumbs />
<DocVersionBadge />
Expand Down
94 changes: 94 additions & 0 deletions packages/docusaurus-theme/src/theme/Heading/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import useBrokenLinks from '@docusaurus/useBrokenLinks';
import { Props as HeadingProps } from '@theme/Heading';
import {
EuiTitle,
EuiButtonIcon,
UseEuiTheme,
EuiTitleProps,
useEuiMemoizedStyles,
} from '@elastic/eui';
import { css } from '@emotion/react';

const TAG_TO_TITLE_SIZE_MAP: Record<string, EuiTitleProps['size']> = {
h6: 'xxxs',
h5: 'xxs',
h4: 'xs',
h3: 's',
h2: 'm',
h1: 'l',
};

const getHeadingStyles = ({ euiTheme }: UseEuiTheme) => ({
heading: css`
margin-block-start: calc(var(--eui-theme-content-vertical-spacing) * 2.5);
margin-block-end: var(--eui-theme-content-vertical-spacing);
scroll-margin-block-start: calc(var(--ifm-navbar-height) + 1rem);
&:first-child {
margin-block-start: var(--eui-theme-content-vertical-spacing);
}
`,

anchor: css`
margin-inline-start: ${euiTheme.size.s};
opacity: 0;
&:focus,
.heading:hover & {
opacity: 1;
}
`,
});

const Heading = ({
as: Component,
children,
id,
...restProps
}: HeadingProps) => {
const brokenLinks = useBrokenLinks();
const styles = useEuiMemoizedStyles(getHeadingStyles);

brokenLinks.collectAnchor(id);

const anchorTitle = `Direct link to ${
typeof children === 'string' ? children : id
}`;

// We don't want to show section links on document title headings
const shouldShowSectionLink = Component !== 'h1';

return (
<EuiTitle size={TAG_TO_TITLE_SIZE_MAP[Component]}>
<Component
{...restProps}
className="heading anchor"
css={styles.heading}
id={id}
>
{children}
{shouldShowSectionLink && (
<EuiButtonIcon
css={styles.anchor}
href={`#${id}`}
aria-label={anchorTitle}
title={anchorTitle}
iconType="link"
color="text"
size="xs"
/>
)}
</Component>
</EuiTitle>
);
};

export default Heading;
10 changes: 10 additions & 0 deletions packages/docusaurus-theme/src/theme/MDXComponents/A.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import type AType from '@theme-init/MDXComponents/A';
import type { WrapperProps } from '@docusaurus/types';
import { css } from '@emotion/react';
Expand All @@ -8,7 +16,9 @@ type Props = WrapperProps<typeof AType>;
const getStyles = ({ euiTheme }: UseEuiTheme) => {
return {
link: css`
font-weight: ${euiTheme.font.weight.bold};
text-decoration: underline;
text-decoration-color: currentColor;
`,
};
};
Expand Down
8 changes: 8 additions & 0 deletions packages/docusaurus-theme/src/theme/MDXComponents/Code.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React from 'react';
import type CodeType from '@theme-init/MDXComponents/Code';
import CodeBlock from '@theme/CodeBlock';
Expand Down
38 changes: 12 additions & 26 deletions packages/docusaurus-theme/src/theme/MDXComponents/Heading.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
import OriginalHeading from '@theme-init/MDXComponents/Heading';
import type HeadingType from '@theme-init/MDXComponents/Heading';
import type { WrapperProps } from '@docusaurus/types';
import { EuiTitle, EuiTitleSize } from '@elastic/eui';
import { FunctionComponent } from 'react';
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

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

const SIZE_TO_LEVEL_MAP: Record<string, EuiTitleSize> = {
h6: 'xxxs',
h5: 'xxs',
h4: 'xs',
h3: 's',
h2: 'm',
h1: 'l',
};
const MDXHeading = (props: HeadingProps): JSX.Element => (
<Heading {...props} />
);

const Heading: FunctionComponent<Omit<Props, 'as'> & { as: string }> = ({
as,
...rest
}): JSX.Element => {
return (
<EuiTitle size={SIZE_TO_LEVEL_MAP[as]}>
<OriginalHeading as={as} {...rest} />
</EuiTitle>
);
};

export default Heading;
export default MDXHeading;
20 changes: 20 additions & 0 deletions packages/docusaurus-theme/src/theme/MDXComponents/ListItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { HTMLAttributes } from 'react';
import { EuiText } from '@elastic/eui';

export const ListItem = ({ children, ...props }: HTMLAttributes<HTMLLIElement>) => {
return (
<li>
<EuiText size="m">
{children}
</EuiText>
</li>
);
};
Loading

0 comments on commit 6ec4cf0

Please sign in to comment.