-
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(controls): Create react core controls for image viewers (#1285)
- Loading branch information
Showing
10 changed files
with
217 additions
and
20 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,17 @@ | ||
import React from 'react'; | ||
import ControlsBar from '../controls/controls-bar'; | ||
import FullscreenToggle, { Props as FullscreenToggleProps } from '../controls/fullscreen'; | ||
import ZoomControls, { Props as ZoomControlsProps } from '../controls/zoom'; | ||
|
||
export type Props = FullscreenToggleProps & ZoomControlsProps; | ||
|
||
export default function ImageControls({ onFullscreenToggle, onZoomIn, onZoomOut, scale }: Props): JSX.Element { | ||
return ( | ||
<ControlsBar> | ||
<ZoomControls onZoomIn={onZoomIn} onZoomOut={onZoomOut} scale={scale} /> | ||
{/* TODO: RotateControl */} | ||
<FullscreenToggle onFullscreenToggle={onFullscreenToggle} /> | ||
{/* TODO: AnnotationControls (separate group) */} | ||
</ControlsBar> | ||
); | ||
} |
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,16 @@ | ||
import React from 'react'; | ||
import ControlsBar from '../controls/controls-bar'; | ||
import FullscreenToggle, { Props as FullscreenToggleProps } from '../controls/fullscreen'; | ||
import ZoomControls, { Props as ZoomControlsProps } from '../controls/zoom'; | ||
|
||
export type Props = FullscreenToggleProps & ZoomControlsProps; | ||
|
||
export default function MultiImageControls({ onFullscreenToggle, onZoomIn, onZoomOut, scale }: Props): JSX.Element { | ||
return ( | ||
<ControlsBar> | ||
<ZoomControls onZoomIn={onZoomIn} onZoomOut={onZoomOut} scale={scale} /> | ||
{/* TODO: PageControls */} | ||
<FullscreenToggle onFullscreenToggle={onFullscreenToggle} /> | ||
</ControlsBar> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import ControlsBar from '../../controls/controls-bar'; | ||
import FullscreenToggle from '../../controls/fullscreen'; | ||
import ImageControls from '../ImageControls'; | ||
import ZoomControls from '../../controls/zoom'; | ||
|
||
describe('ImageControls', () => { | ||
describe('render', () => { | ||
test('should return a valid wrapper', () => { | ||
const onToggle = jest.fn(); | ||
const onZoomIn = jest.fn(); | ||
const onZoomOut = jest.fn(); | ||
const wrapper = shallow( | ||
<ImageControls onFullscreenToggle={onToggle} onZoomIn={onZoomIn} onZoomOut={onZoomOut} />, | ||
); | ||
|
||
expect(wrapper.exists(ControlsBar)); | ||
expect(wrapper.find(FullscreenToggle).prop('onFullscreenToggle')).toEqual(onToggle); | ||
expect(wrapper.find(ZoomControls).prop('onZoomIn')).toEqual(onZoomIn); | ||
expect(wrapper.find(ZoomControls).prop('onZoomOut')).toEqual(onZoomOut); | ||
}); | ||
}); | ||
}); |
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
24 changes: 24 additions & 0 deletions
24
src/lib/viewers/image/__tests__/MultiImageControls-test.jsx
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,24 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import ControlsBar from '../../controls/controls-bar'; | ||
import FullscreenToggle from '../../controls/fullscreen'; | ||
import MultiImageControls from '../MultiImageControls'; | ||
import ZoomControls from '../../controls/zoom'; | ||
|
||
describe('MultiImageControls', () => { | ||
describe('render', () => { | ||
test('should return a valid wrapper', () => { | ||
const onToggle = jest.fn(); | ||
const onZoomIn = jest.fn(); | ||
const onZoomOut = jest.fn(); | ||
const wrapper = shallow( | ||
<MultiImageControls onFullscreenToggle={onToggle} onZoomIn={onZoomIn} onZoomOut={onZoomOut} />, | ||
); | ||
|
||
expect(wrapper.exists(ControlsBar)); | ||
expect(wrapper.find(FullscreenToggle).prop('onFullscreenToggle')).toEqual(onToggle); | ||
expect(wrapper.find(ZoomControls).prop('onZoomIn')).toEqual(onZoomIn); | ||
expect(wrapper.find(ZoomControls).prop('onZoomOut')).toEqual(onZoomOut); | ||
}); | ||
}); | ||
}); |
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