gab-social/app/javascript/gabsocial/components/column/column.js
2020-02-08 01:12:01 -05:00

37 lines
1.1 KiB
JavaScript

import { isMobile } from '../../utils/is_mobile';
import { ColumnHeader } from '../column_header';
import ColumnBackButton from '../column_back_button';
export default class Column extends PureComponent {
static propTypes = {
heading: PropTypes.string,
icon: PropTypes.string,
children: PropTypes.node,
active: PropTypes.bool,
hideHeadingOnMobile: PropTypes.bool,
backBtn: PropTypes.oneOf([
'normal',
'slim',
]),
};
render () {
const { heading, icon, children, active, hideHeadingOnMobile, backBtn } = this.props;
const showHeading = heading && (!hideHeadingOnMobile || (hideHeadingOnMobile && !isMobile(window.innerWidth)));
const columnHeaderId = showHeading && heading.replace(/ /g, '-');
const header = showHeading && (
<ColumnHeader icon={icon} active={active} type={heading} columnHeaderId={columnHeaderId} />
);
return (
<div role='region' aria-labelledby={columnHeaderId} className='column'>
{ backBtn && <ColumnBackButton slim={backBtn === 'slim'} />}
{children}
</div>
);
}
}