Switch from react-aria-menubutton to <select/>

This commit is contained in:
orangemug 2018-10-06 13:54:02 +01:00
parent e4aa016713
commit a356bfd601
4 changed files with 41 additions and 31 deletions

View file

@ -1,7 +1,6 @@
import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import { Wrapper, Button, Menu, MenuItem } from 'react-aria-menubutton'
import MdFileDownload from 'react-icons/lib/md/file-download'
import OpenIcon from 'react-icons/lib/md/open-in-browser'
@ -72,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 {
static propTypes = {
children: PropTypes.node,
@ -195,34 +210,19 @@ export default class Toolbar extends React.Component {
<IconText>Style Settings</IconText>
</ToolbarAction>
<Wrapper
className='map-state-menu'
onSelection={(val) => this.handleSelection(val)}
>
<Button wdKey="nav:settings" className="maputnik-toolbar-action">
<ViewIcon/>
<IconText>View: {currentView.title}</IconText>
</Button>
<Menu>
<ul className="map-state-menu__menu">
{views.map((item) => {
return (
<li key={item.id}>
<MenuItem value={item.id}>
<button
className="maputnik-toolbar-action"
>
{item.icon}
<IconText>{item.title}</IconText>
</button>
</MenuItem>
</li>
);
})}
</ul>
</Menu>
</Wrapper>
<ToolbarSelect wdKey="nav:inspect">
<ViewIcon/>
<IconText>View </IconText>
<select onChange={(e) => this.handleSelection(e.target.value)}>
{views.map((item) => {
return (
<option value={item.id}>
{item.title}
</option>
);
})}
</select>
</ToolbarSelect>
<ToolbarLink href={"https://github.com/maputnik/editor/wiki"}>
<HelpIcon />

View file

@ -92,6 +92,16 @@
@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 {
padding-left: $margin-1;
}

View file

@ -100,7 +100,7 @@ describe("modals", function() {
"geojson:example"
]));
browser.click(wd.$("nav:inspect"));
browser.setValue(wd.$("nav:inspect", "select"), "inspect");
})
})

View file

@ -83,7 +83,7 @@ describe('screenshots', function() {
browser.waitForExist(".maputnik-toolbar-link");
browser.flushReactUpdates();
browser.click(wd.$("nav:inspect"))
browser.setValue(wd.$("nav:inspect", "select"), "inspect");
browser.flushReactUpdates();
browser.takeScreenShot("/inspect.png")