maputnik/src/components/layers/LayerListItem.jsx

70 lines
1.8 KiB
React
Raw Normal View History

2016-12-17 16:43:25 +01:00
import React from 'react'
import Radium from 'radium'
2016-12-19 11:46:48 +01:00
import Color from 'color'
2016-12-17 16:43:25 +01:00
import Heading from 'rebass/dist/Heading'
import Toolbar from 'rebass/dist/Toolbar'
import NavItem from 'rebass/dist/NavItem'
import Space from 'rebass/dist/Space'
2016-12-20 11:44:22 +01:00
import LayerIcon from '../icons/LayerIcon'
import LayerEditor from './LayerEditor'
import {SortableElement, SortableHandle} from 'react-sortable-hoc'
import colors from '../../config/colors.js'
import { fontSizes, margins } from '../../config/scales.js'
2016-12-17 16:43:25 +01:00
2016-12-18 17:28:59 +01:00
@SortableHandle
class LayerTypeDragHandle extends React.Component {
static propTypes = LayerIcon.propTypes
render() {
return <LayerIcon
{...this.props}
style={{width: 15, height: 15, paddingRight: 3}}
/>
}
}
2016-12-17 19:58:30 +01:00
@SortableElement
2016-12-17 16:43:25 +01:00
@Radium
class LayerListItem extends React.Component {
static propTypes = {
2016-12-17 19:58:30 +01:00
layerId: React.PropTypes.string.isRequired,
2016-12-18 17:28:59 +01:00
layerType: React.PropTypes.string.isRequired,
2016-12-17 16:43:25 +01:00
onLayerSelected: React.PropTypes.func.isRequired,
}
render() {
2016-12-17 19:58:30 +01:00
return <li
key={this.props.layerId}
onClick={() => this.props.onLayerSelected(this.props.layerId)}
style={{
fontWeight: 400,
2016-12-20 11:44:22 +01:00
color: colors.lowgray,
fontSize: fontSizes[5],
2016-12-17 16:43:25 +01:00
borderBottom: 1,
borderLeft: 2,
borderRight: 0,
borderStyle: "solid",
2016-12-17 19:58:30 +01:00
userSelect: 'none',
listStyle: 'none',
zIndex: 2000,
cursor: 'pointer',
position: 'relative',
2016-12-20 11:44:22 +01:00
padding: margins[1],
borderColor: Color(colors.gray).lighten(0.1).string(),
backgroundColor: colors.gray,
2016-12-17 19:58:30 +01:00
":hover": {
2016-12-20 11:44:22 +01:00
backgroundColor: Color(colors.gray).lighten(0.15).string(),
2016-12-17 19:58:30 +01:00
}
2016-12-17 16:43:25 +01:00
}}>
2016-12-18 17:28:59 +01:00
<LayerTypeDragHandle type={this.props.layerType} />
<span>{this.props.layerId}</span>
2016-12-17 19:58:30 +01:00
</li>
2016-12-17 16:43:25 +01:00
}
}
export default Radium(LayerListItem);