|
| 1 | +// @flow |
| 2 | +import * as React from 'react'; |
| 3 | +import { boolean } from '@storybook/addon-knobs'; |
| 4 | +import { State, Store } from '@sambego/storybook-state'; |
| 5 | + |
| 6 | +import PrimaryButton from '../../../components/primary-button/PrimaryButton'; |
| 7 | +import { ACCESS_OPEN } from '../../../constants'; |
| 8 | + |
| 9 | +import ShareDialog from '../ShareDialog'; |
| 10 | +import notes from './ShareDialog.stories.md'; |
| 11 | + |
| 12 | +export const shareDialog = () => { |
| 13 | + const componentStore = new Store({ |
| 14 | + isModalOpen: false, |
| 15 | + }); |
| 16 | + |
| 17 | + const openModal = () => |
| 18 | + componentStore.set({ |
| 19 | + isModalOpen: true, |
| 20 | + }); |
| 21 | + |
| 22 | + const closeModal = () => componentStore.set({ isModalOpen: false }); |
| 23 | + |
| 24 | + const rootElement = document.createElement('div'); |
| 25 | + const appElement = document.createElement('div'); |
| 26 | + rootElement.appendChild(appElement); |
| 27 | + if (document.body) { |
| 28 | + document.body.appendChild(rootElement); |
| 29 | + } |
| 30 | + |
| 31 | + return ( |
| 32 | + <State store={componentStore}> |
| 33 | + {state => ( |
| 34 | + <div> |
| 35 | + <ShareDialog |
| 36 | + appElement={appElement} |
| 37 | + canSetShareAccess={boolean('canSetShareAccess', true)} |
| 38 | + isLoading={boolean('isLoading', false)} |
| 39 | + isOpen={state.isModalOpen} |
| 40 | + item={{ |
| 41 | + id: 'abcdefg', |
| 42 | + shared_link: { |
| 43 | + access: ACCESS_OPEN, |
| 44 | + url: 'https://cloud.box.com/s/abcdefg', |
| 45 | + }, |
| 46 | + }} |
| 47 | + onCancel={closeModal} |
| 48 | + onShareAccessChange={() => null} |
| 49 | + parentElement={rootElement} |
| 50 | + /> |
| 51 | + <PrimaryButton onClick={openModal}>Launch ShareDialog</PrimaryButton> |
| 52 | + </div> |
| 53 | + )} |
| 54 | + </State> |
| 55 | + ); |
| 56 | +}; |
| 57 | + |
| 58 | +export default { |
| 59 | + title: 'Elements|ContentExplorer|ShareDialog', |
| 60 | + component: ShareDialog, |
| 61 | + parameters: { |
| 62 | + notes, |
| 63 | + }, |
| 64 | +}; |
0 commit comments