-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(drawing): add ColorPickerControl for images (#1307)
* feat(drawing): add ColorPickerControl for images
- Loading branch information
Showing
9 changed files
with
134 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import ColorPickerControl from '../color-picker'; | ||
import { ANNOTATION_COLORS } from '../../../AnnotationModule'; | ||
import { AnnotationMode } from './types'; | ||
|
||
export type Props = { | ||
annotationColor?: string; | ||
annotationMode?: AnnotationMode; | ||
onAnnotationColorChange: (color: string) => void; | ||
}; | ||
|
||
export default function DrawingControls({ | ||
annotationColor, | ||
annotationMode, | ||
onAnnotationColorChange, | ||
}: Props): JSX.Element | null { | ||
if (annotationMode !== AnnotationMode.DRAWING) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<ColorPickerControl | ||
activeColor={annotationColor} | ||
colors={ANNOTATION_COLORS} | ||
onColorSelect={onAnnotationColorChange} | ||
/> | ||
); | ||
} |
22 changes: 22 additions & 0 deletions
22
src/lib/viewers/controls/annotations/__tests__/DrawingControls-test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
import { shallow, ShallowWrapper } from 'enzyme'; | ||
import DrawingControls from '../DrawingControls'; | ||
import { AnnotationMode } from '../types'; | ||
|
||
describe('DrawingControls', () => { | ||
const getWrapper = (props = {}): ShallowWrapper => | ||
shallow(<DrawingControls onAnnotationColorChange={jest.fn()} {...props} />); | ||
|
||
describe('render', () => { | ||
test('should return nothing if annotationMode is not DRAWING', () => { | ||
const wrapper = getWrapper(); | ||
expect(wrapper.isEmptyRender()).toBe(true); | ||
}); | ||
|
||
test('should return ColorPickerControl if annotationMode is DRAWING', () => { | ||
const wrapper = getWrapper({ annotationMode: AnnotationMode.DRAWING }); | ||
|
||
expect(wrapper.exists('ColorPickerControl')).toBe(true); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters