2019-07-17 11:20:02 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { storiesOf } from '@storybook/react';
|
|
|
|
import { Toast, toastr } from 'asc-web-components';
|
|
|
|
import Readme from './README.md';
|
2019-07-18 15:26:34 +00:00
|
|
|
import { text, boolean, withKnobs, select, number } from '@storybook/addon-knobs/react';
|
2019-07-17 11:20:02 +00:00
|
|
|
import withReadme from 'storybook-readme/with-readme';
|
|
|
|
import Section from '../../../.storybook/decorators/section';
|
|
|
|
|
|
|
|
const type = ['success', 'error', 'warning', 'info'];
|
|
|
|
|
|
|
|
storiesOf('Components|Toast', module)
|
|
|
|
.addDecorator(withKnobs)
|
|
|
|
.addDecorator(withReadme(Readme))
|
|
|
|
.add('base', () => {
|
|
|
|
const toastType = `${select('type', type, 'success')}`;
|
2019-07-24 08:19:09 +00:00
|
|
|
const toastData = `${text('data (only text in storybook)', 'Demo text for Toast')}`;
|
2019-07-17 11:20:02 +00:00
|
|
|
const titleToast = `${text('title', 'Demo title')}`;
|
2019-07-23 15:52:02 +00:00
|
|
|
const withCross = boolean('withCross', false);
|
|
|
|
const timeout = number('timeout', '5000');
|
2019-07-17 11:20:02 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Toast />
|
|
|
|
<Section>
|
|
|
|
<button onClick={() => {
|
|
|
|
switch (toastType) {
|
|
|
|
case 'error':
|
2019-07-24 08:19:09 +00:00
|
|
|
toastr.error(toastData, titleToast, timeout, withCross);
|
2019-07-17 11:20:02 +00:00
|
|
|
break;
|
|
|
|
case 'warning':
|
2019-07-24 08:19:09 +00:00
|
|
|
toastr.warning(toastData, titleToast, timeout, withCross);
|
2019-07-17 11:20:02 +00:00
|
|
|
break;
|
|
|
|
case 'info':
|
2019-07-24 08:19:09 +00:00
|
|
|
toastr.info(toastData, titleToast, timeout, withCross);
|
2019-07-17 11:20:02 +00:00
|
|
|
break;
|
|
|
|
default:
|
2019-07-24 08:19:09 +00:00
|
|
|
toastr.success(toastData, titleToast, timeout, withCross);
|
2019-07-17 11:20:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}}>
|
|
|
|
Show toast</button>
|
|
|
|
</Section>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
});
|