mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 04:15:22 +01:00
Merge pull request #392 from orangemug/feature/color-accessibility-ui
Color accessibility UI
This commit is contained in:
commit
44fad76d45
7 changed files with 143 additions and 24 deletions
|
@ -106,7 +106,7 @@ export default class App extends React.Component {
|
||||||
{
|
{
|
||||||
keyCode: keyCodes["i"],
|
keyCode: keyCodes["i"],
|
||||||
handler: () => {
|
handler: () => {
|
||||||
this.changeInspectMode();
|
this.setMapState("inspect");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -166,7 +166,7 @@ export default class App extends React.Component {
|
||||||
selectedLayerIndex: 0,
|
selectedLayerIndex: 0,
|
||||||
sources: {},
|
sources: {},
|
||||||
vectorLayers: {},
|
vectorLayers: {},
|
||||||
inspectModeEnabled: false,
|
mapState: "map",
|
||||||
spec: styleSpec.latest,
|
spec: styleSpec.latest,
|
||||||
isOpen: {
|
isOpen: {
|
||||||
settings: false,
|
settings: false,
|
||||||
|
@ -180,7 +180,6 @@ export default class App extends React.Component {
|
||||||
showTileBoundaries: queryUtil.asBool(queryObj, "show-tile-boundaries"),
|
showTileBoundaries: queryUtil.asBool(queryObj, "show-tile-boundaries"),
|
||||||
showCollisionBoxes: queryUtil.asBool(queryObj, "show-collision-boxes")
|
showCollisionBoxes: queryUtil.asBool(queryObj, "show-collision-boxes")
|
||||||
},
|
},
|
||||||
mapFilter: queryObj["color-blindness-emulation"],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.layerWatcher = new LayerWatcher({
|
this.layerWatcher = new LayerWatcher({
|
||||||
|
@ -362,9 +361,9 @@ export default class App extends React.Component {
|
||||||
this.onLayersChange(changedLayers)
|
this.onLayersChange(changedLayers)
|
||||||
}
|
}
|
||||||
|
|
||||||
changeInspectMode = () => {
|
setMapState = (newState) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
inspectModeEnabled: !this.state.inspectModeEnabled
|
mapState: newState
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,17 +445,21 @@ export default class App extends React.Component {
|
||||||
mapElement = <div>TODO</div>
|
mapElement = <div>TODO</div>
|
||||||
} else {
|
} else {
|
||||||
mapElement = <MapboxGlMap {...mapProps}
|
mapElement = <MapboxGlMap {...mapProps}
|
||||||
inspectModeEnabled={this.state.inspectModeEnabled}
|
inspectModeEnabled={this.state.mapState === "inspect"}
|
||||||
highlightedLayer={this.state.mapStyle.layers[this.state.selectedLayerIndex]}
|
highlightedLayer={this.state.mapStyle.layers[this.state.selectedLayerIndex]}
|
||||||
onLayerSelect={this.onLayerSelect} />
|
onLayerSelect={this.onLayerSelect} />
|
||||||
}
|
}
|
||||||
|
|
||||||
const elementStyle = {};
|
let filterName;
|
||||||
if(this.state.mapFilter) {
|
if(this.state.mapState.match(/^filter-/)) {
|
||||||
elementStyle.filter = `url('#${this.state.mapFilter}')`;
|
filterName = this.state.mapState.replace(/^filter-/, "");
|
||||||
}
|
}
|
||||||
|
const elementStyle = {};
|
||||||
|
if (filterName) {
|
||||||
|
elementStyle.filter = `url('#${filterName}')`;
|
||||||
|
};
|
||||||
|
|
||||||
return <div style={elementStyle}>
|
return <div style={elementStyle} className="maputnik-map__container">
|
||||||
{mapElement}
|
{mapElement}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
@ -485,12 +488,13 @@ export default class App extends React.Component {
|
||||||
const metadata = this.state.mapStyle.metadata || {}
|
const metadata = this.state.mapStyle.metadata || {}
|
||||||
|
|
||||||
const toolbar = <Toolbar
|
const toolbar = <Toolbar
|
||||||
|
mapState={this.state.mapState}
|
||||||
mapStyle={this.state.mapStyle}
|
mapStyle={this.state.mapStyle}
|
||||||
inspectModeEnabled={this.state.inspectModeEnabled}
|
inspectModeEnabled={this.state.mapState === "inspect"}
|
||||||
sources={this.state.sources}
|
sources={this.state.sources}
|
||||||
onStyleChanged={this.onStyleChanged}
|
onStyleChanged={this.onStyleChanged}
|
||||||
onStyleOpen={this.onStyleChanged}
|
onStyleOpen={this.onStyleChanged}
|
||||||
onInspectModeToggle={this.changeInspectMode}
|
onSetMapState={this.setMapState}
|
||||||
onToggleModal={this.toggleModal.bind(this)}
|
onToggleModal={this.toggleModal.bind(this)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,11 @@ import HelpIcon from 'react-icons/lib/md/help-outline'
|
||||||
import InspectionIcon from 'react-icons/lib/md/find-in-page'
|
import InspectionIcon from 'react-icons/lib/md/find-in-page'
|
||||||
import SurveyIcon from 'react-icons/lib/md/assignment-turned-in'
|
import SurveyIcon from 'react-icons/lib/md/assignment-turned-in'
|
||||||
|
|
||||||
|
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 logoImage from 'maputnik-design/logos/logo-color.svg'
|
||||||
import pkgJson from '../../package.json'
|
import pkgJson from '../../package.json'
|
||||||
|
|
||||||
|
@ -66,6 +71,22 @@ class ToolbarLinkHighlighted extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ToolbarSelect extends React.Component {
|
||||||
|
static propTypes = {
|
||||||
|
children: PropTypes.node,
|
||||||
|
wdKey: PropTypes.string
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return <div
|
||||||
|
className='maputnik-toolbar-select'
|
||||||
|
data-wd-key={this.props.wdKey}
|
||||||
|
>
|
||||||
|
{this.props.children}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ToolbarAction extends React.Component {
|
class ToolbarAction extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
children: PropTypes.node,
|
children: PropTypes.node,
|
||||||
|
@ -93,9 +114,10 @@ export default class Toolbar extends React.Component {
|
||||||
onStyleOpen: PropTypes.func.isRequired,
|
onStyleOpen: PropTypes.func.isRequired,
|
||||||
// A dict of source id's and the available source layers
|
// A dict of source id's and the available source layers
|
||||||
sources: PropTypes.object.isRequired,
|
sources: PropTypes.object.isRequired,
|
||||||
onInspectModeToggle: PropTypes.func.isRequired,
|
|
||||||
children: PropTypes.node,
|
children: PropTypes.node,
|
||||||
onToggleModal: PropTypes.func,
|
onToggleModal: PropTypes.func,
|
||||||
|
onSetMapState: PropTypes.func,
|
||||||
|
mapState: PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
|
@ -108,7 +130,48 @@ export default class Toolbar extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleSelection(val) {
|
||||||
|
this.props.onSetMapState(val);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const views = [
|
||||||
|
{
|
||||||
|
id: "map",
|
||||||
|
title: "Map",
|
||||||
|
icon: <MapIcon/>,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "inspect",
|
||||||
|
title: "Inspect",
|
||||||
|
icon: <InspectionIcon/>,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "filter-deuteranopia",
|
||||||
|
title: "Map (deuteranopia)",
|
||||||
|
icon: <ColorIcon/>,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "filter-protanopia",
|
||||||
|
title: "Map (protanopia)",
|
||||||
|
icon: <ColorIcon/>,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "filter-tritanopia",
|
||||||
|
title: "Map (tritanopia)",
|
||||||
|
icon: <ColorIcon/>,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "filter-achromatopsia",
|
||||||
|
title: "Map (achromatopsia)",
|
||||||
|
icon: <ColorIcon/>,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const currentView = views.find((view) => {
|
||||||
|
return view.id === this.props.mapState;
|
||||||
|
});
|
||||||
|
|
||||||
return <div className='maputnik-toolbar'>
|
return <div className='maputnik-toolbar'>
|
||||||
<div className="maputnik-toolbar__inner">
|
<div className="maputnik-toolbar__inner">
|
||||||
<div
|
<div
|
||||||
|
@ -147,13 +210,21 @@ export default class Toolbar extends React.Component {
|
||||||
<SettingsIcon />
|
<SettingsIcon />
|
||||||
<IconText>Style Settings</IconText>
|
<IconText>Style Settings</IconText>
|
||||||
</ToolbarAction>
|
</ToolbarAction>
|
||||||
<ToolbarAction wdKey="nav:inspect" onClick={this.props.onInspectModeToggle}>
|
|
||||||
<InspectionIcon />
|
<ToolbarSelect wdKey="nav:inspect">
|
||||||
<IconText>
|
<ViewIcon/>
|
||||||
{ this.props.inspectModeEnabled && <span>Map Mode</span> }
|
<IconText>View </IconText>
|
||||||
{ !this.props.inspectModeEnabled && <span>Inspect Mode</span> }
|
<select onChange={(e) => this.handleSelection(e.target.value)}>
|
||||||
</IconText>
|
{views.map((item) => {
|
||||||
</ToolbarAction>
|
return (
|
||||||
|
<option key={item.id} value={item.id}>
|
||||||
|
{item.title}
|
||||||
|
</option>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</select>
|
||||||
|
</ToolbarSelect>
|
||||||
|
|
||||||
<ToolbarLink href={"https://github.com/maputnik/editor/wiki"}>
|
<ToolbarLink href={"https://github.com/maputnik/editor/wiki"}>
|
||||||
<HelpIcon />
|
<HelpIcon />
|
||||||
<IconText>Help</IconText>
|
<IconText>Help</IconText>
|
||||||
|
|
|
@ -178,7 +178,7 @@ export default class MapboxGlMap extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
if(IS_SUPPORTED) {
|
if(IS_SUPPORTED) {
|
||||||
return <div
|
return <div
|
||||||
className="maputnik-map"
|
className="maputnik-map__map"
|
||||||
ref={x => this.container = x}
|
ref={x => this.container = x}
|
||||||
></div>
|
></div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// MAP
|
// MAP
|
||||||
.maputnik-map {
|
.maputnik-map__container {
|
||||||
display: flex;
|
display: flex;
|
||||||
position: fixed !important;
|
position: fixed !important;
|
||||||
top: $toolbar-height + $toolbar-offset;
|
top: $toolbar-height + $toolbar-offset;
|
||||||
|
@ -23,6 +23,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.maputnik-map__map {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
// DOC LABEL
|
// DOC LABEL
|
||||||
.maputnik-doc {
|
.maputnik-doc {
|
||||||
&-target {
|
&-target {
|
||||||
|
@ -171,3 +176,32 @@
|
||||||
color: $color-red;
|
color: $color-red;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.maputnik-dialog {
|
||||||
|
&__buttons {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -96,6 +96,16 @@
|
||||||
@extend .maputnik-toolbar-link;
|
@extend .maputnik-toolbar-link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.maputnik-toolbar-select {
|
||||||
|
background: inherit;
|
||||||
|
border-width: 0;
|
||||||
|
@extend .maputnik-toolbar-link;
|
||||||
|
}
|
||||||
|
|
||||||
|
.maputnik-toolbar-select select {
|
||||||
|
margin-left: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
.maputnik-icon-text {
|
.maputnik-icon-text {
|
||||||
padding-left: $margin-1;
|
padding-left: $margin-1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ describe("modals", function() {
|
||||||
"geojson:example"
|
"geojson:example"
|
||||||
]));
|
]));
|
||||||
|
|
||||||
browser.click(wd.$("nav:inspect"));
|
browser.selectByValue(wd.$("nav:inspect", "select"), "inspect");
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ describe('screenshots', function() {
|
||||||
browser.waitForExist(".maputnik-toolbar-link");
|
browser.waitForExist(".maputnik-toolbar-link");
|
||||||
browser.flushReactUpdates();
|
browser.flushReactUpdates();
|
||||||
|
|
||||||
browser.click(wd.$("nav:inspect"))
|
browser.selectByValue(wd.$("nav:inspect", "select"), "inspect");
|
||||||
browser.flushReactUpdates();
|
browser.flushReactUpdates();
|
||||||
|
|
||||||
browser.takeScreenShot("/inspect.png")
|
browser.takeScreenShot("/inspect.png")
|
||||||
|
|
Loading…
Reference in a new issue