2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-08-17 21:59:29 +01:00
|
|
|
import PropTypes from 'prop-types'
|
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
|
|
|
|
2020-08-17 21:07:16 +01:00
|
|
|
export default class PanelLayout extends React.PureComponent {
|
2020-07-02 03:07:58 +01:00
|
|
|
|
2019-08-07 06:02:36 +01:00
|
|
|
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,
|
2020-04-22 06:00:11 +01:00
|
|
|
headerButtonTo: PropTypes.string,
|
2020-02-21 00:57:29 +00:00
|
|
|
footerButtonTitle: PropTypes.string,
|
|
|
|
footerButtonAction: PropTypes.func,
|
2020-04-22 06:00:11 +01:00
|
|
|
footerButtonTo: PropTypes.string,
|
2020-07-02 03:07:58 +01:00
|
|
|
footerButtonHref: PropTypes.string,
|
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,
|
2020-07-02 03:07:58 +01:00
|
|
|
footerButtonHref,
|
2020-02-21 00:57:29 +00:00
|
|
|
noPadding,
|
|
|
|
children,
|
|
|
|
} = this.props
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
return (
|
2020-03-11 23:56:18 +00:00
|
|
|
<aside className={[_s.default, _s.mb15].join(' ')}>
|
2020-02-22 23:26:23 +00:00
|
|
|
<Block>
|
|
|
|
{
|
|
|
|
(title || subtitle) &&
|
2020-04-24 04:17:27 +01:00
|
|
|
<div className={[_s.default, _s.px15, _s.py10].join(' ')}>
|
2020-02-22 23:26:23 +00:00
|
|
|
<div className={[_s.default, _s.flexRow, _s.alignItemsCenter].join(' ')}>
|
2020-04-24 04:17:27 +01:00
|
|
|
<Heading size='h2'>
|
2020-02-22 23:26:23 +00:00
|
|
|
{title}
|
|
|
|
</Heading>
|
|
|
|
{
|
|
|
|
(!!headerButtonTitle && (!!headerButtonAction || !!headerButtonTo)) &&
|
2020-04-24 04:17:27 +01:00
|
|
|
<div className={[_s.default, _s.mlAuto].join(' ')}>
|
2020-02-22 23:26:23 +00:00
|
|
|
<Button
|
2020-04-23 07:13:29 +01:00
|
|
|
isText
|
2020-02-22 23:26:23 +00:00
|
|
|
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 &&
|
2020-03-11 23:56:18 +00:00
|
|
|
<div className={[_s.default, _s.px15, _s.py10].join(' ')}>
|
2020-02-22 23:26:23 +00:00
|
|
|
{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
|
|
|
{
|
2020-07-02 03:07:58 +01:00
|
|
|
(!!footerButtonTitle && (!!footerButtonAction || !!footerButtonTo || !!footerButtonHref)) &&
|
2020-04-24 04:17:27 +01:00
|
|
|
<div className={_s.default}>
|
2020-02-22 23:26:23 +00:00
|
|
|
<Button
|
2020-04-23 07:13:29 +01:00
|
|
|
isText
|
2020-02-22 23:26:23 +00:00
|
|
|
color='none'
|
|
|
|
backgroundColor='none'
|
|
|
|
to={footerButtonTo}
|
2020-07-02 03:07:58 +01:00
|
|
|
href={footerButtonHref}
|
2020-02-22 23:26:23 +00:00
|
|
|
onClick={footerButtonAction}
|
2020-04-29 23:32:49 +01:00
|
|
|
className={[_s.px15, _s.py15, _s.bgSubtle_onHover].join(' ')}
|
2020-02-22 23:26:23 +00:00
|
|
|
>
|
2020-04-23 07:13:29 +01:00
|
|
|
<Text color='brand' size='medium'>
|
2020-02-22 23:26:23 +00:00
|
|
|
{footerButtonTitle}
|
|
|
|
</Text>
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
</Block>
|
2020-02-05 22:45:48 +00:00
|
|
|
</aside>
|
|
|
|
)
|
|
|
|
}
|
2020-07-02 03:07:58 +01:00
|
|
|
|
2020-02-05 22:45:48 +00:00
|
|
|
}
|