Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Storybook] Add stories for more components (letters R-S) - Part 4 #7733

Merged
merged 8 commits into from
May 8, 2024
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions src/components/steps/step.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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 { hideStorybookControls } from '../../../.storybook/utils';
import { EuiStep, EuiStepProps } from './step';

const meta: Meta<EuiStepProps> = {
title: 'Navigation/EuiSteps/EuiSteps/EuiStep',
component: EuiStep,
args: {
headingElement: 'p',
titleSize: 's',
step: 1,
},
};
hideStorybookControls(meta, ['aria-label']);

export default meta;
type Story = StoryObj<EuiStepProps>;

export const Playground: Story = {
args: {
title: 'Step 1',
children: 'lorem ipsum',
},
};
39 changes: 39 additions & 0 deletions src/components/steps/step_horizontal.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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 {
enableFunctionToggleControls,
hideStorybookControls,
} from '../../../.storybook/utils';
import { EuiStepHorizontal, EuiStepHorizontalProps } from './step_horizontal';

const meta: Meta<EuiStepHorizontalProps> = {
title: 'Navigation/EuiSteps/EuiStepsHorizontal/EuiStepHorizontal',
component: EuiStepHorizontal,
args: {
size: 'm',
step: 1,
status: 'incomplete',
// set up for easier testing/QA
disabled: false,
},
};
hideStorybookControls(meta, ['aria-label']);
enableFunctionToggleControls(meta, ['onClick']);

export default meta;
type Story = StoryObj<EuiStepHorizontalProps>;

export const Playground: Story = {
args: {
title: 'Step 1',
children: 'lorem ipsum',
},
};
30 changes: 30 additions & 0 deletions src/components/steps/step_number.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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 { hideStorybookControls } from '../../../.storybook/utils';
import { EuiStepNumber, EuiStepNumberProps } from './step_number';

const meta: Meta<EuiStepNumberProps> = {
title: 'Navigation/EuiSteps/Subcomponents/EuiStepNumber',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, if I remember correctly, we had a discussion some time ago about nesting conventions and agreed that we nest subcomponents under the components based on component name and that we wouldn't add other folders as that might be confusing? (conversation)

So the idea would be that EuiStepNumber is a subcomponent of EuiSteps (or even EuiStep) so it's nested under those.

Next to other components the naming Subcomponents now would mean there is a component called Subcomponents if we go by how we organized components so far 😅

component: EuiStepNumber,
args: {
titleSize: 's',
},
};
hideStorybookControls(meta, ['aria-label']);
cee-chen marked this conversation as resolved.
Show resolved Hide resolved

export default meta;
type Story = StoryObj<EuiStepNumberProps>;

export const Playground: Story = {
args: {
number: 1,
},
};
76 changes: 76 additions & 0 deletions src/components/steps/steps.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* 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 { moveStorybookControlsToCategory } from '../../../.storybook/utils';
import { EuiSteps, EuiStepsProps } from './steps';

const meta: Meta<EuiStepsProps> = {
title: 'Navigation/EuiSteps/EuiSteps',
cee-chen marked this conversation as resolved.
Show resolved Hide resolved
component: EuiSteps,
args: {
firstStepNumber: 1,
headingElement: 'p',
titleSize: 's',
},
};
moveStorybookControlsToCategory(
meta,
['headingElement', 'titleSize'],
'EuiStep props'
);

export default meta;
type Story = StoryObj<EuiStepsProps>;

export const Playground: Story = {
args: {
steps: [
{
title: 'Step 1',
children: 'lorem ipsum',
},
{
title: 'Step 2',
children: 'lorem ipsum',
status: 'current',
},
{
title: 'Step 3',
children: 'lorem ipsum',
status: 'complete',
},
{
title: 'Step 4',
children: 'lorem ipsum',
status: 'incomplete',
},
{
title: 'Step 5',
children: 'lorem ipsum',
status: 'warning',
},
{
title: 'Step 6',
children: 'lorem ipsum',
status: 'danger',
},
{
title: 'Step 7',
children: 'lorem ipsum',
status: 'loading',
},
{
title: 'Step 8',
children: 'lorem ipsum',
status: 'disabled',
},
],
},
};
76 changes: 76 additions & 0 deletions src/components/steps/steps_horizontal.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* 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 { action } from '@storybook/addon-actions';

import { moveStorybookControlsToCategory } from '../../../.storybook/utils';
import {
EuiStepsHorizontal,
EuiStepsHorizontalProps,
} from './steps_horizontal';

const meta: Meta<EuiStepsHorizontalProps> = {
title: 'Navigation/EuiSteps/EuiStepsHorizontal',
component: EuiStepsHorizontal,
args: {
size: 'm',
},
};
moveStorybookControlsToCategory(meta, ['size'], 'EuiStepHorizontal props');

export default meta;
type Story = StoryObj<EuiStepsHorizontalProps>;

const onClick = action('onClick');

export const Playground: Story = {
args: {
steps: [
{
title: 'Step 1',
onClick,
},
{
title: 'Step 2',
status: 'current',
onClick,
},
{
title: 'Step 3',
status: 'complete',
onClick,
},
{
title: 'Step 4',
status: 'incomplete',
onClick,
},
{
title: 'Step 5',
status: 'warning',
onClick,
},
{
title: 'Step 6',
status: 'danger',
onClick,
},
{
title: 'Step 7',
status: 'loading',
onClick,
},
{
title: 'Step 8',
status: 'disabled',
onClick,
},
],
},
};
25 changes: 25 additions & 0 deletions src/components/steps/sub_steps.stories.tsx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[just me thinking out loud] I sometimes wonder how much value consumers get from us exporting subcomponents like this, vs just the higher level components 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can have value to understand what's available, how it works etc. Or even to maybe reuse some components in other contexts even if unexpected? 🤔

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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 { EuiSubSteps, EuiSubStepsProps } from './sub_steps';

const meta: Meta<EuiSubStepsProps> = {
title: 'Navigation/EuiSteps/Subcomponents/EuiSubSteps',
component: EuiSubSteps,
};

export default meta;
type Story = StoryObj<EuiSubStepsProps>;

export const Playground: Story = {
args: {
children: 'lorem ipsum dolor sit',
},
};