diff --git a/packages/eui/.loki/reference/chrome_desktop_Display_EuiIconTip_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Display_EuiIconTip_Playground.png new file mode 100644 index 00000000000..2953e95c376 Binary files /dev/null and b/packages/eui/.loki/reference/chrome_desktop_Display_EuiIconTip_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Display_EuiToken_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Display_EuiToken_Playground.png new file mode 100644 index 00000000000..bb956bf733e Binary files /dev/null and b/packages/eui/.loki/reference/chrome_desktop_Display_EuiToken_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Display_EuiToolTip_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Display_EuiToolTip_Playground.png new file mode 100644 index 00000000000..3216010dd8a Binary files /dev/null and b/packages/eui/.loki/reference/chrome_desktop_Display_EuiToolTip_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Display_EuiTour_EuiTourStepIndicator_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Display_EuiTour_EuiTourStepIndicator_Playground.png new file mode 100644 index 00000000000..f5d538c6f22 Binary files /dev/null and b/packages/eui/.loki/reference/chrome_desktop_Display_EuiTour_EuiTourStepIndicator_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Display_EuiTour_EuiTourStep_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Display_EuiTour_EuiTourStep_Playground.png new file mode 100644 index 00000000000..2c4f16a4526 Binary files /dev/null and b/packages/eui/.loki/reference/chrome_desktop_Display_EuiTour_EuiTourStep_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Display_EuiTour_EuiTour_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Display_EuiTour_EuiTour_Playground.png new file mode 100644 index 00000000000..7a32a7d9833 Binary files /dev/null and b/packages/eui/.loki/reference/chrome_desktop_Display_EuiTour_EuiTour_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Display_EuiIconTip_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Display_EuiIconTip_Playground.png new file mode 100644 index 00000000000..a0221465ac2 Binary files /dev/null and b/packages/eui/.loki/reference/chrome_mobile_Display_EuiIconTip_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Display_EuiToken_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Display_EuiToken_Playground.png new file mode 100644 index 00000000000..1bf9b742520 Binary files /dev/null and b/packages/eui/.loki/reference/chrome_mobile_Display_EuiToken_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Display_EuiToolTip_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Display_EuiToolTip_Playground.png new file mode 100644 index 00000000000..d400c371727 Binary files /dev/null and b/packages/eui/.loki/reference/chrome_mobile_Display_EuiToolTip_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Display_EuiTour_EuiTourStepIndicator_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Display_EuiTour_EuiTourStepIndicator_Playground.png new file mode 100644 index 00000000000..48259cae195 Binary files /dev/null and b/packages/eui/.loki/reference/chrome_mobile_Display_EuiTour_EuiTourStepIndicator_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Display_EuiTour_EuiTourStep_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Display_EuiTour_EuiTourStep_Playground.png new file mode 100644 index 00000000000..b6fe9346d54 Binary files /dev/null and b/packages/eui/.loki/reference/chrome_mobile_Display_EuiTour_EuiTourStep_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Display_EuiTour_EuiTour_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Display_EuiTour_EuiTour_Playground.png new file mode 100644 index 00000000000..2d40e5165eb Binary files /dev/null and b/packages/eui/.loki/reference/chrome_mobile_Display_EuiTour_EuiTour_Playground.png differ diff --git a/packages/eui/src/components/token/token.stories.tsx b/packages/eui/src/components/token/token.stories.tsx new file mode 100644 index 00000000000..fbeaf5ab848 --- /dev/null +++ b/packages/eui/src/components/token/token.stories.tsx @@ -0,0 +1,36 @@ +/* + * 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 { Meta, StoryObj } from '@storybook/react'; + +import { EuiTokenProps } from './token_types'; +import { EuiToken } from './token'; + +const meta: Meta = { + title: 'Display/EuiToken', + component: EuiToken, + argTypes: { + iconType: { control: 'text' }, + }, + args: { + size: 's', + fill: 'light', + shape: 'circle', + // set up for easier testing/QA + title: '', + }, +}; + +export default meta; +type Story = StoryObj; + +export const Playground: Story = { + args: { + iconType: 'tokenAlias', + }, +}; diff --git a/packages/eui/src/components/tool_tip/icon_tip.stories.tsx b/packages/eui/src/components/tool_tip/icon_tip.stories.tsx new file mode 100644 index 00000000000..2aa0621f0c5 --- /dev/null +++ b/packages/eui/src/components/tool_tip/icon_tip.stories.tsx @@ -0,0 +1,82 @@ +/* + * 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 { Meta, StoryObj } from '@storybook/react'; + +import { + enableFunctionToggleControls, + moveStorybookControlsToCategory, +} from '../../../.storybook/utils'; +import { LOKI_SELECTORS } from '../../../.storybook/loki'; +import { EuiFlexGroup } from '../flex'; +import { EuiIconTip, Props as EuiIconTipProps } from './icon_tip'; + +const meta: Meta = { + title: 'Display/EuiIconTip', + component: EuiIconTip, + parameters: { + layout: 'fullscreen', + loki: { + chromeSelector: LOKI_SELECTORS.portal, + }, + }, + decorators: [ + (Story, { args }) => ( + + + + ), + ], + args: { + type: 'questionInCircle', + position: 'top', + delay: 'regular', + display: 'inlineBlock', + // set up for easier testing/QA + anchorClassName: '', + repositionOnScroll: false, + title: '', + }, +}; +enableFunctionToggleControls(meta, ['onMouseOut']); +moveStorybookControlsToCategory( + meta, + [ + 'anchorClassName', + 'anchorProps', + 'content', + 'children', + 'display', + 'onMouseOut', + 'repositionOnScroll', + 'title', + ], + 'EuiToolTip props' +); + +export default meta; +type Story = StoryObj; + +export const Playground: Story = { + args: { + content: 'tooltip content', + iconProps: { + // using autoFocus here as small trick to ensure showing the tooltip on load (e.g. for VRT) + // TODO: exchange for loki play() interactions once #7735 is merged + // @ts-ignore - temp. solution for storybook VRT testing + autofocus: 'true', + }, + }, +}; diff --git a/packages/eui/src/components/tool_tip/icon_tip.tsx b/packages/eui/src/components/tool_tip/icon_tip.tsx index b8fcd876e6a..a9e52fbff23 100644 --- a/packages/eui/src/components/tool_tip/icon_tip.tsx +++ b/packages/eui/src/components/tool_tip/icon_tip.tsx @@ -44,7 +44,7 @@ export interface EuiIconTipProps { iconProps?: Omit, 'type'> & { type?: never }; } -type Props = Omit & +export type Props = Omit & EuiIconTipProps & { // This are copied from EuiToolTipProps, but made optional. Defaults // are applied below. diff --git a/packages/eui/src/components/tool_tip/tool_tip.stories.tsx b/packages/eui/src/components/tool_tip/tool_tip.stories.tsx new file mode 100644 index 00000000000..8c4deb06263 --- /dev/null +++ b/packages/eui/src/components/tool_tip/tool_tip.stories.tsx @@ -0,0 +1,74 @@ +/* + * 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 { Meta, StoryObj } from '@storybook/react'; + +import { enableFunctionToggleControls } from '../../../.storybook/utils'; +import { LOKI_SELECTORS } from '../../../.storybook/loki'; +import { EuiFlexGroup } from '../flex'; +import { EuiButton } from '../button'; +import { EuiToolTip, EuiToolTipProps } from './tool_tip'; + +const meta: Meta = { + title: 'Display/EuiToolTip', + component: EuiToolTip, + parameters: { + layout: 'fullscreen', + loki: { + chromeSelector: LOKI_SELECTORS.portal, + }, + }, + decorators: [ + (Story, { args }) => ( + + + + ), + ], + args: { + position: 'top', + delay: 'regular', + display: 'inlineBlock', + // set up for easier testing/QA + anchorClassName: '', + repositionOnScroll: false, + title: '', + }, +}; +enableFunctionToggleControls(meta, ['onMouseOut']); + +export default meta; +type Story = StoryObj; + +export const Playground: Story = { + args: { + // using autoFocus here as small trick to ensure showing the tooltip on load (e.g. for VRT) + // TODO: uncomment loki play() interactions and remove autoFocus once #7747 is merged + children: Tooltip trigger, + content: 'tooltip content', + }, + // play: lokiPlayDecorator(async (context) => { + // const { bodyElement, step } = context; + + // const canvas = within(bodyElement); + + // await step('show tooltip on click', async () => { + // await userEvent.click(canvas.getByRole('button')); + // await waitFor(() => { + // expect(canvas.getByRole('tooltip')).toBeVisible(); + // }); + // }); + // }), +}; diff --git a/packages/eui/src/components/tour/tour.stories.tsx b/packages/eui/src/components/tour/tour.stories.tsx new file mode 100644 index 00000000000..47c1bdd8e5f --- /dev/null +++ b/packages/eui/src/components/tour/tour.stories.tsx @@ -0,0 +1,119 @@ +/* + * 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 { Meta, StoryObj } from '@storybook/react'; +import { action } from '@storybook/addon-actions'; + +import { EuiFlexGroup } from '../flex'; +import { EuiButton, EuiButtonIcon } from '../button'; +import { EuiTour, EuiTourProps } from './tour'; +import { EuiTourStep } from './tour_step'; + +const meta: Meta = { + title: 'Display/EuiTour/EuiTour', + component: EuiTour, + parameters: { + layout: 'fullscreen', + }, + decorators: [ + (Story, { args }) => ( + + + + ), + ], +}; + +export default meta; +type Story = StoryObj; + +export const Playground: Story = { + args: { + initialState: { + currentTourStep: 1, + isTourActive: true, + tourPopoverWidth: 300, + tourSubtitle: '', + }, + steps: [ + { + title: 'Welcome!', + content: 'Tour step content', + step: 1, + stepsTotal: 2, + minWidth: 300, + maxWidth: 600, + decoration: 'beacon', + children: , + onFinish: () => {}, + anchorPosition: 'downCenter', + }, + { + title: 'Goodbye!', + content: 'Tour step content', + step: 2, + stepsTotal: 2, + minWidth: 300, + maxWidth: 600, + decoration: 'beacon', + children: , + onFinish: () => {}, + anchorPosition: 'rightCenter', + }, + ], + }, + render: (args) => , +}; + +const StatefulTour = (props: EuiTourProps) => { + return ( + + {(stepProps, actions, { currentTourStep, isTourActive }) => { + const showNext = isTourActive && currentTourStep < stepProps.length; + + const handleIncrementStep = () => { + actions.incrementStep(); + action('incrementStep')(); + }; + + const handleFinishTour = () => { + actions.finishTour(); + action('onFinish')(); + }; + + return ( + <> + {stepProps.map((props) => ( + + + Finish Tour + + {showNext && ( + Next + )} + + } + /> + ))} + + ); + }} + + ); +}; diff --git a/packages/eui/src/components/tour/tour_step.stories.tsx b/packages/eui/src/components/tour/tour_step.stories.tsx new file mode 100644 index 00000000000..5a76eeea3b3 --- /dev/null +++ b/packages/eui/src/components/tour/tour_step.stories.tsx @@ -0,0 +1,69 @@ +/* + * 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 { Meta, StoryObj } from '@storybook/react'; + +import { + disableStorybookControls, + enableFunctionToggleControls, +} from '../../../.storybook/utils'; +import { EuiFlexGroup } from '../flex'; +import { EuiButtonIcon } from '../button'; +import { EuiTourStep, EuiTourStepProps } from './tour_step'; + +const meta: Meta = { + title: 'Display/EuiTour/EuiTourStep', + component: EuiTourStep, + parameters: { + layout: 'fullscreen', + }, + decorators: [ + (Story, { args }) => ( + + + + ), + ], + argTypes: { + content: { control: 'text' }, + title: { control: 'text' }, + subtitle: { control: 'text' }, + }, + args: { + anchorPosition: 'leftUp', + isStepOpen: false, + minWidth: 300, + maxWidth: 600, + step: 1, + decoration: 'beacon', + // set up for easier testing/QA + subtitle: '', + }, +}; +enableFunctionToggleControls(meta, ['onFinish']); +disableStorybookControls(meta, ['closePopover']); + +export default meta; +type Story = StoryObj; + +export const Playground: Story = { + args: { + title: 'Welcome!', + content: 'Tour step content', + isStepOpen: true, + stepsTotal: 3, + children: , + }, +}; diff --git a/packages/eui/src/components/tour/tour_step_indicator.stories.tsx b/packages/eui/src/components/tour/tour_step_indicator.stories.tsx new file mode 100644 index 00000000000..e4fe7425ccd --- /dev/null +++ b/packages/eui/src/components/tour/tour_step_indicator.stories.tsx @@ -0,0 +1,29 @@ +/* + * 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 { Meta, StoryObj } from '@storybook/react'; + +import { + EuiTourStepIndicator, + EuiTourStepIndicatorProps, +} from './tour_step_indicator'; + +const meta: Meta = { + title: 'Display/EuiTour/EuiTourStepIndicator', + component: EuiTourStepIndicator, +}; + +export default meta; +type Story = StoryObj; + +export const Playground: Story = { + args: { + number: 1, + status: 'active', + }, +};