Merge remote-tracking branch 'upstream/master' into fix/invalid-style-with-duplicate-layer-ids

This commit is contained in:
orangemug 2020-03-30 08:52:37 +01:00
commit b5c09a4f17
6 changed files with 88 additions and 17 deletions

10
package-lock.json generated
View file

@ -1513,6 +1513,11 @@
"integrity": "sha512-zYNV7g+nhURRTnZbFDEIm1XHWWbj6lyqFg9ZqQ72p918UuR6+L/0s1FeM57EhGmNQsCiN/Ika42H1owD91f3Iw==", "integrity": "sha512-zYNV7g+nhURRTnZbFDEIm1XHWWbj6lyqFg9ZqQ72p918UuR6+L/0s1FeM57EhGmNQsCiN/Ika42H1owD91f3Iw==",
"dev": true "dev": true
}, },
"@mdi/react": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@mdi/react/-/react-1.3.0.tgz",
"integrity": "sha512-RmdB3gsAW4iXOTTHaEaGQ//2w0sxGWiZEoIDteXcf1qTkDkaA+LBu6ub4nNi4VcmSKjcceGHnYHqHENh8fky7A=="
},
"@nodelib/fs.scandir": { "@nodelib/fs.scandir": {
"version": "2.1.3", "version": "2.1.3",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz",
@ -11091,6 +11096,11 @@
"prop-types": "^15.6.2" "prop-types": "^15.6.2"
} }
}, },
"react-accessible-accordion": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/react-accessible-accordion/-/react-accessible-accordion-3.0.1.tgz",
"integrity": "sha512-2OZY6PWVOTYjVRQ5vnzVfvSRvapH1fYHNE6rG0S64cCatf+IOovokZEa4Xzmdl69ebrYO2HU3h8yLlEk9LqwPA=="
},
"react-aria-menubutton": { "react-aria-menubutton": {
"version": "6.3.0", "version": "6.3.0",
"resolved": "https://registry.npmjs.org/react-aria-menubutton/-/react-aria-menubutton-6.3.0.tgz", "resolved": "https://registry.npmjs.org/react-aria-menubutton/-/react-aria-menubutton-6.3.0.tgz",

View file

@ -25,6 +25,7 @@
"@babel/runtime": "^7.8.4", "@babel/runtime": "^7.8.4",
"@mapbox/mapbox-gl-rtl-text": "^0.2.3", "@mapbox/mapbox-gl-rtl-text": "^0.2.3",
"@mapbox/mapbox-gl-style-spec": "^13.12.0", "@mapbox/mapbox-gl-style-spec": "^13.12.0",
"@mdi/react": "^1.3.0",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"codemirror": "^5.52.0", "codemirror": "^5.52.0",
"color": "^3.1.2", "color": "^3.1.2",
@ -46,6 +47,7 @@
"ol-mapbox-style": "^6.0.1", "ol-mapbox-style": "^6.0.1",
"prop-types": "^15.7.2", "prop-types": "^15.7.2",
"react": "^16.12.0", "react": "^16.12.0",
"react-accessible-accordion": "^3.0.1",
"react-aria-menubutton": "^6.3.0", "react-aria-menubutton": "^6.3.0",
"react-aria-modal": "^4.0.0", "react-aria-modal": "^4.0.0",
"react-autobind": "^1.0.6", "react-autobind": "^1.0.6",

View file

@ -13,6 +13,7 @@ import MaxZoomBlock from './MaxZoomBlock'
import CommentBlock from './CommentBlock' import CommentBlock from './CommentBlock'
import LayerSourceBlock from './LayerSourceBlock' import LayerSourceBlock from './LayerSourceBlock'
import LayerSourceLayerBlock from './LayerSourceLayerBlock' import LayerSourceLayerBlock from './LayerSourceLayerBlock'
import {Accordion} from 'react-accessible-accordion';
import {MdMoreVert} from 'react-icons/md' import {MdMoreVert} from 'react-icons/md'
@ -233,12 +234,16 @@ export default class LayerEditor extends React.Component {
} }
render() { render() {
const groupIds = [];
const layerType = this.props.layer.type const layerType = this.props.layer.type
const groups = layoutGroups(layerType).filter(group => { const groups = layoutGroups(layerType).filter(group => {
return !(layerType === 'background' && group.type === 'source') return !(layerType === 'background' && group.type === 'source')
}).map(group => { }).map(group => {
const groupId = group.title.replace(/ /g, "_");
groupIds.push(groupId);
return <LayerEditorGroup return <LayerEditorGroup
data-wd-key={group.title} data-wd-key={group.title}
id={groupId}
key={group.title} key={group.title}
title={group.title} title={group.title}
isActive={this.state.editorGroups[group.title]} isActive={this.state.editorGroups[group.title]}
@ -315,7 +320,13 @@ export default class LayerEditor extends React.Component {
</div> </div>
</header> </header>
{groups} <Accordion
allowMultipleExpanded={true}
allowZeroExpanded={true}
preExpanded={groupIds}
>
{groups}
</Accordion>
</div> </div>
} }
} }

View file

@ -1,11 +1,21 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import Collapser from './Collapser' import Icon from '@mdi/react'
import Collapse from './Collapse' import {
mdiMenuDown,
mdiMenuUp
} from '@mdi/js';
import {
AccordionItem,
AccordionItemHeading,
AccordionItemButton,
AccordionItemPanel,
} from 'react-accessible-accordion';
export default class LayerEditorGroup extends React.Component { export default class LayerEditorGroup extends React.Component {
static propTypes = { static propTypes = {
"id": PropTypes.string,
"data-wd-key": PropTypes.string, "data-wd-key": PropTypes.string,
title: PropTypes.string.isRequired, title: PropTypes.string.isRequired,
isActive: PropTypes.bool.isRequired, isActive: PropTypes.bool.isRequired,
@ -14,20 +24,28 @@ export default class LayerEditorGroup extends React.Component {
} }
render() { render() {
return <div> return <AccordionItem uuid={this.props.id}>
<div className="maputnik-layer-editor-group" <AccordionItemHeading className="maputnik-layer-editor-group"
data-wd-key={"layer-editor-group:"+this.props["data-wd-key"]} data-wd-key={"layer-editor-group:"+this.props["data-wd-key"]}
onClick={e => this.props.onActiveToggle(!this.props.isActive)} onClick={e => this.props.onActiveToggle(!this.props.isActive)}
> >
<span>{this.props.title}</span> <AccordionItemButton className="maputnik-layer-editor-group__button">
<span style={{flexGrow: 1}} /> <span style={{flexGrow: 1}}>{this.props.title}</span>
<Collapser isCollapsed={this.props.isActive} /> <Icon
</div> path={mdiMenuUp}
<Collapse isActive={this.props.isActive}> size={1}
<div className="react-collapse-container"> className="maputnik-layer-editor-group__button__icon maputnik-layer-editor-group__button__icon--up"
{this.props.children} />
</div> <Icon
</Collapse> path={mdiMenuDown}
</div> size={1}
className="maputnik-layer-editor-group__button__icon maputnik-layer-editor-group__button__icon--down"
/>
</AccordionItemButton>
</AccordionItemHeading>
<AccordionItemPanel>
{this.props.children}
</AccordionItemPanel>
</AccordionItem>
} }
} }

View file

@ -163,10 +163,39 @@
color: $color-white; color: $color-white;
cursor: pointer; cursor: pointer;
user-select: none; user-select: none;
padding: $margin-2;
line-height: 20px; line-height: 20px;
border-top: solid 1px #36383e; border-top: solid 1px #36383e;
&__button {
flex: 1;
display: flex;
padding: $margin-2;
&__icon {
fill: white;
}
&__icon--up {
display: block;
}
&__icon--down {
display: none;
}
}
&__button[aria-expanded="true"] {
.maputnik-layer-editor-group__button__icon--up {
display: none;
}
.maputnik-layer-editor-group__button__icon--down {
display: block;
}
}
@include flex-row; @include flex-row;
&:hover { &:hover {

View file

@ -2,7 +2,8 @@
div:not(.maputnik-toolbar__actions) { div:not(.maputnik-toolbar__actions) {
&::-webkit-scrollbar { &::-webkit-scrollbar {
background-color: #26282e; background-color: #26282e;
width: 5px; width: 8px;
height: 8px;
} }
&::-webkit-scrollbar-thumb { &::-webkit-scrollbar-thumb {