This repository has been archived by the owner on Jan 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modal (prev. modali) Storybook stories (#1508)
* export ModalOptions and ModalProps * Modal stories * use action and make modal smaller * rename css variable to generic + variable defaults
- Loading branch information
Showing
6 changed files
with
72 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react' | ||
import { action } from '@storybook/addon-actions' | ||
// also exported from '@storybook/react' if you can deal with breaking changes in 6.1 | ||
import { Story, Meta } from '@storybook/react/types-6-0' | ||
import Modal, { ModalOptions, ModalProps, useModal } from 'components/common/Modal' | ||
import { LoremIpsum } from 'storybook/LoremIpsum' | ||
|
||
const { Modal: ModalComponent } = Modal | ||
|
||
export default { | ||
title: 'Common/Modal', | ||
component: ModalComponent, | ||
} as Meta | ||
|
||
const Template: Story<{ props: ModalProps; options?: ModalOptions }> = (args) => { | ||
const [modalHook, toggleModal] = useModal(args.options) | ||
return ( | ||
<> | ||
<button onClick={toggleModal}>Open Modal</button> | ||
<ModalComponent {...args} {...modalHook} /> | ||
</> | ||
) | ||
} | ||
|
||
const LoremDefaultModalOptions = { | ||
title: 'Lorem Ipsum', | ||
message: ( | ||
<div style={{ height: '20rem', overflowY: 'auto' }}> | ||
<LoremIpsum /> | ||
</div> | ||
), | ||
} | ||
|
||
export const LoremOneButton = Template.bind({}) | ||
LoremOneButton.args = { | ||
options: { | ||
...LoremDefaultModalOptions, | ||
buttons: [ | ||
<> </>, | ||
<Modal.Button label="Close" key="yes" isStyleDefault onClick={action('Close button clicked')} />, | ||
], | ||
}, | ||
} | ||
|
||
export const LoremTwoButtons = Template.bind({}) | ||
LoremTwoButtons.args = { | ||
options: { | ||
...LoremDefaultModalOptions, | ||
buttons: [ | ||
<Modal.Button label="Cancel" key="cancel" isStyleCancel onClick={action('Close button clicked')} />, | ||
<Modal.Button label="Confirm" key="confirm" isStyleDefault onClick={action('Confirm button clicked')} />, | ||
], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters