-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert Modal and BaseModal to TypeScript (#2355)
* Convert Modal to tsx * Migrate basemodal * organize imports * remove unused prop * Setup userevent * update url
- Loading branch information
1 parent
e356d61
commit 38a6095
Showing
7 changed files
with
145 additions
and
103 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,98 @@ | ||
import { Meta, StoryObj } from '@storybook/react' | ||
import noop from 'lodash/noop' | ||
import { useState } from 'react' | ||
|
||
import Button from 'ui/Button' | ||
|
||
import BaseModal from './BaseModal' | ||
import Modal, { ModalProps } from './Modal' | ||
|
||
|
||
export default { | ||
title: 'Components/Modal', | ||
component: Modal, | ||
} as Meta | ||
|
||
type Story = StoryObj<typeof Modal> | ||
|
||
const RenderTemplate: React.FC<{ args: ModalProps }> = ({ args }) => { | ||
const [isOpen, setIsOpen] = useState(false) | ||
args.isOpen = isOpen | ||
args.onClose = () => setIsOpen(false) | ||
return ( | ||
<> | ||
<Button | ||
hook="open" | ||
onClick={() => setIsOpen(true)} | ||
to="" | ||
disabled={false} | ||
> | ||
Open | ||
</Button> | ||
<Modal {...args} /> | ||
</> | ||
) | ||
} | ||
|
||
export const SimpleModal: Story = { | ||
args: { | ||
title: 'Simple modal', | ||
body: 'You can use the body to render any JSX', | ||
}, | ||
render: (args) => <RenderTemplate args={args} />, | ||
} | ||
|
||
export const ModalWithFooter: Story = { | ||
args: { | ||
title: 'Modal with a footer', | ||
body: 'The footer will appear under a line, good place for buttons', | ||
footer: ( | ||
<Button to="" disabled={false} hook=""> | ||
Footer here | ||
</Button> | ||
), | ||
}, | ||
render: (args) => <RenderTemplate args={args} />, | ||
} | ||
|
||
export const ModalWithSubtitle: Story = { | ||
args: { | ||
title: 'Modal with a subtitle', | ||
subtitle: 'You can add some extra content under the title with this prop', | ||
body: 'And it should render well with a body', | ||
}, | ||
render: (args) => <RenderTemplate args={args} />, | ||
} | ||
|
||
export const ModalWithNoCloseButton: Story = { | ||
args: { | ||
title: 'Modal with no close button', | ||
body: "You pass the prop hasCloseButton={false} so the close button doesn't appear next to the title", | ||
hasCloseButton: false, | ||
}, | ||
render: (args) => <RenderTemplate args={args} />, | ||
} | ||
|
||
export const BaseModalOnly: React.FC = () => ( | ||
<div className="bg-gray-900 p-20"> | ||
<div className="w-1/3"> | ||
<BaseModal | ||
onClose={noop} | ||
title="<BaseModal/>" | ||
body={ | ||
<div className="flex flex-col"> | ||
<span> | ||
You can only use the Modal/BaseModal to only use the styling of | ||
the modal itself if you need to shell it differently | ||
</span> | ||
</div> | ||
} | ||
footer={ | ||
<Button to="" disabled={false} hook=""> | ||
Footer here | ||
</Button> | ||
} | ||
/> | ||
</div> | ||
</div> | ||
) |
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