-
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 versions of text viewer controls (#1284)
- Loading branch information
Showing
15 changed files
with
220 additions
and
10 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 @@ | ||
export { default } from './controls-root'; |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
@import './Text'; | ||
@import './PlainText'; | ||
|
||
// Overrides pre-wrap from plain text | ||
.markdown-body { | ||
|
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,13 @@ | ||
import React from 'react'; | ||
import ControlsBar from '../controls/controls-bar'; | ||
import FullscreenToggle, { Props as FullscreenToggleProps } from '../controls/fullscreen'; | ||
|
||
export type Props = FullscreenToggleProps; | ||
|
||
export default function MarkdownControls({ onFullscreenToggle }: Props): JSX.Element { | ||
return ( | ||
<ControlsBar> | ||
<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
File renamed without changes.
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,28 @@ | ||
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 TextControls({ | ||
maxScale, | ||
minScale, | ||
onFullscreenToggle, | ||
onZoomIn, | ||
onZoomOut, | ||
scale, | ||
}: Props): JSX.Element { | ||
return ( | ||
<ControlsBar> | ||
<ZoomControls | ||
maxScale={maxScale} | ||
minScale={minScale} | ||
onZoomIn={onZoomIn} | ||
onZoomOut={onZoomOut} | ||
scale={scale} | ||
/> | ||
<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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import ControlsBar from '../../controls/controls-bar'; | ||
import FullscreenToggle from '../../controls/fullscreen'; | ||
import MarkdownControls from '../MarkdownControls'; | ||
|
||
describe('MarkdownControls', () => { | ||
describe('render', () => { | ||
test('should return a valid wrapper', () => { | ||
const onToggle = jest.fn(); | ||
const wrapper = shallow(<MarkdownControls onFullscreenToggle={onToggle} />); | ||
|
||
expect(wrapper.exists(ControlsBar)); | ||
expect(wrapper.find(FullscreenToggle).prop('onFullscreenToggle')).toEqual(onToggle); | ||
}); | ||
}); | ||
}); |
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
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 TextControls from '../TextControls'; | ||
import ZoomControls from '../../controls/zoom'; | ||
|
||
describe('TextControls', () => { | ||
describe('render', () => { | ||
test('should return a valid wrapper', () => { | ||
const onToggle = jest.fn(); | ||
const onZoomIn = jest.fn(); | ||
const onZoomOut = jest.fn(); | ||
const wrapper = shallow( | ||
<TextControls 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); | ||
}); | ||
}); | ||
}); |