Some checks are pending
farmcontrol/farmcontrol-ui/pipeline/head Build queued...
21 lines
664 B
JavaScript
21 lines
664 B
JavaScript
import PropTypes from 'prop-types'
|
|
import { Button } from 'antd'
|
|
import GridIcon from '../../Icons/GridIcon'
|
|
import ListIcon from '../../Icons/ListIcon'
|
|
|
|
const ObjectTableViewButton = ({ viewMode, setViewMode, ...buttonProps }) => (
|
|
<Button
|
|
icon={viewMode === 'cards' ? <ListIcon /> : <GridIcon />}
|
|
onClick={() => setViewMode(viewMode === 'cards' ? 'list' : 'cards')}
|
|
title={viewMode === 'cards' ? 'Switch to list view' : 'Switch to card view'}
|
|
{...buttonProps}
|
|
/>
|
|
)
|
|
|
|
ObjectTableViewButton.propTypes = {
|
|
viewMode: PropTypes.oneOf(['list', 'cards']).isRequired,
|
|
setViewMode: PropTypes.func.isRequired
|
|
}
|
|
|
|
export default ObjectTableViewButton
|