2019-08-07 06:02:36 +01:00
|
|
|
import { isMobile } from '../../utils/is_mobile';
|
2020-01-29 21:53:33 +00:00
|
|
|
import { ColumnHeader } from '../column_header';
|
2019-08-07 06:02:36 +01:00
|
|
|
import ColumnBackButton from '../column_back_button';
|
|
|
|
|
2019-07-29 20:20:00 +01:00
|
|
|
export default class Column extends PureComponent {
|
2019-07-02 08:10:25 +01:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
heading: PropTypes.string,
|
|
|
|
icon: PropTypes.string,
|
|
|
|
children: PropTypes.node,
|
|
|
|
active: PropTypes.bool,
|
|
|
|
hideHeadingOnMobile: PropTypes.bool,
|
2019-08-07 06:02:36 +01:00
|
|
|
backBtn: PropTypes.oneOf([
|
|
|
|
'normal',
|
|
|
|
'slim',
|
|
|
|
]),
|
2019-07-02 08:10:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
2019-08-07 06:02:36 +01:00
|
|
|
const { heading, icon, children, active, hideHeadingOnMobile, backBtn } = this.props;
|
2019-07-02 08:10:25 +01:00
|
|
|
|
|
|
|
const showHeading = heading && (!hideHeadingOnMobile || (hideHeadingOnMobile && !isMobile(window.innerWidth)));
|
|
|
|
const columnHeaderId = showHeading && heading.replace(/ /g, '-');
|
2020-01-29 21:53:33 +00:00
|
|
|
const header = showHeading && (
|
|
|
|
<ColumnHeader icon={icon} active={active} type={heading} columnHeaderId={columnHeaderId} />
|
|
|
|
);
|
2019-07-19 04:27:54 +01:00
|
|
|
|
2019-07-02 08:10:25 +01:00
|
|
|
return (
|
2020-02-14 00:40:04 +00:00
|
|
|
<div role='region' aria-labelledby={columnHeaderId} className={[styles.default].join(' ')}>
|
2019-08-07 06:02:36 +01:00
|
|
|
{ backBtn && <ColumnBackButton slim={backBtn === 'slim'} />}
|
2019-07-02 08:10:25 +01:00
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|