You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import React, { useState } from 'react'
import { ModalInline, Box, Label, Button, Modal } from '../..'
const variants = [
'primary', 'danger', 'success', 'info', 'secondary', 'default', 'light',
]
export const Default: React.FC<any> = (props) => {
const {
label,
icon,
title,
variant,
subTitle,
} = props
const [isVisible, setIsVisible] = useState(false)
const modalProps = {
label,
icon,
title,
variant,
subTitle,
onOverlayClick: () => setIsVisible(false),
onClose: () => setIsVisible(false),
buttons: [
{ label: 'Cancel' },
{ label: 'Delete', variant },
],
}
return (
<Box variant="grey">
<Label>Inline modal: ModalInline</Label>
<Box py="xxl" width={1}>
<ModalInline {...modalProps} />
</Box>
<Box>
<Label>Modal Trigger</Label>
<Button
onClick={() => setIsVisible(!isVisible)}
>
Toggle Modal
</Button>
{isVisible && <Modal {...modalProps} />}
</Box>
</Box>
)
}
export default {
title: 'DesignSystem/Molecules/Modal',
argTypes: {
variant: {
defaultValue: variants[0],
options: variants,
control: { type: 'select' },
},
title: {
defaultValue: 'Are you sure you want to delete this car?',
control: { type: 'text' },
},
subTitle: {
defaultValue: 'This item will be deleted immediately. You cant undo this action.',
control: { type: 'text' },
},
icon: {
defaultValue: 'Warning',
control: { type: 'text' },
},
label: {
defaultValue: 'Warning',
control: { type: 'text' },
},
},
}