UNPKG

decap-cms-core

Version:

Decap CMS core application, see decap-cms package for the main distribution.

52 lines (44 loc) 1.31 kB
import styled from '@emotion/styled'; import { Icon, buttons, colors } from 'decap-cms-ui-default'; import { VIEW_STYLE_LIST, VIEW_STYLE_GRID } from '../../constants/collectionViews'; const ViewControlsSection = styled.div` display: flex; align-items: center; justify-content: flex-end; max-width: 500px; `; const ViewControlsButton = styled.button` ${buttons.button}; color: ${props => (props.isActive ? colors.active : '#b3b9c4')}; background-color: transparent; display: block; padding: 0; margin: 0 4px; &:last-child { margin-right: 0; } ${Icon} { display: block; } `; function ViewStyleControl({ viewStyle, onChangeViewStyle, t }) { return ( <ViewControlsSection> <ViewControlsButton aria-label={t('collection.collectionTop.viewAsList')} isActive={viewStyle === VIEW_STYLE_LIST} onClick={() => onChangeViewStyle(VIEW_STYLE_LIST)} > <Icon type="list" /> </ViewControlsButton> <ViewControlsButton aria-label={t('collection.collectionTop.viewAsGrid')} isActive={viewStyle === VIEW_STYLE_GRID} onClick={() => onChangeViewStyle(VIEW_STYLE_GRID)} > <Icon type="grid" /> </ViewControlsButton> </ViewControlsSection> ); } export default ViewStyleControl;