-
Notifications
You must be signed in to change notification settings - Fork 0
/
stage.jsx
167 lines (161 loc) · 6.81 KB
/
stage.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import Box from '../box/box.jsx';
import DOMElementRenderer from '../../containers/dom-element-renderer.jsx';
import Loupe from '../loupe/loupe.jsx';
import MonitorList from '../../containers/monitor-list.jsx';
import TargetHighlight from '../../containers/target-highlight.jsx';
import GreenFlagOverlay from '../../containers/green-flag-overlay.jsx';
import Question from '../../containers/question.jsx';
import MicIndicator from '../mic-indicator/mic-indicator.jsx';
import {STAGE_DISPLAY_SIZES} from '../../lib/layout-constants.js';
import {getStageDimensions} from '../../lib/screen-utils.js';
import styles from './stage.css';
const StageComponent = props => {
const {
canvas,
dragRef,
isColorPicking,
isFullScreen,
isStarted,
colorInfo,
micIndicator,
question,
stageSize,
useEditorDragStyle,
onDeactivateColorPicker,
onDoubleClick,
onQuestionAnswered,
...boxProps
} = props;
const stageDimensions = getStageDimensions(stageSize, isFullScreen);
return (
<React.Fragment>
<Box
className={classNames(
styles.stageWrapper,
{[styles.withColorPicker]: !isFullScreen && isColorPicking})}
onDoubleClick={onDoubleClick}
>
<Box
className={classNames(
styles.stage,
{[styles.fullScreen]: isFullScreen}
)}
style={{
height: stageDimensions.height,
width: stageDimensions.width
}}
>
<div
className={classNames(
styles.stageContainer,
// 下面这行决定了出现颜色选择器时的高亮位置
{[styles.withColorPicker]: !isFullScreen && isColorPicking},
)}
>
<DOMElementRenderer
domElement={canvas}
// style={{
// height: stageDimensions.height,
// width: stageDimensions.width
// }}
{...boxProps}
/>
<Box className={styles.monitorWrapper}>
<MonitorList
draggable={useEditorDragStyle}
stageSize={stageDimensions}
/>
</Box>
{/* TODO: 高亮的逻辑,如果用目前多个屏幕尺寸的方案,有问题,先隐藏 */}
{/* ![](http://res.watermcc.top/blog/2022/20220929-1664437207.png)
![](http://res.watermcc.top/blog/2022/20220929-1664437223.png)
![](http://res.watermcc.top/blog/2022/20220929-1664437238.png) */}
{/* <Box className={styles.frameWrapper}>
<TargetHighlight
className={styles.frame}
stageHeight={stageDimensions.height}
stageWidth={stageDimensions.width}
/>
</Box> */}
{isColorPicking && colorInfo ? (
<Loupe colorInfo={colorInfo} />
) : null}
{/* `stageOverlays` is for items that should *not* have their overflow contained within the stage */}
<Box
className={classNames(
styles.stageOverlays,
{[styles.fullScreen]: isFullScreen}
)}
>
<div
className={styles.stageBottomWrapper}
// style={{
// width: stageDimensions.width,
// height: stageDimensions.height
// }}
>
{micIndicator ? (
<MicIndicator
className={styles.micIndicator}
// stageSize={stageDimensions}
/>
) : null}
{question === null ? null : (
<div
className={styles.questionWrapper}
// style={{width: stageDimensions.width}}
>
<Question
question={question}
onQuestionAnswered={onQuestionAnswered}
/>
</div>
)}
</div>
<canvas
className={styles.draggingSprite}
height={0}
ref={dragRef}
width={0}
/>
</Box>
</div>
</Box>
{isStarted ? null : (
<GreenFlagOverlay
className={styles.greenFlagOverlay}
wrapperClass={styles.greenFlagOverlayWrapper}
/>
)}
</Box>
{isColorPicking ? (
<Box
className={styles.colorPickerBackground}
onClick={onDeactivateColorPicker}
/>
) : null}
</React.Fragment>
);
};
StageComponent.propTypes = {
canvas: PropTypes.instanceOf(Element).isRequired,
colorInfo: Loupe.propTypes.colorInfo,
dragRef: PropTypes.func,
isColorPicking: PropTypes.bool,
isFullScreen: PropTypes.bool.isRequired,
isStarted: PropTypes.bool,
micIndicator: PropTypes.bool,
onDeactivateColorPicker: PropTypes.func,
onDoubleClick: PropTypes.func,
onQuestionAnswered: PropTypes.func,
question: PropTypes.string,
stageSize: PropTypes.oneOf(Object.keys(STAGE_DISPLAY_SIZES)).isRequired,
useEditorDragStyle: PropTypes.bool,
};
StageComponent.defaultProps = {
dragRef: () => {}
};
export default StageComponent;