2020-02-24 21:56:07 +00:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl'
|
2020-03-24 04:39:12 +00:00
|
|
|
import classNames from 'classnames/bind'
|
2020-02-24 21:56:07 +00:00
|
|
|
import Button from '../button'
|
|
|
|
import Block from '../block'
|
|
|
|
import Heading from '../heading'
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-03-24 04:39:12 +00:00
|
|
|
const cx = classNames.bind(_s)
|
|
|
|
|
2019-08-07 06:02:36 +01:00
|
|
|
const messages = defineMessages({
|
|
|
|
close: { id: 'lightbox.close', defaultMessage: 'Close' },
|
2020-02-24 21:56:07 +00:00
|
|
|
})
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-02-24 21:56:07 +00:00
|
|
|
export default
|
|
|
|
@injectIntl
|
2019-08-07 06:02:36 +01:00
|
|
|
class ModalLayout extends PureComponent {
|
2020-05-14 21:45:39 +01:00
|
|
|
|
2019-08-07 06:02:36 +01:00
|
|
|
static propTypes = {
|
|
|
|
title: PropTypes.string,
|
|
|
|
children: PropTypes.node,
|
|
|
|
onClose: PropTypes.func.isRequired,
|
2020-03-24 04:39:12 +00:00
|
|
|
width: PropTypes.number,
|
|
|
|
hideClose: PropTypes.bool,
|
|
|
|
noPadding: PropTypes.bool,
|
2020-05-14 21:45:39 +01:00
|
|
|
isXS: PropTypes.bool,
|
2020-03-24 04:39:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
width: 600,
|
2020-02-24 21:56:07 +00:00
|
|
|
}
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-03-25 03:08:43 +00:00
|
|
|
onHandleCloseModal = () => {
|
2020-04-07 02:53:23 +01:00
|
|
|
this.props.onClose()
|
2020-03-25 03:08:43 +00:00
|
|
|
}
|
|
|
|
|
2019-08-07 06:02:36 +01:00
|
|
|
render() {
|
2020-03-07 04:53:28 +00:00
|
|
|
const {
|
|
|
|
title,
|
|
|
|
children,
|
|
|
|
intl,
|
2020-03-24 04:39:12 +00:00
|
|
|
width,
|
|
|
|
hideClose,
|
2020-05-14 21:45:39 +01:00
|
|
|
noPadding,
|
|
|
|
isXS,
|
2020-03-07 04:53:28 +00:00
|
|
|
} = this.props
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-03-24 04:39:12 +00:00
|
|
|
const childrenContainerClasses = cx({
|
|
|
|
default: 1,
|
2020-03-25 03:08:43 +00:00
|
|
|
heightMax80VH: 1,
|
2020-03-27 15:29:52 +00:00
|
|
|
overflowYScroll: 1,
|
2020-03-24 04:39:12 +00:00
|
|
|
px15: !noPadding,
|
|
|
|
py10: !noPadding,
|
|
|
|
})
|
|
|
|
|
2019-08-07 06:02:36 +01:00
|
|
|
return (
|
2020-05-14 21:45:39 +01:00
|
|
|
<div style={{width: `${width}px`}} className={[_s.default, _s.modal].join(' ')}>
|
2020-02-24 21:56:07 +00:00
|
|
|
<Block>
|
2020-03-11 23:56:18 +00:00
|
|
|
<div className={[_s.default, _s.flexRow, _s.alignItemsCenter, _s.justifyContentCenter, _s.borderBottom1PX, _s.borderColorSecondary, _s.height53PX, _s.px15].join(' ')}>
|
2020-04-24 04:17:27 +01:00
|
|
|
<Heading size='h2'>
|
2020-02-24 21:56:07 +00:00
|
|
|
{title}
|
|
|
|
</Heading>
|
2020-03-24 04:39:12 +00:00
|
|
|
{
|
2020-05-14 21:45:39 +01:00
|
|
|
!hideClose && !isXS &&
|
2020-03-24 04:39:12 +00:00
|
|
|
<Button
|
|
|
|
backgroundColor='none'
|
|
|
|
title={intl.formatMessage(messages.close)}
|
2020-04-24 04:17:27 +01:00
|
|
|
className={_s.mlAuto}
|
2020-03-25 03:08:43 +00:00
|
|
|
onClick={this.onHandleCloseModal}
|
2020-03-27 15:29:52 +00:00
|
|
|
color='secondary'
|
2020-03-24 04:39:12 +00:00
|
|
|
icon='close'
|
2020-04-23 07:13:29 +01:00
|
|
|
iconSize='10px'
|
2020-03-24 04:39:12 +00:00
|
|
|
/>
|
|
|
|
}
|
2020-02-24 21:56:07 +00:00
|
|
|
</div>
|
2020-03-24 04:39:12 +00:00
|
|
|
<div className={childrenContainerClasses}>
|
2020-02-24 21:56:07 +00:00
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
</Block>
|
2019-08-07 06:02:36 +01:00
|
|
|
</div>
|
|
|
|
)
|
2020-02-24 21:56:07 +00:00
|
|
|
}
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
}
|