gab-social/app/javascript/gabsocial/components/modal/modal_layout.js

80 lines
1.9 KiB
JavaScript
Raw Normal View History

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'
2020-03-24 04:39:12 +00:00
const cx = classNames.bind(_s)
const messages = defineMessages({
close: { id: 'lightbox.close', defaultMessage: 'Close' },
2020-02-24 21:56:07 +00:00
})
2020-02-24 21:56:07 +00:00
export default
@injectIntl
class ModalLayout extends PureComponent {
static propTypes = {
title: PropTypes.string,
children: PropTypes.node,
onClose: PropTypes.func.isRequired,
2020-03-25 03:08:43 +00:00
handleCloseModal: PropTypes.func.isRequired,
2020-03-24 04:39:12 +00:00
width: PropTypes.number,
hideClose: PropTypes.bool,
noPadding: PropTypes.bool,
}
static defaultProps = {
width: 600,
2020-02-24 21:56:07 +00: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
}
render() {
2020-03-07 04:53:28 +00:00
const {
title,
children,
intl,
2020-03-24 04:39:12 +00:00
width,
hideClose,
noPadding
2020-03-07 04:53:28 +00:00
} = this.props
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,
})
return (
2020-03-24 04:39:12 +00:00
<div style={{width: `${width}px`}}>
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
{
!hideClose &&
<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>
</div>
)
2020-02-24 21:56:07 +00:00
}
}