gab-social/app/javascript/gabsocial/components/column/column.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

import { isMobile } from '../../utils/is_mobile';
import { ColumnHeader } from '../column_header';
import ColumnBackButton from '../column_back_button';
import './column.scss';
2019-07-02 08:10:25 +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,
backBtn: PropTypes.oneOf([
'normal',
'slim',
]),
2019-07-02 08:10:25 +01:00
};
render () {
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, '-');
const header = showHeading && (
<ColumnHeader icon={icon} active={active} type={heading} columnHeaderId={columnHeaderId} />
);
2019-07-02 08:10:25 +01:00
return (
<div role='region' aria-labelledby={columnHeaderId} className='column'>
{ backBtn && <ColumnBackButton slim={backBtn === 'slim'} />}
2019-07-02 08:10:25 +01:00
{children}
</div>
);
}
}