From 85a28999fb077d576218c27b349570041fbdc5c7 Mon Sep 17 00:00:00 2001 From: orangemug Date: Mon, 18 Jun 2018 20:28:24 +0100 Subject: [PATCH] Initial color accessibility UI --- src/components/App.jsx | 22 +++++----- src/components/Toolbar.jsx | 81 +++++++++++++++++++++++++++++++++---- src/styles/_components.scss | 23 +++++++++++ 3 files changed, 109 insertions(+), 17 deletions(-) diff --git a/src/components/App.jsx b/src/components/App.jsx index f35ea93..ed06070 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -104,7 +104,7 @@ export default class App extends React.Component { { keyCode: keyCodes["i"], handler: () => { - this.changeInspectMode(); + this.setMapState("inspect"); } }, { @@ -164,7 +164,7 @@ export default class App extends React.Component { selectedLayerIndex: 0, sources: {}, vectorLayers: {}, - inspectModeEnabled: false, + mapState: "normal", spec: styleSpec.latest, isOpen: { settings: false, @@ -176,7 +176,6 @@ export default class App extends React.Component { mapOptions: { showTileBoundaries: queryUtil.asBool(queryObj, "show-tile-boundaries") }, - mapFilter: queryObj["color-blindness-emulation"], } this.layerWatcher = new LayerWatcher({ @@ -341,9 +340,9 @@ export default class App extends React.Component { this.onLayersChange(changedLayers) } - changeInspectMode() { + setMapState(newState) { this.setState({ - inspectModeEnabled: !this.state.inspectModeEnabled + mapState: newState }) } @@ -423,13 +422,17 @@ export default class App extends React.Component { mapElement = } else { mapElement = } + let filterName = ""; + if(this.state.mapState.match(/^filter-/)) { + filterName = this.state.mapState.replace(/^filter-/, ""); + } const elementStyle = { - "filter": `url('#${this.state.mapFilter}')` + "filter": `url('#${filterName}')` }; return
@@ -457,12 +460,13 @@ export default class App extends React.Component { const metadata = this.state.mapStyle.metadata || {} const toolbar = diff --git a/src/components/Toolbar.jsx b/src/components/Toolbar.jsx index ab26601..dbd8449 100644 --- a/src/components/Toolbar.jsx +++ b/src/components/Toolbar.jsx @@ -2,6 +2,7 @@ import React from 'react' import PropTypes from 'prop-types' import FileReaderInput from 'react-file-reader-input' import classnames from 'classnames' +import { Wrapper, Button, Menu, MenuItem } from 'react-aria-menubutton' import MdFileDownload from 'react-icons/lib/md/file-download' import MdFileUpload from 'react-icons/lib/md/file-upload' @@ -17,6 +18,11 @@ import MdFontDownload from 'react-icons/lib/md/font-download' import HelpIcon from 'react-icons/lib/md/help-outline' import InspectionIcon from 'react-icons/lib/md/find-in-page' +import ColorIcon from 'react-icons/lib/md/color-lens' +import MapIcon from 'react-icons/lib/md/map' +import ViewIcon from 'react-icons/lib/md/remove-red-eye' + + import logoImage from 'maputnik-design/logos/logo-color.svg' import pkgJson from '../../package.json' @@ -79,7 +85,6 @@ export default class Toolbar extends React.Component { onStyleOpen: PropTypes.func.isRequired, // A dict of source id's and the available source layers sources: PropTypes.object.isRequired, - onInspectModeToggle: PropTypes.func.isRequired, children: PropTypes.node, onToggleModal: PropTypes.func, } @@ -97,7 +102,44 @@ export default class Toolbar extends React.Component { } } + handleSelection(val) { + this.props.onSetMapState(val); + } + render() { + const views = [ + { + id: "map", + title: "Map", + icon: , + }, + { + id: "inspect", + title: "Inspect", + icon: , + }, + { + id: "filter-deuteranopia", + title: "Filter deuteranopia", + icon: , + }, + { + id: "filter-protanopia", + title: "Filter protanopia", + icon: , + }, + { + id: "filter-tritanopia", + title: "Filter tritanopia", + icon: , + }, + { + id: "filter-achromatopsia", + title: "Filter achromatopsia", + icon: , + }, + ]; + return
Style Settings - - - - { this.props.inspectModeEnabled && Map Mode } - { !this.props.inspectModeEnabled && Inspect Mode } - - + + this.handleSelection(val)} + > + + +
    + {views.map((item) => { + return ( +
  • + + + +
  • + ); + })} +
+
+
+ + Help diff --git a/src/styles/_components.scss b/src/styles/_components.scss index 170d855..26a6922 100644 --- a/src/styles/_components.scss +++ b/src/styles/_components.scss @@ -141,3 +141,26 @@ text-align: right; } } + +.map-state-menu { + display: inline-block; + + &__menu { + position: absolute; + z-index: 999999; + background: $color-black; + display: flex; + flex-direction: column; + align-content: stretch; + + li { + display: flex; + flex-direction: column; + + button { + width: 100%; + text-align: left; + } + } + } +}