2020-02-22 23:26:23 +00:00
|
|
|
import Block from '../block'
|
2020-02-19 23:57:07 +00:00
|
|
|
import Heading from '../heading'
|
|
|
|
import Button from '../button'
|
2020-02-21 00:57:29 +00:00
|
|
|
import Text from '../text'
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
export default class PanelLayout extends PureComponent {
|
|
|
|
static propTypes = {
|
|
|
|
title: PropTypes.string,
|
2020-02-05 22:45:48 +00:00
|
|
|
subtitle: PropTypes.string,
|
2019-08-07 06:02:36 +01:00
|
|
|
children: PropTypes.node,
|
2020-02-21 00:57:29 +00:00
|
|
|
headerButtonTitle: PropTypes.string,
|
|
|
|
headerButtonAction: PropTypes.func,
|
|
|
|
headerButtonTo: PropTypes.func,
|
|
|
|
footerButtonTitle: PropTypes.string,
|
|
|
|
footerButtonAction: PropTypes.func,
|
|
|
|
footerButtonTo: PropTypes.func,
|
2020-02-19 23:57:07 +00:00
|
|
|
noPadding: PropTypes.bool,
|
2020-02-05 22:45:48 +00:00
|
|
|
}
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
render() {
|
2020-02-21 00:57:29 +00:00
|
|
|
const {
|
|
|
|
title,
|
|
|
|
subtitle,
|
|
|
|
headerButtonTitle,
|
|
|
|
headerButtonAction,
|
|
|
|
headerButtonTo,
|
|
|
|
footerButtonTitle,
|
|
|
|
footerButtonAction,
|
|
|
|
footerButtonTo,
|
|
|
|
noPadding,
|
|
|
|
children,
|
|
|
|
} = this.props
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
return (
|
2020-02-22 23:26:23 +00:00
|
|
|
<aside className={[_s.default, _s.marginBottom15PX].join(' ')}>
|
|
|
|
<Block>
|
|
|
|
{
|
|
|
|
(title || subtitle) &&
|
|
|
|
<div className={[_s.default, _s.paddingHorizontal15PX, _s.paddingVertical10PX, _s.borderColorSecondary, _s.borderBottom1PX].join(' ')}>
|
|
|
|
<div className={[_s.default, _s.flexRow, _s.alignItemsCenter].join(' ')}>
|
|
|
|
<Heading size='h3'>
|
|
|
|
{title}
|
|
|
|
</Heading>
|
|
|
|
{
|
|
|
|
(!!headerButtonTitle && (!!headerButtonAction || !!headerButtonTo)) &&
|
|
|
|
<div className={[_s.default, _s.marginLeftAuto].join(' ')}>
|
|
|
|
<Button
|
|
|
|
text
|
|
|
|
backgroundColor='none'
|
|
|
|
color='brand'
|
|
|
|
to={headerButtonTo}
|
|
|
|
onClick={headerButtonAction}
|
|
|
|
>
|
|
|
|
<Text size='small' color='inherit' weight='bold'>
|
|
|
|
{headerButtonTitle}
|
|
|
|
</Text>
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
</div>
|
2020-02-08 06:12:01 +00:00
|
|
|
{
|
2020-02-22 23:26:23 +00:00
|
|
|
subtitle &&
|
|
|
|
<Heading size='h4'>
|
|
|
|
{subtitle}
|
|
|
|
</Heading>
|
2020-02-08 06:12:01 +00:00
|
|
|
}
|
2020-02-05 22:45:48 +00:00
|
|
|
</div>
|
2020-02-22 23:26:23 +00:00
|
|
|
}
|
2020-02-19 23:57:07 +00:00
|
|
|
|
2020-02-22 23:26:23 +00:00
|
|
|
{
|
|
|
|
!noPadding &&
|
|
|
|
<div className={[_s.default, _s.paddingHorizontal15PX, _s.paddingVertical10PX].join(' ')}>
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
}
|
2020-02-19 23:57:07 +00:00
|
|
|
|
2020-02-22 23:26:23 +00:00
|
|
|
{
|
|
|
|
noPadding && children
|
|
|
|
}
|
2020-02-21 00:57:29 +00:00
|
|
|
|
2020-02-22 23:26:23 +00:00
|
|
|
{
|
|
|
|
(!!footerButtonTitle && (!!footerButtonAction || !!footerButtonTo)) &&
|
|
|
|
<div className={[_s.default, _s.borderColorSecondary, _s.borderTop1PX].join(' ')}>
|
|
|
|
<Button
|
|
|
|
text
|
|
|
|
color='none'
|
|
|
|
backgroundColor='none'
|
|
|
|
to={footerButtonTo}
|
|
|
|
onClick={footerButtonAction}
|
|
|
|
className={[_s.paddingHorizontal15PX, _s.paddingVertical15PX, _s.backgroundSubtle_onHover].join(' ')}
|
|
|
|
>
|
|
|
|
<Text color='brand' align='left' size='medium'>
|
|
|
|
{footerButtonTitle}
|
|
|
|
</Text>
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
</Block>
|
2020-02-05 22:45:48 +00:00
|
|
|
</aside>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|