From b9d6a4526837e3a5e7e255304fabb25b2320ce25 Mon Sep 17 00:00:00 2001 From: Leopold Joy Date: Wed, 7 Nov 2018 18:11:34 -0500 Subject: [PATCH] implement dropdown menu for classifying imagery --- src/components/DropdownEditor/index.js | 66 ++++++++++++++++++++++++++ src/components/Editor/index.js | 38 ++++++++++----- 2 files changed, 93 insertions(+), 11 deletions(-) create mode 100644 src/components/DropdownEditor/index.js diff --git a/src/components/DropdownEditor/index.js b/src/components/DropdownEditor/index.js new file mode 100644 index 0000000..e3d6a2b --- /dev/null +++ b/src/components/DropdownEditor/index.js @@ -0,0 +1,66 @@ +import React from 'react' +import styled, { keyframes } from 'styled-components' + +const Inner = styled.div` + padding: 8px 16px; + + textarea { + border: 0; + font-size: 14px; + margin: 6px 0; + min-height: 60px; + outline: 0; + } +` + +const Button = styled.div` + background: whitesmoke; + border: 0; + box-sizing: border-box; + color: #363636; + cursor: pointer; + font-size: 1rem; + margin: 0; + outline: 0; + padding: 8px 16px; + text-align: center; + text-shadow: 0 1px 0 rgba(0,0,0,0.1); + width: 100%; + + transition: background 0.21s ease-in-out; + + &:focus, &:hover { + background: #eeeeee; + } +` + +function DropdownEditor (props) { + return ( + + + + {/**/} + + {(props.value && props.value.length > 0 && props.value !== 'na') && + + } + + ) +} + +export default DropdownEditor diff --git a/src/components/Editor/index.js b/src/components/Editor/index.js index 5e6d03b..e1a0e23 100644 --- a/src/components/Editor/index.js +++ b/src/components/Editor/index.js @@ -1,6 +1,7 @@ import React from 'react' import styled, { keyframes } from 'styled-components' import TextEditor from '../TextEditor' +import DropdownEditor from '../DropdownEditor' import { getHorizontallyCentralPoint, getVerticallyLowestPoint } from '../../utils/pointsUtils' import { PolygonSelector } from '../../selectors' @@ -47,17 +48,32 @@ function Editor (props) { }} > - props.onChange({ - ...props.annotation, - data: { - ...props.annotation.data, - text: e.target.value - } - })} - onSubmit={props.onSubmit} - value={props.annotation.data && props.annotation.data.text} - /> + {(geometry.type === PolygonSelector.TYPE) && + props.onChange({ + ...props.annotation, + data: { + ...props.annotation.data, + text: e.target.value + } + })} + onSubmit={props.onSubmit} + value={props.annotation.data && props.annotation.data.text} + /> + } + {(geometry.type !== PolygonSelector.TYPE) && + props.onChange({ + ...props.annotation, + data: { + ...props.annotation.data, + text: e.target.value + } + })} + onSubmit={props.onSubmit} + value={props.annotation.data && props.annotation.data.text} + /> + } )