html-reporter 8.4.4 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +35 -3
  3. package/lib/config/index.js +17 -6
  4. package/lib/constants/defaults.js +2 -1
  5. package/lib/constants/diff-modes.js +32 -0
  6. package/lib/constants/group-tests.js +7 -0
  7. package/lib/constants/plugin-events.js +2 -1
  8. package/lib/server-utils.js +1 -1
  9. package/lib/static/components/bottom-progress-bar/index.js +5 -1
  10. package/lib/static/components/controls/common-controls.js +19 -20
  11. package/lib/static/components/controls/controls.less +0 -31
  12. package/lib/static/components/controls/selects/control.js +51 -0
  13. package/lib/static/components/controls/selects/group-tests.js +94 -0
  14. package/lib/static/components/controls/selects/index.styl +58 -0
  15. package/lib/static/components/{error-groups → group-tests}/item.js +8 -8
  16. package/lib/static/components/group-tests/list.js +71 -0
  17. package/lib/static/components/group-tests/prop-types.js +12 -0
  18. package/lib/static/components/icons/arrows-move.js +24 -0
  19. package/lib/static/components/main-tree.js +5 -5
  20. package/lib/static/components/modals/screenshot-accepter/body.js +4 -12
  21. package/lib/static/components/modals/screenshot-accepter/header.js +3 -32
  22. package/lib/static/components/retry-switcher/item.js +15 -7
  23. package/lib/static/components/section/body/index.js +9 -4
  24. package/lib/static/components/section/title/browser.js +1 -2
  25. package/lib/static/components/state/index.js +2 -9
  26. package/lib/static/components/state/{diff-circle.js → screenshot/diff-circle.js} +1 -1
  27. package/lib/static/components/state/screenshot/full.js +28 -0
  28. package/lib/static/components/state/{screenshot.js → screenshot/resized.js} +28 -30
  29. package/lib/static/components/state/screenshot/with-encode-uri.js +44 -0
  30. package/lib/static/components/state/screenshot/with-synced-scale.js +116 -0
  31. package/lib/static/components/state/state-error.js +3 -3
  32. package/lib/static/components/state/state-fail/index.js +142 -0
  33. package/lib/static/components/state/state-fail/index.styl +31 -0
  34. package/lib/static/components/state/state-fail/onion-skin-diff/index.js +43 -0
  35. package/lib/static/components/state/state-fail/onion-skin-diff/index.styl +19 -0
  36. package/lib/static/components/state/state-fail/prop-types.js +16 -0
  37. package/lib/static/components/state/state-fail/swipe-diff/index.js +138 -0
  38. package/lib/static/components/state/state-fail/swipe-diff/index.styl +82 -0
  39. package/lib/static/components/state/state-fail/switch-diff/index.js +36 -0
  40. package/lib/static/components/state/state-fail/switch-diff/index.styl +12 -0
  41. package/lib/static/components/state/state-success.js +2 -2
  42. package/lib/static/gui.min.css +205 -27
  43. package/lib/static/gui.min.js +16 -16
  44. package/lib/static/modules/action-names.js +9 -5
  45. package/lib/static/modules/actions.js +29 -5
  46. package/lib/static/modules/custom-queries.js +1 -2
  47. package/lib/static/modules/default-state.js +14 -4
  48. package/lib/static/modules/middlewares/local-storage.js +1 -3
  49. package/lib/static/modules/middlewares/metrika.js +10 -13
  50. package/lib/static/modules/reducers/grouped-tests/by/meta.js +31 -0
  51. package/lib/static/modules/reducers/grouped-tests/by/result.js +57 -0
  52. package/lib/static/modules/reducers/grouped-tests/helpers.js +91 -0
  53. package/lib/static/modules/reducers/grouped-tests/index.js +52 -0
  54. package/lib/static/modules/reducers/index.js +2 -2
  55. package/lib/static/modules/reducers/tree/index.js +38 -12
  56. package/lib/static/modules/reducers/tree/nodes/browsers.js +9 -10
  57. package/lib/static/modules/reducers/tree/nodes/results.js +16 -0
  58. package/lib/static/modules/reducers/tree/nodes/suites.js +1 -1
  59. package/lib/static/modules/reducers/view.js +29 -22
  60. package/lib/static/modules/selectors/grouped-tests.js +8 -0
  61. package/lib/static/modules/selectors/view.js +1 -0
  62. package/lib/static/modules/utils.js +19 -1
  63. package/lib/static/report.min.css +205 -27
  64. package/lib/static/report.min.js +16 -16
  65. package/lib/static/styles.css +71 -42
  66. package/lib/test-adapter.js +11 -2
  67. package/package.json +4 -2
  68. package/webpack.common.js +7 -0
  69. package/lib/static/components/controls/view-select.js +0 -50
  70. package/lib/static/components/error-groups/list.js +0 -56
  71. package/lib/static/components/state/state-fail.js +0 -56
  72. package/lib/static/modules/group-errors.js +0 -101
  73. package/lib/static/modules/reducers/grouped-errors.js +0 -43
@@ -0,0 +1,116 @@
1
+ import React, {Component} from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import ResizeObserver from 'rc-resize-observer';
4
+
5
+ export default (WrappedComponent) => class WithSyncedScale extends Component {
6
+ static propTypes = {
7
+ image1: PropTypes.shape({
8
+ size: PropTypes.shape({
9
+ width: PropTypes.number,
10
+ height: PropTypes.number
11
+ })
12
+ }).isRequired,
13
+ image2: PropTypes.shape({
14
+ size: PropTypes.shape({
15
+ width: PropTypes.number,
16
+ height: PropTypes.number
17
+ })
18
+ }).isRequired
19
+ }
20
+
21
+ constructor(props) {
22
+ super(props);
23
+
24
+ const {image1, image2} = props;
25
+
26
+ this._scaleFactor = 1;
27
+ this._shouldScale = image1.size.width !== image2.size.width;
28
+ this._isFirstImageWider = image1.size.width > image2.size.width;
29
+
30
+ this.state = {
31
+ syncedImage1: {
32
+ containerRef: React.createRef(),
33
+ width: image1.size.width
34
+ },
35
+ syncedImage2: {
36
+ containerRef: React.createRef(),
37
+ width: image2.size.width
38
+ },
39
+ resizesNum: 0
40
+ };
41
+ }
42
+
43
+ componentDidMount() {
44
+ this._handleResize();
45
+ }
46
+
47
+ _calcScaleFactor = () => {
48
+ if (!this._shouldScale) {
49
+ return this._scaleFactor;
50
+ }
51
+
52
+ const {image1, image2} = this.props;
53
+ const {syncedImage1, syncedImage2} = this.state;
54
+
55
+ const imgWidth = this._isFirstImageWider ? image1.size.width : image2.size.width;
56
+ const renderedImgWidth = this._isFirstImageWider
57
+ ? this.getRenderedImgWidth(syncedImage1)
58
+ : this.getRenderedImgWidth(syncedImage2);
59
+
60
+ return renderedImgWidth / imgWidth;
61
+ }
62
+
63
+ _getScaledWidth = (image) => {
64
+ if (!this._shouldScale) {
65
+ return image.size.width;
66
+ }
67
+
68
+ const scaledWidth = Math.ceil(image.size.width * this._scaleFactor);
69
+
70
+ return Math.min(scaledWidth, image.size.width);
71
+ }
72
+
73
+ getRenderedImgWidth(syncedImage) {
74
+ return syncedImage.containerRef.current
75
+ ? syncedImage.containerRef.current.offsetWidth
76
+ : syncedImage.width;
77
+ }
78
+
79
+ _handleResize = () => {
80
+ if (!this._shouldScale) {
81
+ return;
82
+ }
83
+
84
+ const {image1, image2} = this.props;
85
+ this._scaleFactor = this._calcScaleFactor();
86
+
87
+ this.setState(prevState => ({
88
+ syncedImage1: {
89
+ ...prevState.syncedImage1,
90
+ width: this._isFirstImageWider ? image1.size.width : this._getScaledWidth(image1)
91
+ },
92
+ syncedImage2: {
93
+ ...prevState.syncedImage2,
94
+ width: this._isFirstImageWider ? this._getScaledWidth(image2) : image2.size.width
95
+ },
96
+ resizesNum: prevState.resizesNum + 1
97
+ }));
98
+ }
99
+
100
+ render() {
101
+ const {syncedImage1, syncedImage2, resizesNum} = this.state;
102
+
103
+ return (
104
+ <ResizeObserver onResize={this._handleResize}>
105
+ <WrappedComponent
106
+ syncedImage1={syncedImage1}
107
+ syncedImage2={syncedImage2}
108
+ resizesNum={resizesNum}
109
+ getRenderedImgWidth={this.getRenderedImgWidth}
110
+
111
+ {...this.props}
112
+ />
113
+ </ResizeObserver>
114
+ );
115
+ }
116
+ };
@@ -7,7 +7,7 @@ import PropTypes from 'prop-types';
7
7
  import {isEmpty, map, isFunction} from 'lodash';
8
8
  import ReactHtmlParser from 'react-html-parser';
9
9
  import * as actions from '../../modules/actions';
10
- import Screenshot from './screenshot';
10
+ import ResizedScreenshot from './screenshot/resized';
11
11
  import {isNoRefImageError, isAssertViewError} from '../../modules/utils';
12
12
  import ErrorDetails from './error-details';
13
13
  import Details from '../details';
@@ -44,10 +44,10 @@ class StateError extends Component {
44
44
  }
45
45
 
46
46
  return isNoRefImageError(error)
47
- ? <Screenshot image={image.actualImg} />
47
+ ? <ResizedScreenshot image={image.actualImg} />
48
48
  : <Details
49
49
  title="Page screenshot"
50
- content={() => <Screenshot image={image.actualImg} />}
50
+ content={() => <ResizedScreenshot image={image.actualImg} />}
51
51
  extendClassNames="details_type_image"
52
52
  onClick={this.onTogglePageScreenshot}
53
53
  />;
@@ -0,0 +1,142 @@
1
+ 'use strict';
2
+
3
+ import React, {Component, Fragment} from 'react';
4
+ import {connect} from 'react-redux';
5
+ import PropTypes from 'prop-types';
6
+ import classNames from 'classnames';
7
+ import ResizedScreenshot from '../screenshot/resized';
8
+ import SwipeDiff from './swipe-diff';
9
+ import SwitchDiff from './switch-diff';
10
+ import OnionSkinDiff from './onion-skin-diff';
11
+ import diffModes from '../../../../constants/diff-modes';
12
+
13
+ import './index.styl';
14
+
15
+ class StateFail extends Component {
16
+ static propTypes = {
17
+ image: PropTypes.shape({
18
+ expectedImg: PropTypes.object.isRequired,
19
+ actualImg: PropTypes.object.isRequired,
20
+ diffImg: PropTypes.object.isRequired,
21
+ diffClusters: PropTypes.array
22
+ }).isRequired,
23
+ // from store
24
+ diffMode: PropTypes.string
25
+ }
26
+
27
+ constructor(props) {
28
+ super(props);
29
+
30
+ this.state = {diffMode: this.props.diffMode};
31
+ }
32
+
33
+ componentWillReceiveProps(nextProps) {
34
+ if (this.state.diffMode !== nextProps.diffMode) {
35
+ this.setState({diffMode: nextProps.diffMode});
36
+ }
37
+ }
38
+
39
+ _handleDiffModeClick = (diffMode) => {
40
+ if (this.state.diffMode === diffMode) {
41
+ return;
42
+ }
43
+
44
+ this.setState({diffMode});
45
+ }
46
+
47
+ _renderDiffModeItems() {
48
+ const diffModeItems = Object.values(diffModes).map((diffMode) => {
49
+ return this._renderDiffModeItem(diffMode);
50
+ });
51
+
52
+ return (
53
+ <ul className="diff-modes">
54
+ {diffModeItems}
55
+ </ul>
56
+ );
57
+ }
58
+
59
+ _renderDiffModeItem(diffMode) {
60
+ const className = classNames(
61
+ 'diff-modes__item',
62
+ {'diff-modes__active': this.state.diffMode === diffMode.id}
63
+ );
64
+
65
+ return <li key={diffMode.id} title={diffMode.description} className={className} onClick={() => this._handleDiffModeClick(diffMode.id)}>{diffMode.title}</li>;
66
+ }
67
+
68
+ _renderImages() {
69
+ const {image: {expectedImg, actualImg}} = this.props;
70
+
71
+ switch (this.state.diffMode) {
72
+ case diffModes.ONLY_DIFF.id:
73
+ return this._renderOnlyDiff();
74
+
75
+ case diffModes.SWITCH.id:
76
+ return <SwitchDiff image1={expectedImg} image2={actualImg} />;
77
+
78
+ case diffModes.SWIPE.id:
79
+ return <SwipeDiff image1={expectedImg} image2={actualImg} />;
80
+
81
+ case diffModes.ONION_SKIN.id:
82
+ return <OnionSkinDiff image1={expectedImg} image2={actualImg} />;
83
+
84
+ case diffModes.THREE_UP_SCALED.id:
85
+ return <div className="image-box__scaled">
86
+ {this._renderThreeImages()}
87
+ </div>;
88
+
89
+ case diffModes.THREE_UP.id:
90
+ default:
91
+ return this._renderThreeImages();
92
+ }
93
+ }
94
+
95
+ _renderOnlyDiff() {
96
+ const {image: {diffImg, diffClusters}} = this.props;
97
+
98
+ return this._drawImageBox(diffImg, {diffClusters});
99
+ }
100
+
101
+ _renderThreeImages() {
102
+ const {image: {expectedImg, actualImg, diffImg, diffClusters}} = this.props;
103
+
104
+ return <Fragment>
105
+ {this._drawExpectedAndActual(expectedImg, actualImg)}
106
+ {this._drawImageBox(diffImg, {label: 'Diff', diffClusters})}
107
+ </Fragment>;
108
+ }
109
+
110
+ render() {
111
+ return (
112
+ <Fragment>
113
+ {this._renderDiffModeItems()}
114
+ {this._renderImages()}
115
+ </Fragment>
116
+ );
117
+ }
118
+
119
+ _drawExpectedAndActual(expectedImg, actualImg) {
120
+ return (
121
+ <Fragment>
122
+ {this._drawImageBox(expectedImg, {label: 'Expected'})}
123
+ {this._drawImageBox(actualImg, {label: 'Actual'})}
124
+ </Fragment>
125
+ );
126
+ }
127
+
128
+ _drawImageBox(image, {label, diffClusters} = {}) {
129
+ const text = `${label} (${image.size.width}x${image.size.height})`;
130
+
131
+ return (
132
+ <div className="image-box__image" style={{flex: image.size.width}}>
133
+ {label && <div className="image-box__title">{text}</div>}
134
+ <ResizedScreenshot image={image} diffClusters={diffClusters}/>
135
+ </div>
136
+ );
137
+ }
138
+ }
139
+
140
+ export default connect(
141
+ ({view: {diffMode}}) => ({diffMode})
142
+ )(StateFail);
@@ -0,0 +1,31 @@
1
+ .diff-modes
2
+ display: flex
3
+ justify-content: center
4
+ border-bottom: 1px solid #ccc
5
+ padding: 5px 0
6
+ margin: 10px auto
7
+ width: 420px
8
+
9
+ &__item
10
+ display: inline-block
11
+ padding: 0 5px
12
+ cursor: pointer
13
+
14
+ &__item:not(:last-child)
15
+ border-right: 1px solid #ccc
16
+
17
+ &__active
18
+ font-weight: bold
19
+
20
+ .image-box__scaled
21
+ display: flex
22
+ flex-flow: row wrap
23
+
24
+ .image-box__image
25
+ padding: 0 5px
26
+
27
+ &:first-child
28
+ padding-left: 0
29
+
30
+ &:last-child
31
+ padding-right: 0
@@ -0,0 +1,43 @@
1
+ import React, {Component} from 'react';
2
+ import FullScreenshot from '../../screenshot/full';
3
+ import withSyncedScale from '../../screenshot/with-synced-scale';
4
+ import {imageType, syncedImageType} from '../prop-types';
5
+
6
+ import './index.styl';
7
+
8
+ const DEFAULT_IMAGE_TRANSPARENCY = 0.5;
9
+
10
+ class OnionSkinDiff extends Component {
11
+ static propTypes = {
12
+ image1: imageType.isRequired,
13
+ image2: imageType.isRequired,
14
+ // from withSyncedScale
15
+ syncedImage1: syncedImageType.isRequired,
16
+ syncedImage2: syncedImageType.isRequired
17
+ }
18
+
19
+ state = {imgTransparency: DEFAULT_IMAGE_TRANSPARENCY}
20
+
21
+ _handleChangeTransparency = (e) => {
22
+ return this.setState({imgTransparency: parseFloat(e.target.value)});
23
+ }
24
+
25
+ render() {
26
+ const {image1, image2, syncedImage1, syncedImage2} = this.props;
27
+ const {imgTransparency} = this.state;
28
+
29
+ return (
30
+ <div className='onion-skin-diff'>
31
+ <div className='onion-skin-diff__img-container'>
32
+ <FullScreenshot className='onion-skin-diff__img' image={image1} imgRef={syncedImage1.containerRef} style={{width: syncedImage1.width}} />
33
+ <FullScreenshot className='onion-skin-diff__img' image={image2} imgRef={syncedImage2.containerRef} style={{width: syncedImage2.width, opacity: imgTransparency}} />
34
+ </div>
35
+ <div className="onion-skin-diff__footer">
36
+ <input className='onion-skin-diff__slider' type="range" min={0} max={1} step={0.01} value={imgTransparency} onChange={this._handleChangeTransparency} />
37
+ </div>
38
+ </div>
39
+ );
40
+ }
41
+ }
42
+
43
+ export default withSyncedScale(OnionSkinDiff);
@@ -0,0 +1,19 @@
1
+ .onion-skin-diff
2
+ &__img-container
3
+ display: grid
4
+ grid-template-areas: 'one one'
5
+ max-width: max-content
6
+
7
+ &__img
8
+ max-width: 100%
9
+ grid-area: one
10
+ border: 1px solid #ccc
11
+
12
+ &__footer
13
+ display: flex
14
+ justify-content: center
15
+
16
+ &__slider
17
+ width: 250px
18
+ margin-top: 10px
19
+ cursor: pointer
@@ -0,0 +1,16 @@
1
+ import PropTypes from 'prop-types';
2
+
3
+ export const imageType = PropTypes.shape({
4
+ path: PropTypes.string.isRequired,
5
+ size: PropTypes.shape({
6
+ width: PropTypes.number,
7
+ height: PropTypes.number
8
+ })
9
+ });
10
+
11
+ export const syncedImageType = PropTypes.shape({
12
+ containerRef: PropTypes.shape({
13
+ current: PropTypes.instanceOf(Element)
14
+ }),
15
+ width: PropTypes.number
16
+ });
@@ -0,0 +1,138 @@
1
+ import React, {Component} from 'react';
2
+ import classNames from 'classnames';
3
+ import PropTypes from 'prop-types';
4
+ import FullScreenshot from '../../screenshot/full';
5
+ import ArrowsMove from '../../../icons/arrows-move';
6
+ import withSyncedScale from '../../screenshot/with-synced-scale';
7
+ import {imageType, syncedImageType} from '../prop-types';
8
+
9
+ import './index.styl';
10
+
11
+ function clamp(n, min = 0, max = 100) {
12
+ return Math.max(Math.min(n, max), min);
13
+ }
14
+
15
+ class SwipeDiff extends Component {
16
+ static propTypes = {
17
+ image1: imageType.isRequired,
18
+ image2: imageType.isRequired,
19
+ // from withSyncedScale
20
+ syncedImage1: syncedImageType.isRequired,
21
+ syncedImage2: syncedImageType.isRequired,
22
+ resizesNum: PropTypes.number.isRequired,
23
+ getRenderedImgWidth: PropTypes.func.isRequired
24
+ }
25
+
26
+ constructor(props) {
27
+ super(props);
28
+
29
+ this._swipeContainer = React.createRef();
30
+ this._swipeContainerLeft = 0;
31
+
32
+ this.state = {
33
+ mousePosX: 0,
34
+ isPressed: false,
35
+ dividerWasMoved: false
36
+ };
37
+ }
38
+
39
+ componentDidMount() {
40
+ this._swipeContainerLeft = this._swipeContainer.current.getBoundingClientRect().left;
41
+
42
+ this.setState({mousePosX: this._getMiddleMousePosX()});
43
+ }
44
+
45
+ componentDidUpdate(prevProps) {
46
+ if (this.state.dividerWasMoved || prevProps.resizesNum === this.props.resizesNum) {
47
+ return;
48
+ }
49
+
50
+ this.setState({mousePosX: this._getMiddleMousePosX()});
51
+ }
52
+
53
+ _getMiddleMousePosX() {
54
+ const {image1, syncedImage1, syncedImage2, getRenderedImgWidth} = this.props;
55
+ const middlePosX = Math.min(getRenderedImgWidth(syncedImage1), getRenderedImgWidth(syncedImage2)) / 2;
56
+
57
+ return clamp(middlePosX, 0, image1.size.width);
58
+ }
59
+
60
+ _getMousePosX(e) {
61
+ const newMousePosX = e.pageX - this._swipeContainerLeft - window.scrollX;
62
+ return clamp(newMousePosX, 0, this.props.syncedImage1.width);
63
+ }
64
+
65
+ _calcImgPosX(width) {
66
+ const imgPosX = this.state.mousePosX / width * 100;
67
+ return clamp(imgPosX, 0, 100);
68
+ }
69
+
70
+ _handleMouseMove = (e) => {
71
+ if (!this.state.isPressed) {
72
+ return;
73
+ }
74
+
75
+ this.setState({mousePosX: this._getMousePosX(e)});
76
+ }
77
+
78
+ _handleMouseDown = (e) => {
79
+ this.setState({mousePosX: this._getMousePosX(e), isPressed: true, dividerWasMoved: true});
80
+
81
+ window.addEventListener('mousemove', this._handleMouseMove);
82
+ window.addEventListener('mouseup', this._handleMouseUp);
83
+
84
+ document.body.classList.add('disable-user-select');
85
+ }
86
+
87
+ _handleMouseUp = () => {
88
+ this.setState({isPressed: false});
89
+ document.body.classList.remove('disable-user-select');
90
+
91
+ window.removeEventListener('mouseup', this._handleMouseUp);
92
+ window.removeEventListener('mousemove', this._handleMouseMove);
93
+ }
94
+
95
+ render() {
96
+ const {image1, image2, syncedImage1, syncedImage2, getRenderedImgWidth} = this.props;
97
+ const {isPressed} = this.state;
98
+
99
+ const maxRenderedWidth = Math.max(getRenderedImgWidth(syncedImage1), getRenderedImgWidth(syncedImage2));
100
+ const img1PosX = 100 - this._calcImgPosX(maxRenderedWidth);
101
+ const img2PosX = this._calcImgPosX(maxRenderedWidth);
102
+
103
+ const className = classNames(
104
+ 'swipe-diff',
105
+ {'swipe-diff_pressed': isPressed}
106
+ );
107
+
108
+ return (
109
+ <div
110
+ className={className}
111
+ style={{'--img1-pos-x': `${img1PosX}%`, '--img2-pos-x': `${img2PosX}%`}}
112
+ ref={this._swipeContainer}
113
+ onMouseDown={this._handleMouseDown}
114
+ >
115
+ <div className='swipe-diff__second'>
116
+ <div className='swipe-diff__frame'>
117
+ <FullScreenshot className='swipe-diff__img' image={image2} imgRef={syncedImage2.containerRef} style={{width: syncedImage2.width}} />
118
+ </div>
119
+ </div>
120
+ <div className="swipe-diff__first">
121
+ <div className="swipe-diff__overlay">
122
+ <div className='swipe-diff__frame'>
123
+ <FullScreenshot className='swipe-diff__img' image={image1} imgRef={syncedImage1.containerRef} style={{width: syncedImage1.width}} />
124
+ </div>
125
+ </div>
126
+ <div className="swipe-diff-divider">
127
+ <div className="swipe-diff-divider__line"></div>
128
+ <div className="swipe-diff-divider__arrows">
129
+ <ArrowsMove />
130
+ </div>
131
+ </div>
132
+ </div>
133
+ </div>
134
+ );
135
+ }
136
+ }
137
+
138
+ export default withSyncedScale(SwipeDiff);
@@ -0,0 +1,82 @@
1
+ .swipe-diff
2
+ display: grid
3
+ grid-template-areas: 'one one'
4
+ max-width: max-content
5
+ overflow: hidden
6
+ cursor: move
7
+
8
+ &_pressed .swipe-diff-divider__arrows
9
+ opacity: 0
10
+
11
+ &__overlay
12
+ overflow: hidden
13
+
14
+ &__img
15
+ max-width: 100%
16
+ pointer-events: none
17
+ user-select: none
18
+ border: 1px solid #ccc
19
+
20
+ &__first
21
+ grid-area: one
22
+ line-height: 0
23
+ transform: translateX(calc(var(--img1-pos-x) * -1))
24
+
25
+ .swipe-diff__frame
26
+ transform: translateX(var(--img1-pos-x))
27
+
28
+ &__second
29
+ line-height: 0
30
+ grid-area: one
31
+ transform: translateX(var(--img2-pos-x))
32
+ overflow: hidden
33
+
34
+ .swipe-diff__frame
35
+ transform: translateX(calc(var(--img2-pos-x) * -1))
36
+
37
+ &-divider
38
+ transform: translateX(50%)
39
+ position: absolute
40
+ height: 100%
41
+ top: 0
42
+ right: 0
43
+ display: flex
44
+ align-items: flex-end
45
+ justify-content: center
46
+ flex-direction: column
47
+
48
+ &__line
49
+ position: absolute
50
+ height: 100%
51
+ width: 100%
52
+ left: 0
53
+ top: 0
54
+ display: flex
55
+ align-items: center
56
+ justify-content: center
57
+ flex-direction: column
58
+
59
+ &:after
60
+ content: ''
61
+ display: block
62
+ height: 100%
63
+ border-left-width: 1px
64
+ border-left-style: solid
65
+ border-left-color: black
66
+
67
+ &__arrows
68
+ pointer-events: none
69
+ box-sizing: border-box
70
+ margin-left: 1px
71
+ transform: translateX(-0.5px)
72
+ opacity: 1
73
+ transition: opacity 500ms
74
+
75
+ .arrows-move
76
+ width: 60px
77
+
78
+ &__icon
79
+ stroke: black
80
+
81
+ .disable-user-select
82
+ user-select: none
@@ -0,0 +1,36 @@
1
+ import React, {Component} from 'react';
2
+ import FullScreenshot from '../../screenshot/full';
3
+ import withSyncedScale from '../../screenshot/with-synced-scale';
4
+ import {imageType, syncedImageType} from '../prop-types';
5
+
6
+ import './index.styl';
7
+
8
+ class SwitchDiff extends Component {
9
+ static propTypes = {
10
+ image1: imageType.isRequired,
11
+ image2: imageType.isRequired,
12
+ // from withSyncedScale
13
+ syncedImage1: syncedImageType.isRequired,
14
+ syncedImage2: syncedImageType.isRequired
15
+ }
16
+
17
+ state = {showFirst: true}
18
+
19
+ _handleClick = () => this.setState({showFirst: !this.state.showFirst})
20
+
21
+ render() {
22
+ const {image1, image2, syncedImage1, syncedImage2} = this.props;
23
+ const {showFirst} = this.state;
24
+ const displayImage1 = showFirst ? 'visible' : 'hidden';
25
+ const displayImage2 = !showFirst ? 'visible' : 'hidden';
26
+
27
+ return (
28
+ <div className={'switch-diff'} onClick={this._handleClick} >
29
+ <FullScreenshot className='switch-diff__img' image={image1} imgRef={syncedImage1.containerRef} style={{width: syncedImage1.width, visibility: displayImage1}} />
30
+ <FullScreenshot className='switch-diff__img' image={image2} imgRef={syncedImage2.containerRef} style={{width: syncedImage2.width, visibility: displayImage2}} />
31
+ </div>
32
+ );
33
+ }
34
+ }
35
+
36
+ export default withSyncedScale(SwitchDiff);
@@ -0,0 +1,12 @@
1
+ .switch-diff
2
+ display: grid
3
+ grid-template-areas: 'one one'
4
+ max-width: max-content
5
+ cursor: pointer
6
+
7
+ &__img
8
+ grid-area: one
9
+ max-width: 100%
10
+ pointer-events: none
11
+ user-select: none
12
+ border: 1px solid #ccc
@@ -2,7 +2,7 @@
2
2
 
3
3
  import React, {Component} from 'react';
4
4
  import PropTypes from 'prop-types';
5
- import Screenshot from './screenshot';
5
+ import ResizedScreenshot from './screenshot/resized';
6
6
  import {isUpdatedStatus} from '../../../common-utils';
7
7
 
8
8
  export default class StateSuccess extends Component {
@@ -16,7 +16,7 @@ export default class StateSuccess extends Component {
16
16
 
17
17
  return (
18
18
  <div className="image-box__image">
19
- <Screenshot noCache={isUpdatedStatus(status)} image={expectedImg}/>
19
+ <ResizedScreenshot noCache={isUpdatedStatus(status)} image={expectedImg}/>
20
20
  </div>
21
21
  );
22
22
  }