diff --git a/package.json b/package.json index f487e58..6be26d1 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "mapbox-gl-style-spec": "mapbox/mapbox-gl-style-spec#e85407a377510acb647161de6be6357ab4f606dd", "ol-mapbox-style": "0.0.11", "openlayers": "^3.19.1", - "radium": "^0.18.1", "randomcolor": "^0.4.4", "react": "^15.4.0", "react-addons-pure-render-mixin": "^15.4.0", diff --git a/src/components/App.jsx b/src/components/App.jsx index 6f47975..34dde60 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -137,6 +137,7 @@ export default class App extends React.Component { const layerList = diff --git a/src/components/Layout.jsx b/src/components/Layout.jsx index b7c1673..46bb45f 100644 --- a/src/components/Layout.jsx +++ b/src/components/Layout.jsx @@ -37,7 +37,7 @@ export default class Layout extends React.Component { top: 50, left: 0, zIndex: 100, - width: 180, + width: 200, overflow: "hidden", backgroundColor: colors.gray }}> @@ -48,7 +48,7 @@ export default class Layout extends React.Component { bottom: 0, height: "100%", top: 50, - left: 180, + left: 200, zIndex: 100, width: 300, backgroundColor: colors.gray} diff --git a/src/components/layers/LayerEditor.jsx b/src/components/layers/LayerEditor.jsx index 96fab8d..31e1df9 100644 --- a/src/components/layers/LayerEditor.jsx +++ b/src/components/layers/LayerEditor.jsx @@ -31,7 +31,6 @@ export default class LayerEditor extends React.Component { sources: React.PropTypes.object, vectorLayers: React.PropTypes.object, onLayerChanged: React.PropTypes.func, - onLayerDestroyed: React.PropTypes.func, } static defaultProps = { @@ -98,10 +97,6 @@ export default class LayerEditor extends React.Component { /> }) - let visibleIcon = - if('layout' in this.props.layer && this.props.layer.layout.visibility === 'none') { - visibleIcon = - } return
@@ -109,13 +104,6 @@ export default class LayerEditor extends React.Component { {this.props.layer.id} - - - {visibleIcon} - - this.props.onLayerDestroyed(this.props.layer)}> - - {propertyGroups} {this.props.layer.type !== 'background' &&
diff --git a/src/components/layers/LayerList.jsx b/src/components/layers/LayerList.jsx index 55a3651..69cd209 100644 --- a/src/components/layers/LayerList.jsx +++ b/src/components/layers/LayerList.jsx @@ -15,6 +15,7 @@ import {SortableContainer, SortableHandle, arrayMove} from 'react-sortable-hoc'; const layerListPropTypes = { layers: React.PropTypes.array.isRequired, + selectedLayerIndex: React.PropTypes.number.isRequired, onLayersChanged: React.PropTypes.func.isRequired, onLayerSelected: React.PropTypes.func, } @@ -45,6 +46,7 @@ class LayerListContainer extends React.Component { key={layerId} layerId={layerId} layerType={layer.type} + isSelected={index === this.props.selectedLayerIndex} onLayerSelected={this.props.onLayerSelected} /> }) diff --git a/src/components/layers/LayerListItem.jsx b/src/components/layers/LayerListItem.jsx index f23b442..0b0a489 100644 --- a/src/components/layers/LayerListItem.jsx +++ b/src/components/layers/LayerListItem.jsx @@ -1,5 +1,4 @@ import React from 'react' -import Radium from 'radium' import Color from 'color' import Heading from 'rebass/dist/Heading' @@ -7,6 +6,11 @@ import Toolbar from 'rebass/dist/Toolbar' import NavItem from 'rebass/dist/NavItem' import Space from 'rebass/dist/Space' +import CopyIcon from 'react-icons/lib/md/content-copy' +import VisibilityIcon from 'react-icons/lib/md/visibility' +import VisibilityOffIcon from 'react-icons/lib/md/visibility-off' +import DeleteIcon from 'react-icons/lib/md/delete' + import LayerIcon from '../icons/LayerIcon' import LayerEditor from './LayerEditor' import {SortableElement, SortableHandle} from 'react-sortable-hoc' @@ -27,43 +31,149 @@ class LayerTypeDragHandle extends React.Component { } } +class IconAction extends React.Component { + static propTypes = { + action: React.PropTypes.string.isRequired, + active: React.PropTypes.bool, + } + + constructor(props) { + super(props) + this.state = { hover: false } + } + + renderIcon() { + const iconStyle = { + fill: this.props.active ? (this.state.hover ? colors.lowgray : colors.midgray) : colors.gray, + } + + switch(this.props.action) { + case 'copy': return + case 'show': return + case 'hide': return + case 'delete': return + default: return null + } + } + + render() { + return
this.setState({hover: true})} + onMouseOut={e => this.setState({hover: false})} + > + {this.renderIcon()} +
+ } +} + @SortableElement -@Radium class LayerListItem extends React.Component { static propTypes = { layerId: React.PropTypes.string.isRequired, layerType: React.PropTypes.string.isRequired, + isSelected: React.PropTypes.bool, + visibility: React.PropTypes.bool, + onLayerSelected: React.PropTypes.func.isRequired, + onLayerDestroyed: React.PropTypes.func, + onLayerVisibilityToggled: React.PropTypes.func, + } + + static defaultProps = { + isSelected: false, + visibility: true, + onLayerDestroyed: () => {}, + onLayerVisibilityToggled: () => {}, + } + + static childContextTypes = { + reactIconBase: React.PropTypes.object + } + + constructor(props) { + super(props) + this.state = { + hover: false + } + } + + getChildContext() { + return { + reactIconBase: { size: 12 } + } } render() { + const itemStyle = { + fontWeight: 400, + color: colors.lowgray, + fontSize: fontSizes[5], + borderLeft: 0, + borderTop: 0, + borderBottom: 1, + borderRight: 0, + borderStyle: "solid", + userSelect: 'none', + listStyle: 'none', + zIndex: 2000, + cursor: 'pointer', + position: 'relative', + padding: margins[1], + borderColor: Color(colors.gray).lighten(0.1).string(), + backgroundColor: colors.gray, + } + + if(this.state.hover) { + console.log('hooover') + itemStyle.backgroundColor = Color(colors.gray).lighten(0.10) + } + + if(this.props.isSelected) { + itemStyle.backgroundColor = Color(colors.gray).lighten(0.15) + } + + const iconProps = { + active: this.state.hover || this.props.isSelected + } + return
  • this.props.onLayerSelected(this.props.layerId)} - style={{ - fontWeight: 400, - color: colors.lowgray, - fontSize: fontSizes[5], - borderBottom: 1, - borderLeft: 2, - borderRight: 0, - borderStyle: "solid", - userSelect: 'none', - listStyle: 'none', - zIndex: 2000, - cursor: 'pointer', - position: 'relative', - padding: margins[1], - borderColor: Color(colors.gray).lighten(0.1).string(), - backgroundColor: colors.gray, - ":hover": { - backgroundColor: Color(colors.gray).lighten(0.15).string(), - } - }}> - - {this.props.layerId} + onClick={e => this.props.onLayerSelected(this.props.layerId)} + onMouseOver={e => this.setState({hover: true})} + onMouseOut={e => this.setState({hover: false})} + style={itemStyle}> +
    + + {this.props.layerId} + + this.props.onLayerDestroyed(this.props.layerId)} + /> + this.props.onLayerVisibilityToggled(this.props.layerId)} + /> + this.props.onLayerVisibilityToggled(this.props.layerId)} + /> +
  • } } -export default Radium(LayerListItem); +export default LayerListItem;