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

116 lines
3.3 KiB
JavaScript
Raw Normal View History

import React from 'react'
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'
class PanelLayout extends React.PureComponent {
render() {
2020-02-21 00:57:29 +00:00
const {
title,
subtitle,
headerButtonTitle,
headerButtonAction,
headerButtonTo,
headerButtonHref,
2020-02-21 00:57:29 +00:00
footerButtonTitle,
footerButtonAction,
footerButtonTo,
footerButtonHref,
2020-02-21 00:57:29 +00:00
noPadding,
children,
} = this.props
return (
<aside className={[_s.d, _s.mb15].join(' ')}>
2020-02-22 23:26:23 +00:00
<Block>
{
(title || subtitle) &&
<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>
{
(!!headerButtonTitle && (!!headerButtonAction || !!headerButtonTo || !!headerButtonHref)) &&
<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
radiusSmall
2020-02-22 23:26:23 +00:00
backgroundColor='none'
color='brand'
to={headerButtonTo}
href={headerButtonHref}
2020-02-22 23:26:23 +00:00
onClick={headerButtonAction}
className={[_s.px15, _s.py5, _s.bgSubtle_onHover].join(' ')}
2020-02-22 23:26:23 +00:00
>
<Text color='inherit' weight='bold'>
2020-02-22 23:26:23 +00:00
{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.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
{
(!!footerButtonTitle && (!!footerButtonAction || !!footerButtonTo || !!footerButtonHref)) &&
<div className={[_s.d, _s.py10, _s.px10].join(' ')}>
2020-02-22 23:26:23 +00:00
<Button
radiusSmall
color='primary'
backgroundColor='tertiary'
2020-02-22 23:26:23 +00:00
to={footerButtonTo}
href={footerButtonHref}
2020-02-22 23:26:23 +00:00
onClick={footerButtonAction}
className={[_s.px15, _s.py10, _s.bgSubtle_onHover].join(' ')}
2020-02-22 23:26:23 +00:00
>
<Text color='inherit' size='medium' weight='medium' align='center'>
2020-02-22 23:26:23 +00:00
{footerButtonTitle}
</Text>
</Button>
</div>
}
</Block>
2020-02-05 22:45:48 +00:00
</aside>
)
}
}
PanelLayout.propTypes = {
title: PropTypes.string,
subtitle: PropTypes.string,
children: PropTypes.node,
headerButtonTitle: PropTypes.string,
headerButtonAction: PropTypes.func,
headerButtonTo: PropTypes.string,
headerButtonHref: PropTypes.string,
footerButtonTitle: PropTypes.string,
footerButtonAction: PropTypes.func,
footerButtonTo: PropTypes.string,
footerButtonHref: PropTypes.string,
noPadding: PropTypes.bool,
}
export default PanelLayout