// @flow
import * as React from 'react';
import { IntlProvider } from 'react-intl';
import { State, Store } from '@sambego/storybook-state';
import Button from '../../button/Button';
import PrimaryButton from '../../primary-button/PrimaryButton';
import Notification from '../Notification';
import NotificationsWrapper from '../NotificationsWrapper';
import notes from './NotificationsWrapper.stories.md';
export const example = () => {
const DATE = new Date('May 13, 2002 23:15:30').toTimeString();
const componentStore = new Store({
id: 0,
notifications: new Map(),
});
const closeNotification = id => {
const notifications = componentStore.get('notifications');
notifications.delete(id);
componentStore.set({ notifications });
};
const addNotification = (duration, type) => {
const id = componentStore.get('id');
const notifications = componentStore.get('notifications');
const notification = (
closeNotification(id)} type={type}>
Hello world! I was made at {DATE}
);
componentStore.set({
notifications: notifications.set(id, notification),
id: id + 1,
});
};
return (
{state => (
{[...state.notifications.values()]}
addNotification(undefined, 'warn')}>
Display persistent notification
)}
);
};
export default {
title: 'Components|Notifications/NotificationsWrapper',
component: NotificationsWrapper,
parameters: {
notes,
},
};