diff --git a/README.md b/README.md index fc361b3..3990137 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,19 @@ You can also link the css style from a CDN in your index.html ##### PolygonDraw -**Props** +![Editing Polygon](docs/polygon-editor.gif) + +**Editing functionalities:** +- Undo: undoes the last action +- Redo: redoes the last action +- Pen: adds small points between each vertex to enable editing the polygon shape and creating more vertexes. +- Delete: deletes selected vertex(es) +- Import: enables the import of a polygon with GeoJSON format +- Export: exports the polygon in GEOJson, JTS, or LtnLng formats +- Focus: refocuses the map to the selected polygon + + +**Component Props** - **polygon**: _Coordinate[] | Coordinate[][]_ (Single or list of polygons to render) - **activeIndex**?: _number_ (index of currently active polygon, can be omitted when only one polygon exists. **Default value: 0**) @@ -60,7 +72,7 @@ You can also link the css style from a CDN in your index.html The initialCenter and initialZoom props are applicable only when both the polygon and the boundary coordinates are empty. This flow explains which parameters are used to focus the map: -![Focus flow](map_focus_flow.png) +![Focus flow](docs/map_focus_flow.png) For more details, have a look at the Component definition in [PolygonDraw](src/PolygonDraw/PolygonDraw.tsx) diff --git a/map_focus_flow.png b/docs/map_focus_flow.png similarity index 100% rename from map_focus_flow.png rename to docs/map_focus_flow.png diff --git a/docs/polygon-editor.gif b/docs/polygon-editor.gif new file mode 100644 index 0000000..57a6038 Binary files /dev/null and b/docs/polygon-editor.gif differ diff --git a/src/ActionBar/ActionBar.tsx b/src/ActionBar/ActionBar.tsx index e656885..9300762 100644 --- a/src/ActionBar/ActionBar.tsx +++ b/src/ActionBar/ActionBar.tsx @@ -50,10 +50,10 @@ export const ActionBar: FunctionComponent = ({ onUndo, }) => ( - + {LABELS.UNDO} - + {LABELS.REDO} {editable && ( diff --git a/src/ActionBar/ActionButton.tsx b/src/ActionBar/ActionButton.tsx index 7d55fae..24c665b 100644 --- a/src/ActionBar/ActionButton.tsx +++ b/src/ActionBar/ActionButton.tsx @@ -1,13 +1,15 @@ import React, { FunctionComponent } from 'react'; import styled from 'styled-components'; -import { AUTHENTIC_BLUE_900, AUTHENTIC_BLUE_200, ACTION_BLUE_900, WHITE } from '../common/colors'; +import { ACTION_BLUE_900, AUTHENTIC_BLUE_200, AUTHENTIC_BLUE_900, WHITE } from '../common/colors'; +import { Export } from './Icons/Export'; import { Frame } from './Icons/Frame'; +import { Import } from './Icons/Import'; +import { Redo } from './Icons/Redo'; import { Trashcan } from './Icons/Trashcan'; +import { Undo } from './Icons/Undo'; import { VectorMode } from './Icons/VectorMode'; -import { Export } from './Icons/Export'; -import { Import } from './Icons/Import'; export enum ActionButtonIcons { TRASHCAN = 'TRASHCAN', @@ -15,12 +17,15 @@ export enum ActionButtonIcons { VECTOR_MODE = 'VECTOR_MODE', EXPORT = 'EXPORT', IMPORT = 'IMPORT', + UNDO = 'UNDO', + REDO = 'REDO', } interface ContainerProps { disabled?: boolean; } -const Container = styled('button').attrs(() => ({type: 'button'}))` + +const Container = styled('button').attrs(() => ({ type: 'button' }))` position: relative; width: 42px; height: 42px; @@ -71,6 +76,12 @@ const renderIcon = (icon: ActionButtonIcons, inactive?: boolean, activeIconColor case ActionButtonIcons.IMPORT: { return ; } + case ActionButtonIcons.REDO: { + return ; + } + case ActionButtonIcons.UNDO: { + return ; + } default: return null; } diff --git a/src/ActionBar/Icons/Export.tsx b/src/ActionBar/Icons/Export.tsx index e2633e8..0afbc11 100644 --- a/src/ActionBar/Icons/Export.tsx +++ b/src/ActionBar/Icons/Export.tsx @@ -1,12 +1,7 @@ -import React, { SVGProps } from 'react'; - import { AUTHENTIC_BLUE_900 } from '../../common/colors'; +import { IconProps } from './types'; -interface Props extends SVGProps { - iconColor?: string; -} - -export const Export: React.FC = ({ iconColor = AUTHENTIC_BLUE_900, ...props }) => ( +export const Export = ({ iconColor = AUTHENTIC_BLUE_900, ...props }: IconProps): React.ReactElement => ( { - iconColor?: string; -} - -export const Frame: FunctionComponent = ({ iconColor, ...props }) => ( +export const Frame = ({ iconColor = AUTHENTIC_BLUE_900, ...props }: IconProps): React.ReactElement => ( { - iconColor?: string; -} - -export const Import: React.FC = ({ iconColor = AUTHENTIC_BLUE_900, ...props }) => ( +export const Import = ({ iconColor = AUTHENTIC_BLUE_900, ...props }: IconProps): React.ReactElement => ( ( + + + +); diff --git a/src/ActionBar/Icons/Trashcan.tsx b/src/ActionBar/Icons/Trashcan.tsx index 46855a5..85dd7e8 100644 --- a/src/ActionBar/Icons/Trashcan.tsx +++ b/src/ActionBar/Icons/Trashcan.tsx @@ -1,12 +1,7 @@ -import { FunctionComponent, SVGProps } from 'react'; - import { AUTHENTIC_BLUE_900 } from '../../common/colors'; +import { IconProps } from './types'; -interface Props extends SVGProps { - iconColor?: string; -} - -export const Trashcan: FunctionComponent = ({ iconColor = AUTHENTIC_BLUE_900, ...props }) => ( +export const Trashcan = ({ iconColor = AUTHENTIC_BLUE_900, ...props }: IconProps): React.ReactElement => ( ( + + + +); diff --git a/src/ActionBar/Icons/types.ts b/src/ActionBar/Icons/types.ts new file mode 100644 index 0000000..d3f0b35 --- /dev/null +++ b/src/ActionBar/Icons/types.ts @@ -0,0 +1,5 @@ +import { SVGProps } from 'react'; + +export interface IconProps extends SVGProps { + iconColor?: string; +}