-
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 new rotate control + add to image viewer
- Loading branch information
Showing
7 changed files
with
62 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@import '../styles'; | ||
|
||
.bp-RotateControl { | ||
@include bp-ControlButton; | ||
} |
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,15 @@ | ||
import React from 'react'; | ||
import IconRotate24 from '../icons/IconRotate24'; | ||
import './RotateControl.scss'; | ||
|
||
export type Props = { | ||
onRotateLeft: () => void; | ||
}; | ||
|
||
export default function RotateControl({ onRotateLeft }: Props): JSX.Element { | ||
return ( | ||
<button className="bp-RotateControl" onClick={onRotateLeft} title={__('rotate_left')} type="button"> | ||
<IconRotate24 /> | ||
</button> | ||
); | ||
} |
28 changes: 28 additions & 0 deletions
28
src/lib/viewers/controls/rotate/__tests__/RotateControl-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,28 @@ | ||
import React from 'react'; | ||
import { shallow, ShallowWrapper } from 'enzyme'; | ||
import IconRotate24 from '../../icons/IconRotate24'; | ||
import RotateControl from '../RotateControl'; | ||
|
||
describe('RotateControl', () => { | ||
const getWrapper = (props = {}): ShallowWrapper => shallow(<RotateControl onRotateLeft={jest.fn()} {...props} />); | ||
|
||
describe('event handlers', () => { | ||
test('should invoke onRotateLeft prop on click', () => { | ||
const onRotateLeft = jest.fn(); | ||
const wrapper = getWrapper({ onRotateLeft }); | ||
|
||
wrapper.simulate('click'); | ||
|
||
expect(onRotateLeft).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
describe('render', () => { | ||
test('should return a valid wrapper', () => { | ||
const wrapper = getWrapper(); | ||
|
||
expect(wrapper.hasClass('bp-RotateControl')).toBe(true); | ||
expect(wrapper.exists(IconRotate24)).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './RotateControl'; | ||
export { default } from './RotateControl'; |
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