111 lines
3.0 KiB
JavaScript
Raw Normal View History

import React from 'react'
import PropTypes from 'prop-types'
2020-02-22 18:26:23 -05:00
import Block from '../block'
2020-02-19 18:57:07 -05:00
import Heading from '../heading'
import Button from '../button'
2020-02-20 19:57:29 -05:00
import Text from '../text'
class PanelLayout extends React.PureComponent {
render() {
2020-02-20 19:57:29 -05:00
const {
title,
subtitle,
headerButtonTitle,
headerButtonAction,
headerButtonTo,
footerButtonTitle,
footerButtonAction,
footerButtonTo,
footerButtonHref,
2020-02-20 19:57:29 -05:00
noPadding,
children,
} = this.props
return (
<aside className={[_s.d, _s.mb15].join(' ')}>
2020-02-22 18:26:23 -05:00
<Block>
{
(title || subtitle) &&
<div className={[_s.d, _s.px15, _s.py10].join(' ')}>
<div className={[_s.d, _s.flexRow, _s.aiCenter].join(' ')}>
2020-04-23 23:17:27 -04:00
<Heading size='h2'>
2020-02-22 18:26:23 -05:00
{title}
</Heading>
{
(!!headerButtonTitle && (!!headerButtonAction || !!headerButtonTo)) &&
<div className={[_s.d, _s.mlAuto].join(' ')}>
2020-02-22 18:26:23 -05:00
<Button
2020-04-23 02:13:29 -04:00
isText
2020-02-22 18:26:23 -05:00
backgroundColor='none'
color='brand'
to={headerButtonTo}
onClick={headerButtonAction}
>
<Text size='small' color='inherit' weight='bold'>
{headerButtonTitle}
</Text>
</Button>
</div>
}
</div>
2020-02-08 01:12:01 -05:00
{
2020-02-22 18:26:23 -05:00
subtitle &&
<Heading size='h4'>
{subtitle}
</Heading>
2020-02-08 01:12:01 -05:00
}
2020-02-05 17:45:48 -05:00
</div>
2020-02-22 18:26:23 -05:00
}
2020-02-19 18:57:07 -05:00
2020-02-22 18:26:23 -05:00
{
!noPadding &&
<div className={[_s.d, _s.px15, _s.py10].join(' ')}>
2020-02-22 18:26:23 -05:00
{children}
</div>
}
2020-02-19 18:57:07 -05:00
2020-02-22 18:26:23 -05:00
{
noPadding && children
}
2020-02-20 19:57:29 -05:00
2020-02-22 18:26:23 -05:00
{
(!!footerButtonTitle && (!!footerButtonAction || !!footerButtonTo || !!footerButtonHref)) &&
<div className={_s.d}>
2020-02-22 18:26:23 -05:00
<Button
2020-04-23 02:13:29 -04:00
isText
2020-02-22 18:26:23 -05:00
color='none'
backgroundColor='none'
to={footerButtonTo}
href={footerButtonHref}
2020-02-22 18:26:23 -05:00
onClick={footerButtonAction}
2020-04-29 18:32:49 -04:00
className={[_s.px15, _s.py15, _s.bgSubtle_onHover].join(' ')}
2020-02-22 18:26:23 -05:00
>
2020-04-23 02:13:29 -04:00
<Text color='brand' size='medium'>
2020-02-22 18:26:23 -05:00
{footerButtonTitle}
</Text>
</Button>
</div>
}
</Block>
2020-02-05 17:45:48 -05:00
</aside>
)
}
}
PanelLayout.propTypes = {
title: PropTypes.string,
subtitle: PropTypes.string,
children: PropTypes.node,
headerButtonTitle: PropTypes.string,
headerButtonAction: PropTypes.func,
headerButtonTo: PropTypes.string,
footerButtonTitle: PropTypes.string,
footerButtonAction: PropTypes.func,
footerButtonTo: PropTypes.string,
footerButtonHref: PropTypes.string,
noPadding: PropTypes.bool,
}
export default PanelLayout