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 (letter D) - Part 1 #7762

Merged
merged 4 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
37 changes: 37 additions & 0 deletions packages/eui/src/components/delay_hide/delay_hide.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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 { EuiLoadingSpinner } from '../loading';
import { EuiDelayHide, EuiDelayHideProps } from './delay_hide';

const meta: Meta<EuiDelayHideProps> = {
title: 'Utilities/EuiDelayHide',
component: EuiDelayHide,
parameters: {
loki: {
// VRT is not really useful here as the main functionality is the timeout
skip: true,
},
},
args: {
hide: false,
minimumDuration: 1000,
},
};

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

export const Playground: Story = {
args: {
render: () => <EuiLoadingSpinner />,
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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, { useEffect, useState } from 'react';
import type { Meta, StoryObj } from '@storybook/react';

import { EuiLoadingSpinner } from '../loading';
import { EuiDelayRender, EuiDelayRenderProps } from './delay_render';

const meta: Meta<EuiDelayRenderProps> = {
title: 'Utilities/EuiDelayRender',
component: EuiDelayRender,
parameters: {
loki: {
// VRT is not really useful here as the main functionality is the delay
skip: true,
},
},
args: {
delay: 500,
},
};

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

export const Playground: Story = {
args: {
children: <EuiLoadingSpinner />,
},
render: (args) => <StatefulPlayground {...args} />,
};

// stateful wrapper to ensure changing args triggers a new mount of
// the component without having to refresh the page
const StatefulPlayground = (props: EuiDelayRenderProps) => {
const [render, setRender] = useState(true);

useEffect(() => {
setRender(false);
setTimeout(() => {
setRender(true);
}, 0);
}, [props]);

return render ? <EuiDelayRender {...props} /> : null;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* 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 { faker } from '@faker-js/faker';

faker.seed(42);

const listItems = Array.from({ length: 3 }, () => ({
title: faker.lorem.sentence(),
description: faker.lorem.sentences(2),
}));
import { moveStorybookControlsToCategory } from '../../../.storybook/utils';
import { EuiDescriptionListProps } from './description_list_types';
import { EuiDescriptionList } from './description_list';

const meta: Meta<EuiDescriptionListProps> = {
title: 'Display/EuiDescriptionList',
component: EuiDescriptionList,
args: {
align: 'left',
compressed: false,
textStyle: 'normal',
type: 'row',
rowGutterSize: 's',
columnGutterSize: 's',
},
};

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

export const Playground: Story = {
args: {
listItems,
},
};
mgadewoll marked this conversation as resolved.
Show resolved Hide resolved
moveStorybookControlsToCategory(
Playground,
['columnGutterSize', 'columnWidths'],
'Column layout'
);
moveStorybookControlsToCategory(Playground, ['rowGutterSize'], 'Row layout');

export const Column: Story = {
parameters: {
controls: {
include: [
'align',
'columnGutterSize',
'columnWidths',
'compressed',
'descriptionProps',
'textStyle',
'titleProps',
'type',
],
},
},
args: {
listItems,
type: 'column',
},
};

export const Row: Story = {
parameters: {
controls: {
include: [
'align',
'compressed',
'descriptionProps',
'rowGutterSize',
'textStyle',
'titleProps',
'type',
],
},
},
args: {
listItems,
type: 'row',
},
};

export const Inline: Story = {
parameters: {
controls: {
include: ['align', 'compressed', 'descriptionProps', 'titleProps'],
},
},
args: {
listItems,
type: 'inline',
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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 {
EuiDescriptionListDescription,
EuiDescriptionListDescriptionProps,
} from './description_list_description';

const meta: Meta<EuiDescriptionListDescriptionProps> = {
title:
'Display/EuiDescriptionList/Subcomponents/EuiDescriptionListDescription',
component: EuiDescriptionListDescription,
};
hideStorybookControls(meta, ['aria-label']);

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

export const Playground: Story = {
args: {
children: 'Description list description',
},
};
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 {
EuiDescriptionListTitle,
EuiDescriptionListTitleProps,
} from './description_list_title';

const meta: Meta<EuiDescriptionListTitleProps> = {
title: 'Display/EuiDescriptionList/Subcomponents/EuiDescriptionListTitle',
component: EuiDescriptionListTitle,
};
hideStorybookControls(meta, ['aria-label']);

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

export const Playground: Story = {
args: {
children: 'Description list title',
},
};
Loading