gab-social/app/javascript/gabsocial/components/panel/panel_layout.js

102 lines
3.0 KiB
JavaScript
Raw Normal View History

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'
export default class PanelLayout extends PureComponent {
static propTypes = {
title: PropTypes.string,
2020-02-05 22:45:48 +00:00
subtitle: PropTypes.string,
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
}
render() {
2020-02-21 00:57:29 +00:00
const {
title,
subtitle,
headerButtonTitle,
headerButtonAction,
headerButtonTo,
footerButtonTitle,
footerButtonAction,
footerButtonTo,
noPadding,
children,
} = this.props
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-03-11 23:56:18 +00:00
<div className={[_s.default, _s.px15, _s.py10, _s.borderColorSecondary, _s.borderBottom1PX].join(' ')}>
2020-02-22 23:26:23 +00:00
<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 &&
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
{
(!!footerButtonTitle && (!!footerButtonAction || !!footerButtonTo)) &&
<div className={[_s.default, _s.borderColorSecondary, _s.borderTop1PX].join(' ')}>
<Button
text
color='none'
backgroundColor='none'
to={footerButtonTo}
onClick={footerButtonAction}
2020-03-11 23:56:18 +00:00
className={[_s.px15, _s.py15, _s.backgroundSubtle_onHover].join(' ')}
2020-02-22 23:26:23 +00:00
>
<Text color='brand' align='left' size='medium'>
{footerButtonTitle}
</Text>
</Button>
</div>
}
</Block>
2020-02-05 22:45:48 +00:00
</aside>
)
}
}