diff --git a/demo/src/components/Docs/index.js b/demo/src/components/Docs/index.js index 2923a31..d6ffe3f 100644 --- a/demo/src/components/Docs/index.js +++ b/demo/src/components/Docs/index.js @@ -29,7 +29,7 @@ export default class Docs extends Component { render () { return ( -

Multiple Type/Shape Support

+

Multiple Type/Shape/Style Support

{multiCode} diff --git a/demo/src/components/Samples/Multiple/index.js b/demo/src/components/Samples/Multiple/index.js index 61f412f..5f90755 100644 --- a/demo/src/components/Samples/Multiple/index.js +++ b/demo/src/components/Samples/Multiple/index.js @@ -11,15 +11,21 @@ import Button from '../../Button' import mocks from '../../../mocks' import img from '../../../img.jpeg' +const styles = { + redBorder: { border: '1px solid red' }, + blueBorder: { border: '1px solid blue'} +} + export default class Multiple extends Component { state = { type: RectangleSelector.TYPE, annotations: mocks.annotations, - annotation: {} + annotation: {}, + style: {} } onChange = (annotation) => { - this.setState({ annotation }) + this.setState({ annotation: { ...annotation, style: this.state.style } }) } onSubmit = (annotation) => { @@ -32,7 +38,8 @@ export default class Multiple extends Component { data: { ...data, id: Math.random() - } + }, + style: this.state.style }) }) } @@ -47,25 +54,51 @@ export default class Multiple extends Component { render () { return (
- - - +
+

Shape:

+ + + +
+ +
+

Border:

+ + + +
+ { - this.setState({ annotation }) + this.setState({ annotation: { ...annotation, style: this.state.style } }) } onSubmit = (annotation) => { @@ -27,7 +38,8 @@ export default class Multiple extends Component { data: { ...data, id: Math.random() - } + }, + style: this.state.style }) }) } @@ -42,16 +54,51 @@ export default class Multiple extends Component { render () { return (
- - - +
+

Shape:

+ + + +
+ +
+

Border:

+ + + +
+ ) diff --git a/src/components/defaultProps.js b/src/components/defaultProps.js index 0cf81c9..02f3cf7 100644 --- a/src/components/defaultProps.js +++ b/src/components/defaultProps.js @@ -32,11 +32,15 @@ export default { renderSelector: ({ annotation }) => { switch (annotation.geometry.type) { case RectangleSelector.TYPE: - return ( - - ) + if (annotation.style) { + return + } else { + return ( + + ) + } case PointSelector.TYPE: return (