Added column back button to column component by default

This commit is contained in:
mgabdev 2019-07-18 23:27:54 -04:00
parent 0510fe0915
commit db480928ec

View File

@ -2,6 +2,8 @@ import React from 'react';
import ColumnHeader from './column_header'; import ColumnHeader from './column_header';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { isMobile } from '../../../is_mobile'; import { isMobile } from '../../../is_mobile';
import ColumnBackButton from '../../../components/column_back_button';
import ColumnBackButtonSlim from '../../../components/column_back_button_slim';
export default class Column extends React.PureComponent { export default class Column extends React.PureComponent {
@ -11,10 +13,11 @@ export default class Column extends React.PureComponent {
children: PropTypes.node, children: PropTypes.node,
active: PropTypes.bool, active: PropTypes.bool,
hideHeadingOnMobile: PropTypes.bool, hideHeadingOnMobile: PropTypes.bool,
backBtnSlim: PropTypes.string,
}; };
render () { render () {
const { heading, icon, children, active, hideHeadingOnMobile } = this.props; const { heading, icon, children, active, hideHeadingOnMobile, backBtnSlim } = this.props;
const showHeading = heading && (!hideHeadingOnMobile || (hideHeadingOnMobile && !isMobile(window.innerWidth))); const showHeading = heading && (!hideHeadingOnMobile || (hideHeadingOnMobile && !isMobile(window.innerWidth)));
@ -22,9 +25,13 @@ export default class Column extends React.PureComponent {
const header = showHeading && ( const header = showHeading && (
<ColumnHeader icon={icon} active={active} type={heading} columnHeaderId={columnHeaderId} /> <ColumnHeader icon={icon} active={active} type={heading} columnHeaderId={columnHeaderId} />
); );
const backBtn = backBtnSlim ? (<ColumnBackButtonSlim/>) : (<ColumnBackButton/>);
return ( return (
<div role='region' aria-labelledby={columnHeaderId} className='column'> <div role='region' aria-labelledby={columnHeaderId} className='column'>
{header} {header}
{backBtn}
{children} {children}
</div> </div>
); );