import React from 'react' import { t } from 'ttag' import { connect } from 'react-redux' import ColorPicker from './ColorPicker' import { toggleCustomLayer, removeCustomLayer, setCustomColor } from '../actions/customLayers' import { CustomLayer, customLayerColors } from '../reducers/customLayers' interface CustomLayerListItemProps { layer: CustomLayer onToggleCustomLayer: (id: string) => any onRemoveCustomLayer: (id: string) => any onSetCustomColor: (id: string, color: string) => any showColorPicker: boolean toggleColorPicker: (id: string) => void } const CustomLayerListItem = ({ layer, onToggleCustomLayer, onRemoveCustomLayer, onSetCustomColor, showColorPicker, toggleColorPicker, }: CustomLayerListItemProps) => { return (
  • toggleColorPicker(layer.id)} onKeyPress={event => { if (event.key === 'Enter') { toggleColorPicker(layer.id) } }} className="is-clickable" style={{ float: 'left', height: '20px', width: '20px', borderRadius: '100%', background: layer.color, marginRight: '12px', }} />
    { onRemoveCustomLayer(layer.id) }} onKeyPress={event => { if (event.key === 'Enter') onRemoveCustomLayer(layer.id) }} /> {showColorPicker ? ( { onSetCustomColor(layer.id, color) }} /> ) : null}
  • ) } export default connect(null, (dispatch: (action: any) => any) => { return { onToggleCustomLayer: (id: string) => { dispatch(toggleCustomLayer(id)) }, onRemoveCustomLayer: (id: string) => { dispatch(removeCustomLayer(id)) }, onSetCustomColor: (id: string, color: string) => { dispatch(setCustomColor(id, color)) }, } })(CustomLayerListItem)