Skip to content

Commit

Permalink
fix label and control dialog spacing and sizing on zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
leopoldjoy committed Nov 8, 2018
1 parent 343f1bd commit a95f835
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
6 changes: 4 additions & 2 deletions src/components/Annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ export default compose(
&& (
renderContent({
key: annotation.data.id,
annotation: annotation
annotation: annotation,
imageZoomAmount: props.imageZoomAmount
})
)
))}
Expand All @@ -297,7 +298,8 @@ export default compose(
renderEditor({
annotation: props.value,
onChange: props.onChange,
onSubmit: this.onSubmit
onSubmit: this.onSubmit,
imageZoomAmount: props.imageZoomAmount
})
)
}
Expand Down
7 changes: 6 additions & 1 deletion src/components/Content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ const Container = styled.div`
margin-top: 8px;
margin-left: -50%;
margin-right: 50%;
color: #363636!important;
`

function Content (props) {
const { geometry } = props.annotation
if (!geometry) return null

const zoomBetweenHalfAndOne = Math.abs(props.imageZoomAmount - 2) / 2;

return (
<div
style={{
Expand All @@ -32,7 +35,9 @@ function Content (props) {
className={props.className}
geometry={geometry}
>
<Container>
<Container
style={{fontSize: ((0.5 + zoomBetweenHalfAndOne) + 'rem'), padding: ((4 + (4 * zoomBetweenHalfAndOne)) + 'px ' + (8 + (8 * zoomBetweenHalfAndOne)) + 'px')}}
>
{props.annotation.data && props.annotation.data.age}
{' - '}
{props.annotation.data && props.annotation.data.renovationType}
Expand Down
1 change: 1 addition & 0 deletions src/components/Editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function Editor (props) {
onSubmit={props.onSubmit}
ageValue={props.annotation.data && props.annotation.data.age}
renovationTypeValue={props.annotation.data && props.annotation.data.renovationType}
imageZoomAmount={props.imageZoomAmount}
/>
}
{(geometry.type !== PolygonSelector.TYPE) &&
Expand Down
18 changes: 7 additions & 11 deletions src/components/RadioButtonEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@ 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;
}
color: #363636!important;
`

const Button = styled.div`
Expand All @@ -35,10 +28,12 @@ const Button = styled.div`
`

function RadioButtonEditor (props) {
const zoomBetweenHalfAndOne = Math.abs(props.imageZoomAmount - 2) / 2;

return (
<React.Fragment>
<Inner>
<div><h6 style={{margin: '6px 0'}}> - Coffee Age - </h6></div>
<Inner style={{fontSize: ((0.5 + zoomBetweenHalfAndOne) + 'rem'), padding: ((4 + (4 * zoomBetweenHalfAndOne)) + 'px ' + (8 + (8 * zoomBetweenHalfAndOne)) + 'px')}}>
<div><h6 style={{margin: '0px 0px', textAlign: 'center'}}> - Coffee Age - </h6></div>
<div>
<label><input type="radio"
name="age"
Expand All @@ -56,7 +51,7 @@ function RadioButtonEditor (props) {
/> Mature</label>
</div>

<div><h6 style={{margin: '6px 0'}}> - Renovation Type - </h6></div>
<div><h6 style={{margin: '0px 0px', textAlign: 'center'}}> - Renovation Type - </h6></div>
<div>
<label><input type="radio"
name="renovationType"
Expand All @@ -77,6 +72,7 @@ function RadioButtonEditor (props) {
{(props.ageValue && props.ageValue.length > 0 && props.renovationTypeValue && props.renovationTypeValue.length > 0) &&
<Button
onClick={props.onSubmit}
style={{fontSize: ((0.5 + zoomBetweenHalfAndOne) + 'rem'), padding: ((4 + (4 * zoomBetweenHalfAndOne)) + 'px ' + (8 + (8 * zoomBetweenHalfAndOne)) + 'px')}}
>
Submit
</Button>
Expand Down
6 changes: 4 additions & 2 deletions src/components/defaultProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ export default {
return null
}
},
renderEditor: ({ annotation, onChange, onSubmit }) => (
renderEditor: ({ annotation, onChange, onSubmit, imageZoomAmount }) => (
<Editor
annotation={annotation}
onChange={onChange}
onSubmit={onSubmit}
imageZoomAmount={imageZoomAmount}
/>
),
renderPolygonControls: ({ annotation, onSelectionComplete, onSelectionClear, onSelectionUndo, imageZoomAmount }) => (
Expand Down Expand Up @@ -118,10 +119,11 @@ export default {
return null
}
},
renderContent: ({ key, annotation }) => (
renderContent: ({ key, annotation, imageZoomAmount }) => (
<Content
key={key}
annotation={annotation}
imageZoomAmount={imageZoomAmount}
/>
),
renderOverlay: ({ type, annotation }) => {
Expand Down

0 comments on commit a95f835

Please sign in to comment.