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-19 01:22:15 +01:00
|
|
|
class PanelLayout extends React.PureComponent {
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
render() {
|
2020-02-21 00:57:29 +00:00
|
|
|
const {
|
|
|
|
title,
|
|
|
|
subtitle,
|
|
|
|
headerButtonTitle,
|
|
|
|
headerButtonAction,
|
|
|
|
headerButtonTo,
|
2020-11-07 05:20:22 +00:00
|
|
|
headerButtonHref,
|
2020-02-21 00:57:29 +00:00
|
|
|
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-08-18 21:49:11 +01:00
|
|
|
<aside className={[_s.d, _s.mb15].join(' ')}>
|
2020-02-22 23:26:23 +00:00
|
|
|
<Block>
|
|
|
|
{
|
|
|
|
(title || subtitle) &&
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.px15, _s.py10].join(' ')}>
|
|
|
|
<div className={[_s.d, _s.flexRow, _s.aiCenter].join(' ')}>
|
2020-04-24 04:17:27 +01:00
|
|
|
<Heading size='h2'>
|
2020-02-22 23:26:23 +00:00
|
|
|
{title}
|
|
|
|
</Heading>
|
|
|
|
{
|
2020-11-07 05:20:22 +00:00
|
|
|
(!!headerButtonTitle && (!!headerButtonAction || !!headerButtonTo || !!headerButtonHref)) &&
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _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}
|
2020-11-07 05:20:22 +00:00
|
|
|
href={headerButtonHref}
|
2020-02-22 23:26:23 +00:00
|
|
|
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-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _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-08-18 21:49:11 +01:00
|
|
|
<div className={_s.d}>
|
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-08-19 01:22:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PanelLayout.propTypes = {
|
|
|
|
title: PropTypes.string,
|
|
|
|
subtitle: PropTypes.string,
|
|
|
|
children: PropTypes.node,
|
|
|
|
headerButtonTitle: PropTypes.string,
|
|
|
|
headerButtonAction: PropTypes.func,
|
|
|
|
headerButtonTo: PropTypes.string,
|
2020-11-07 05:20:22 +00:00
|
|
|
headerButtonHref: PropTypes.string,
|
2020-08-19 01:22:15 +01:00
|
|
|
footerButtonTitle: PropTypes.string,
|
|
|
|
footerButtonAction: PropTypes.func,
|
|
|
|
footerButtonTo: PropTypes.string,
|
|
|
|
footerButtonHref: PropTypes.string,
|
|
|
|
noPadding: PropTypes.bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default PanelLayout
|