diff --git a/package-lock.json b/package-lock.json index ec51079..aed0ea2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1513,6 +1513,11 @@ "integrity": "sha512-zYNV7g+nhURRTnZbFDEIm1XHWWbj6lyqFg9ZqQ72p918UuR6+L/0s1FeM57EhGmNQsCiN/Ika42H1owD91f3Iw==", "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": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz", @@ -11091,6 +11096,11 @@ "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": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/react-aria-menubutton/-/react-aria-menubutton-6.3.0.tgz", diff --git a/package.json b/package.json index 458832b..540436e 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "@babel/runtime": "^7.8.4", "@mapbox/mapbox-gl-rtl-text": "^0.2.3", "@mapbox/mapbox-gl-style-spec": "^13.12.0", + "@mdi/react": "^1.3.0", "classnames": "^2.2.6", "codemirror": "^5.52.0", "color": "^3.1.2", @@ -46,6 +47,7 @@ "ol-mapbox-style": "^6.0.1", "prop-types": "^15.7.2", "react": "^16.12.0", + "react-accessible-accordion": "^3.0.1", "react-aria-menubutton": "^6.3.0", "react-aria-modal": "^4.0.0", "react-autobind": "^1.0.6", diff --git a/src/components/layers/LayerEditor.jsx b/src/components/layers/LayerEditor.jsx index 291cae2..bc0150e 100644 --- a/src/components/layers/LayerEditor.jsx +++ b/src/components/layers/LayerEditor.jsx @@ -13,6 +13,7 @@ import MaxZoomBlock from './MaxZoomBlock' import CommentBlock from './CommentBlock' import LayerSourceBlock from './LayerSourceBlock' import LayerSourceLayerBlock from './LayerSourceLayerBlock' +import {Accordion} from 'react-accessible-accordion'; import {MdMoreVert} from 'react-icons/md' @@ -233,12 +234,16 @@ export default class LayerEditor extends React.Component { } render() { + const groupIds = []; const layerType = this.props.layer.type const groups = layoutGroups(layerType).filter(group => { return !(layerType === 'background' && group.type === 'source') }).map(group => { + const groupId = group.title.replace(/ /g, "_"); + groupIds.push(groupId); return - {groups} + + {groups} + } } diff --git a/src/components/layers/LayerEditorGroup.jsx b/src/components/layers/LayerEditorGroup.jsx index e132dd5..652aba4 100644 --- a/src/components/layers/LayerEditorGroup.jsx +++ b/src/components/layers/LayerEditorGroup.jsx @@ -1,11 +1,21 @@ import React from 'react' import PropTypes from 'prop-types' -import Collapser from './Collapser' -import Collapse from './Collapse' +import Icon from '@mdi/react' +import { + mdiMenuDown, + mdiMenuUp +} from '@mdi/js'; +import { + AccordionItem, + AccordionItemHeading, + AccordionItemButton, + AccordionItemPanel, +} from 'react-accessible-accordion'; export default class LayerEditorGroup extends React.Component { static propTypes = { + "id": PropTypes.string, "data-wd-key": PropTypes.string, title: PropTypes.string.isRequired, isActive: PropTypes.bool.isRequired, @@ -14,20 +24,28 @@ export default class LayerEditorGroup extends React.Component { } render() { - return
-
+ this.props.onActiveToggle(!this.props.isActive)} > - {this.props.title} - - -
- -
- {this.props.children} -
-
-
+ + {this.props.title} + + + + + + {this.props.children} + + } } diff --git a/src/styles/_layer.scss b/src/styles/_layer.scss index 1648bd4..4e059f0 100644 --- a/src/styles/_layer.scss +++ b/src/styles/_layer.scss @@ -163,10 +163,39 @@ color: $color-white; cursor: pointer; user-select: none; - padding: $margin-2; line-height: 20px; 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; &:hover { diff --git a/src/styles/_scrollbar.scss b/src/styles/_scrollbar.scss index aed9fe1..340c789 100644 --- a/src/styles/_scrollbar.scss +++ b/src/styles/_scrollbar.scss @@ -2,7 +2,8 @@ div:not(.maputnik-toolbar__actions) { &::-webkit-scrollbar { background-color: #26282e; - width: 5px; + width: 8px; + height: 8px; } &::-webkit-scrollbar-thumb {