From e04514e782b452e58b3f3aec6f3f8476caae9587 Mon Sep 17 00:00:00 2001 From: meriadec Date: Mon, 16 Apr 2018 14:51:21 +0200 Subject: [PATCH] Add ConfirmModal component --- src/components/base/Modal/ConfirmModal.js | 59 ++++++++++++++++++++++ src/components/base/Modal/stories.js | 60 +++++++++++++++-------- 2 files changed, 99 insertions(+), 20 deletions(-) create mode 100644 src/components/base/Modal/ConfirmModal.js diff --git a/src/components/base/Modal/ConfirmModal.js b/src/components/base/Modal/ConfirmModal.js new file mode 100644 index 00000000..4fd3364f --- /dev/null +++ b/src/components/base/Modal/ConfirmModal.js @@ -0,0 +1,59 @@ +// @flow + +import React, { PureComponent } from 'react' +import { translate } from 'react-i18next' + +import type { T } from 'types/common' + +import Button from 'components/base/Button' +import Box from 'components/base/Box' + +import { Modal, ModalContent, ModalBody, ModalTitle, ModalFooter } from './index' + +type Props = { + isOpened: boolean, + isDanger: boolean, + title: string, + subTitle: string, + desc: string, + confirmText: string, + cancelText: string, + t: T, +} + +class ConfirmModal extends PureComponent { + render() { + const { isOpened, title, subTitle, desc, confirmText, cancelText, isDanger, t } = this.props + + const realConfirmText = confirmText || t('common:confirm') + const realCancelText = cancelText || t('common:cancel') + return ( + ( + + {title} + + {subTitle && ( + + {subTitle} + + )} + + {desc} + + + + + + + + )} + /> + ) + } +} + +export default translate()(ConfirmModal) diff --git a/src/components/base/Modal/stories.js b/src/components/base/Modal/stories.js index 0516912a..1b95d374 100644 --- a/src/components/base/Modal/stories.js +++ b/src/components/base/Modal/stories.js @@ -2,29 +2,49 @@ import React from 'react' import { storiesOf } from '@storybook/react' -import { boolean } from '@storybook/addon-knobs' +import { action } from '@storybook/addon-actions' +import { boolean, text } from '@storybook/addon-knobs' -import { Modal, ModalBody, ModalTitle, ModalContent, ModalFooter } from 'components/base/Modal' +import { + Modal, + ModalBody, + ModalTitle, + ModalContent, + ModalFooter, + ConfirmModal, +} from 'components/base/Modal' import Box from 'components/base/Box' import Button from 'components/base/Button' const stories = storiesOf('Components/base', module) -stories.add('Modal', () => { - const isOpened = boolean('isOpened', true) - return ( - ( - - {'modal title'} - {'this is the modal content'} - - {'modal footer'} - - - - )} - /> - ) -}) +stories.add('Modal', () => ( + ( + + {'modal title'} + {'this is the modal content'} + + {'modal footer'} + + + + )} + /> +)) + +stories.add('ConfirmModal', () => ( + +))