Commit 100e7eb9 by Uchechukwu Obasi Committed by GitHub

Alert: update story to use controls (#31145)

* Alert: updated story to use Controls

* updated some changes
parent 7f1f5599
import React from 'react'; import React from 'react';
import { Story } from '@storybook/react';
import { action } from '@storybook/addon-actions'; import { action } from '@storybook/addon-actions';
import { Alert, AlertVariant, VerticalGroup } from '@grafana/ui'; import { Alert, AlertVariant, VerticalGroup } from '@grafana/ui';
import { Props } from './Alert';
import { withCenteredStory, withHorizontallyCenteredStory } from '../../utils/storybook/withCenteredStory'; import { withCenteredStory, withHorizontallyCenteredStory } from '../../utils/storybook/withCenteredStory';
import mdx from '../Alert/Alert.mdx'; import mdx from '../Alert/Alert.mdx';
import { StoryExample } from '../../utils/storybook/StoryExample'; import { StoryExample } from '../../utils/storybook/StoryExample';
const severities: AlertVariant[] = ['error', 'warning', 'info', 'success'];
export default { export default {
title: 'Overlays/Alert', title: 'Overlays/Alert',
component: Alert, component: Alert,
...@@ -13,26 +17,30 @@ export default { ...@@ -13,26 +17,30 @@ export default {
docs: { docs: {
page: mdx, page: mdx,
}, },
knobs: {
disabled: true,
},
},
argTypes: {
severity: { control: { type: 'select', options: severities } },
}, },
}; };
const severities: AlertVariant[] = ['error', 'warning', 'info', 'success']; export const Examples: Story<Props> = ({ severity, title, buttonContent }) => {
export const Examples = () => {
return ( return (
<VerticalGroup> <VerticalGroup>
<StoryExample name="With buttonContent and children"> <StoryExample name="With buttonContent and children">
<Alert <Alert
title="Some very important message" title={title}
severity="error" severity={severity}
buttonContent={<span>Close</span>} buttonContent={<span>{buttonContent}</span>}
onRemove={action('Remove button clicked')} onRemove={action('Remove button clicked')}
> >
Child content that includes some alert details, like maybe what actually happened. Child content that includes some alert details, like maybe what actually happened.
</Alert> </Alert>
</StoryExample> </StoryExample>
<StoryExample name="No dismiss"> <StoryExample name="No dismiss">
<Alert title="Some very important message" severity="info" /> <Alert title={title} severity={severity} />
</StoryExample> </StoryExample>
<StoryExample name="Severities"> <StoryExample name="Severities">
<VerticalGroup> <VerticalGroup>
...@@ -49,3 +57,9 @@ export const Examples = () => { ...@@ -49,3 +57,9 @@ export const Examples = () => {
</VerticalGroup> </VerticalGroup>
); );
}; };
Examples.args = {
severity: 'error',
title: 'Some very important message',
buttonContent: 'Close',
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment