bigbuffet-rw/app/soapbox/features/ui/components/column.js
2021-09-12 19:36:18 -05:00

37 lines
1.2 KiB
JavaScript

import React from 'react';
import ColumnHeader from './column_header';
import PropTypes from 'prop-types';
import ColumnBackButton from '../../../components/column_back_button';
import ColumnBackButtonSlim from '../../../components/column_back_button_slim';
export default class Column extends React.PureComponent {
static propTypes = {
heading: PropTypes.string,
icon: PropTypes.string,
children: PropTypes.node,
active: PropTypes.bool,
backBtnSlim: PropTypes.bool,
showBackBtn: PropTypes.bool,
back: PropTypes.string,
};
static defaultProps = {
showBackBtn: true,
}
render() {
const { heading, icon, children, active, backBtnSlim, showBackBtn, back } = this.props;
const columnHeaderId = heading && heading.replace(/ /g, '-');
const backBtn = backBtnSlim ? (<ColumnBackButtonSlim to={back} />) : (<ColumnBackButton to={back} />);
return (
<div role='region' aria-labelledby={columnHeaderId} className='column'>
{heading && <ColumnHeader icon={icon} active={active} type={heading} columnHeaderId={columnHeaderId} />}
{showBackBtn ? backBtn : null}
{children}
</div>
);
}
}