Merge pull request #32 from edewit/fix-alert-story

update story
This commit is contained in:
Stan Silvert 2020-08-20 13:00:27 -04:00 committed by GitHub
commit 3a7c8f501c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,22 +3,16 @@ import { AlertVariant, Button } from '@patternfly/react-core';
import { storiesOf } from '@storybook/react';
import { AlertPanel } from '../src/components/alert/AlertPanel';
import { withAlerts, useAlerts } from '../src/components/alert/Alerts';
import { useAlerts } from '../src/components/alert/Alerts';
storiesOf('Alert Panel', module)
storiesOf('Alert Panel')
.add('api', () => <AlertPanel alerts={[{ key: 1, message: 'Hello', variant: AlertVariant.default }]} onCloseAlert={() => { }} />)
.add('add alert', () => {
const Comp = () => {
const [alerts, add, hide] = useAlerts();
return (
<>
<AlertPanel alerts={alerts} onCloseAlert={hide} />
<Button onClick={() => add('Hello', AlertVariant.default)}>Add</Button>
</>
);
}
const WrapperComponent = withAlerts(Comp);
const [add, alerts, hide] = useAlerts();
return (
<WrapperComponent/>
<>
<AlertPanel alerts={alerts} onCloseAlert={hide} />
<Button onClick={() => add('Hello', AlertVariant.default)}>Add</Button>
</>
);
});