2021-01-01 12:06:12 -08:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2021-10-06 13:57:24 -07:00
|
|
|
import Column from 'soapbox/components/column';
|
2021-01-01 12:06:12 -08:00
|
|
|
import DropdownMenu from 'soapbox/containers/dropdown_menu_container';
|
2022-01-10 14:01:24 -08:00
|
|
|
import ColumnHeader from './column_header';
|
2021-01-01 12:06:12 -08:00
|
|
|
|
|
|
|
// Yes, there are 3 types of columns at this point, but this one is better, I swear
|
2021-10-06 13:57:24 -07:00
|
|
|
export default class BetterColumn extends React.PureComponent {
|
2021-01-01 12:06:12 -08:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
heading: PropTypes.string,
|
|
|
|
icon: PropTypes.string,
|
|
|
|
children: PropTypes.node,
|
|
|
|
active: PropTypes.bool,
|
|
|
|
menu: PropTypes.array,
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2021-10-06 13:57:24 -07:00
|
|
|
const { heading, icon, children, active, menu, ...rest } = this.props;
|
2021-01-01 12:11:52 -08:00
|
|
|
const columnHeaderId = heading && heading.replace(/ /g, '-');
|
2021-01-01 12:06:12 -08:00
|
|
|
|
|
|
|
return (
|
2021-10-06 13:57:24 -07:00
|
|
|
<Column aria-labelledby={columnHeaderId} className='column--better' {...rest}>
|
2021-01-01 12:06:12 -08:00
|
|
|
<div className='column__top'>
|
2021-01-01 12:25:48 -08:00
|
|
|
{heading && <ColumnHeader icon={icon} active={active} type={heading} columnHeaderId={columnHeaderId} />}
|
2021-01-01 12:06:12 -08:00
|
|
|
{menu && (
|
|
|
|
<div className='column__menu'>
|
|
|
|
<DropdownMenu items={menu} icon='ellipsis-v' size={18} direction='right' />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
{children}
|
2021-10-06 13:57:24 -07:00
|
|
|
</Column>
|
2021-01-01 12:06:12 -08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|