-
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): Add React controls for Image360 (#1388)
- Loading branch information
Conrad Chan
authored
May 25, 2021
1 parent
9604879
commit 09fadfa
Showing
6 changed files
with
222 additions
and
5 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
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 ControlsBar from '../../controls/controls-bar'; | ||
import FullscreenToggle, { Props as FullscreenToggleProps } from '../../controls/fullscreen'; | ||
import VrToggleControl, { Props as VrToggleConrolProps } from '../../controls/box3d/VrToggleControl'; | ||
|
||
export type Props = FullscreenToggleProps & VrToggleConrolProps; | ||
|
||
export default function Image360Controls({ isVrShown, onFullscreenToggle, onVrToggle }: Props): JSX.Element { | ||
return ( | ||
<ControlsBar> | ||
<FullscreenToggle onFullscreenToggle={onFullscreenToggle} /> | ||
<VrToggleControl isVrShown={isVrShown} onVrToggle={onVrToggle} /> | ||
</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
34 changes: 34 additions & 0 deletions
34
src/lib/viewers/box3d/image360/__tests__/Image360Controls-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,34 @@ | ||
import React from 'react'; | ||
import { shallow, ShallowWrapper } from 'enzyme'; | ||
import FullscreenToggle from '../../../controls/fullscreen'; | ||
import Image360Controls, { Props } from '../Image360Controls'; | ||
import VrToggleControl from '../../../controls/box3d/VrToggleControl'; | ||
|
||
describe('lib/viewers/box3d/image360/Image360Controls', () => { | ||
const getDefaults = (): Props => ({ | ||
isVrShown: false, | ||
onFullscreenToggle: jest.fn(), | ||
onVrToggle: jest.fn(), | ||
}); | ||
|
||
const getWrapper = (props: Partial<Props>): ShallowWrapper => | ||
shallow(<Image360Controls {...getDefaults()} {...props} />); | ||
|
||
describe('render()', () => { | ||
test('should return a valid wrapper', () => { | ||
const onFullscreenToggle = jest.fn(); | ||
const onVrToggle = jest.fn(); | ||
|
||
const wrapper = getWrapper({ | ||
onFullscreenToggle, | ||
onVrToggle, | ||
}); | ||
|
||
expect(wrapper.find(VrToggleControl).props()).toMatchObject({ | ||
isVrShown: false, | ||
onVrToggle, | ||
}); | ||
expect(wrapper.find(FullscreenToggle).prop('onFullscreenToggle')).toEqual(onFullscreenToggle); | ||
}); | ||
}); | ||
}); |
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