Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/implement classifer dropdown #5

Merged
merged 2 commits into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions src/components/DropdownEditor/index.js
Original file line number Diff line number Diff line change
@@ -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 (
<React.Fragment>
<Inner>
<select defaultValue={props.value} onChange={props.onChange}>
<option value="na">- classify -</option>
<option>Young Coffee</option>
<option>Mature Coffee</option>
</select>
{/*<textarea
placeholder='Write description'
onFocus={props.onFocus}
onBlur={props.onBlur}
onChange={props.onChange}
value={props.value}
>
</textarea>*/}
</Inner>
{(props.value && props.value.length > 0 && props.value !== 'na') &&
<Button
onClick={props.onSubmit}
>
Submit
</Button>
}
</React.Fragment>
)
}

export default DropdownEditor
38 changes: 27 additions & 11 deletions src/components/Editor/index.js
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -47,17 +48,32 @@ function Editor (props) {
}}
>
<Container>
<TextEditor
onChange={e => 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) &&
<DropdownEditor
onChange={e => 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) &&
<TextEditor
onChange={e => props.onChange({
...props.annotation,
data: {
...props.annotation.data,
text: e.target.value
}
})}
onSubmit={props.onSubmit}
value={props.annotation.data && props.annotation.data.text}
/>
}
</Container>
</div>
)
Expand Down
3 changes: 1 addition & 2 deletions src/components/PolygonControls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const Container = styled.div`
0px 1px 5px 0px rgba(0, 0, 0, 0.2),
0px 2px 2px 0px rgba(0, 0, 0, 0.14),
0px 3px 1px -2px rgba(0, 0, 0, 0.12);
margin-top: 16px;
transform-origin: top left;

animation: ${fadeInScale} 0.31s cubic-bezier(0.175, 0.885, 0.32, 1.275);
Expand Down Expand Up @@ -61,7 +60,7 @@ function PolygonControls (props) {
style={{
position: 'absolute',
left: `${getHorizontallyCentralPoint(geometry.points)}%`,
top: `${getVerticallyLowestPoint(geometry.points)}%`,
top: `${(getVerticallyLowestPoint(geometry.points) + 10)}%`,
...props.style
}}
>
Expand Down