2020-02-28 15:20:47 +00:00
|
|
|
import Block from '../block'
|
2020-07-06 21:13:44 +01:00
|
|
|
import Button from '../button'
|
2020-05-13 01:36:54 +01:00
|
|
|
import Heading from '../heading'
|
2020-07-06 21:13:44 +01:00
|
|
|
import Text from '../text'
|
2020-02-28 15:20:47 +00:00
|
|
|
|
|
|
|
export default class PopoverLayout extends PureComponent {
|
2020-05-13 01:36:54 +01:00
|
|
|
|
2020-03-24 04:39:12 +00:00
|
|
|
static propTypes = {
|
|
|
|
children: PropTypes.node,
|
2020-04-07 02:53:23 +01:00
|
|
|
width: PropTypes.number,
|
2020-05-13 01:36:54 +01:00
|
|
|
isXS: PropTypes.bool,
|
|
|
|
title: PropTypes.string,
|
2020-07-06 21:13:44 +01:00
|
|
|
onClose: PropTypes.func,
|
2020-04-07 02:53:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
width: 250,
|
2020-03-24 04:39:12 +00:00
|
|
|
}
|
|
|
|
|
2020-07-06 21:13:44 +01:00
|
|
|
handleOnClose = () => {
|
|
|
|
this.props.onClose()
|
|
|
|
}
|
|
|
|
|
2020-02-19 23:57:07 +00:00
|
|
|
render() {
|
2020-05-13 01:36:54 +01:00
|
|
|
const {
|
|
|
|
children,
|
|
|
|
width,
|
|
|
|
isXS,
|
|
|
|
title,
|
|
|
|
} = this.props
|
|
|
|
|
|
|
|
if (isXS) {
|
|
|
|
return (
|
2020-07-06 21:13:44 +01:00
|
|
|
<div className={[_s.default, _s.modal, _s.px10, _s.pb10].join(' ')}>
|
|
|
|
<div className={[_s.default, _s.bgPrimary, _s.radiusSmall, _s.overflowHidden, _s.mb10].join(' ')}>
|
|
|
|
{
|
|
|
|
!!title &&
|
|
|
|
<div className={[_s.default, _s.flexRow, _s.alignItemsCenter, _s.justifyContentCenter, _s.borderBottom1PX, _s.borderColorSecondary, _s.height53PX, _s.px15].join(' ')}>
|
|
|
|
<Heading size='2'>
|
|
|
|
{title}
|
|
|
|
</Heading>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
<div className={[_s.default, _s.heightMax80VH, _s.radiusSmall, _s.overflowYScroll].join(' ')}>
|
|
|
|
{children}
|
2020-05-13 01:36:54 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-07-06 21:13:44 +01:00
|
|
|
|
|
|
|
<Button
|
|
|
|
backgroundColor='primary'
|
|
|
|
color='primary'
|
|
|
|
onClick={this.handleOnClose}
|
|
|
|
radiusSmall
|
|
|
|
>
|
|
|
|
<Text color='inherit' size='large' align='center'>
|
|
|
|
Cancel
|
|
|
|
</Text>
|
|
|
|
</Button>
|
2020-05-13 01:36:54 +01:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2020-02-28 15:20:47 +00:00
|
|
|
|
2020-02-19 23:57:07 +00:00
|
|
|
return (
|
2020-05-13 01:36:54 +01:00
|
|
|
<div style={{ width: `${width}px` }} className={_s.modal}>
|
2020-02-28 15:20:47 +00:00
|
|
|
<Block>
|
|
|
|
{children}
|
|
|
|
</Block>
|
2020-02-19 23:57:07 +00:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2020-05-13 01:36:54 +01:00
|
|
|
|
2020-02-19 23:57:07 +00:00
|
|
|
}
|