Skip to content

Commit

Permalink
Merge pull request #2006 from jansule/drag-drop-card-style
Browse files Browse the repository at this point in the history
feat: add Drag and Drop for rules and symbolizers to CardStyle
  • Loading branch information
jansule committed Dec 7, 2022
2 parents f1938d8 + 33dbbbb commit 020fb8a
Show file tree
Hide file tree
Showing 20 changed files with 1,517 additions and 115 deletions.
161 changes: 155 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
"moment": "^2.29.4",
"monaco-editor": "^0.34.1",
"react-color": "^2.19.3",
"react-dnd": "^15.1.2",
"react-dnd-html5-backend": "^15.1.3",
"react-rnd": "^10.3.7",
"typescript-json-schema": "^0.55.0"
},
Expand Down
83 changes: 83 additions & 0 deletions src/Component/DragDroppable/DragDroppable.example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<!--
* Released under the BSD 2-Clause License
*
* Copyright © 2022-present, terrestris GmbH & Co. KG and GeoStyler contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
-->

This demonstrates the usage of the `DragDroppable` component.

```jsx
import * as React from 'react';
import { DragDroppable } from 'geostyler';
import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
import { ItemType } from '../../Util/DndUtil';

class DragDroppableExample extends React.Component {

constructor(props) {
super(props);
this.state = {
info: ''
};
}

render () {
const {
info
} = this.state;

return (
<div style={{height: '300px'}}>
<DndProvider backend={HTML5Backend}>
<DragDroppable
dragOrientation={'vertical'}
dependencies={[]}
itemType={ItemType.RULE}
position={0}
onMove={(item, target) => {this.setState({info: `Dragged item ${item} on item ${target}`});}}
>
<div style={{width: '100px', height: '100px', border: 'solid 1px'}}>Item 0</div>
</DragDroppable>
<DragDroppable
dragOrientation={'vertical'}
dependencies={[]}
itemType={ItemType.RULE}
position={1}
onMove={(item, target) => {this.setState({info: `Dragged item ${item} on item ${target}`});}}
>
<div style={{width: '100px', height: '100px', border: 'solid 1px'}}>Item 1</div>
</DragDroppable>
</DndProvider>
{info}
</div>
);
}
}

<DragDroppableExample />
```
38 changes: 38 additions & 0 deletions src/Component/DragDroppable/DragDroppable.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* Released under the BSD 2-Clause License
*
* Copyright © 2022-present, terrestris GmbH & Co. KG and GeoStyler contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
.gs-drag-droppable {
display: flex;

&.horizontal {
flex-direction: row;
}

&.vertical {
flex-direction: column;
}
}
Loading

0 comments on commit 020fb8a

Please sign in to comment.