@pie-element/drawing-response 3.9.9 → 3.9.10-beta.1443
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.
- package/CHANGELOG.md +370 -0
- package/configure/CHANGELOG.md +355 -0
- package/configure/lib/button.js.map +1 -1
- package/configure/lib/defaults.js +21 -2
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/image-container.js +37 -21
- package/configure/lib/image-container.js.map +1 -1
- package/configure/lib/index.js +64 -11
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/root.js +65 -30
- package/configure/lib/root.js.map +1 -1
- package/configure/package.json +4 -4
- package/configure/src/__tests__/__snapshots__/image-container.test.jsx.snap +3 -2
- package/configure/src/__tests__/__snapshots__/root.test.jsx.snap +34 -14
- package/configure/src/__tests__/image-container.test.jsx +42 -35
- package/configure/src/__tests__/index.test.js +7 -7
- package/configure/src/__tests__/root.test.jsx +18 -18
- package/configure/src/button.jsx +4 -4
- package/configure/src/defaults.js +24 -5
- package/configure/src/image-container.jsx +80 -59
- package/configure/src/index.js +46 -14
- package/configure/src/root.jsx +71 -63
- package/controller/CHANGELOG.md +20 -0
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +13 -7
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/controller/src/__tests__/index.test.js +29 -19
- package/controller/src/defaults.js +2 -2
- package/controller/src/index.js +13 -14
- package/docs/config-schema.json +126 -0
- package/docs/config-schema.json.md +97 -1
- package/docs/demo/config.js +2 -2
- package/docs/demo/generate.js +4 -2
- package/docs/demo/session.js +4 -4
- package/docs/pie-schema.json +60 -0
- package/docs/pie-schema.json.md +44 -0
- package/lib/drawing-response/button.js.map +1 -1
- package/lib/drawing-response/constants.js.map +1 -1
- package/lib/drawing-response/container.js +73 -22
- package/lib/drawing-response/container.js.map +1 -1
- package/lib/drawing-response/drawable-image.js +1 -0
- package/lib/drawing-response/drawable-image.js.map +1 -1
- package/lib/drawing-response/drawable-main.js +45 -15
- package/lib/drawing-response/drawable-main.js.map +1 -1
- package/lib/drawing-response/drawable-palette.js +6 -1
- package/lib/drawing-response/drawable-palette.js.map +1 -1
- package/lib/drawing-response/drawable-text.js +15 -5
- package/lib/drawing-response/drawable-text.js.map +1 -1
- package/lib/drawing-response/drawable-transformer.js.map +1 -1
- package/lib/drawing-response/factory.js.map +1 -1
- package/lib/drawing-response/icon.js.map +1 -1
- package/lib/drawing-response/index.js +3 -0
- package/lib/drawing-response/index.js.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/src/__tests__/drawing-index-test.jsx +4 -4
- package/src/drawing-response/__tests__/__snapshots__/container.test.jsx.snap +174 -290
- package/src/drawing-response/__tests__/__snapshots__/drawing-main.test.jsx.snap +26 -2
- package/src/drawing-response/__tests__/container.test.jsx +9 -2
- package/src/drawing-response/__tests__/drawable-helper.test.jsx +1 -1
- package/src/drawing-response/__tests__/drawing-main.test.jsx +74 -86
- package/src/drawing-response/button.jsx +5 -8
- package/src/drawing-response/constants.js +42 -34
- package/src/drawing-response/container.jsx +93 -70
- package/src/drawing-response/drawable-image.jsx +5 -4
- package/src/drawing-response/drawable-main.jsx +46 -17
- package/src/drawing-response/drawable-palette.jsx +18 -35
- package/src/drawing-response/drawable-text.jsx +34 -48
- package/src/drawing-response/drawable-transformer.jsx +3 -1
- package/src/drawing-response/factory.js +3 -11
- package/src/drawing-response/icon.jsx +19 -20
- package/src/drawing-response/index.jsx +9 -15
- package/src/index.js +8 -11
|
@@ -11,16 +11,10 @@ import Icon from './icon';
|
|
|
11
11
|
|
|
12
12
|
const { tools: TOOLS } = constants;
|
|
13
13
|
|
|
14
|
-
const ROGVAIV = [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
'violet',
|
|
19
|
-
'blue',
|
|
20
|
-
'green',
|
|
21
|
-
'white',
|
|
22
|
-
'black'
|
|
23
|
-
].map(c => ({ value: c, label: c }));
|
|
14
|
+
const ROGVAIV = ['red', 'orange', 'yellow', 'violet', 'blue', 'green', 'white', 'black'].map((c) => ({
|
|
15
|
+
value: c,
|
|
16
|
+
label: c,
|
|
17
|
+
}));
|
|
24
18
|
|
|
25
19
|
export class Container extends Component {
|
|
26
20
|
static propTypes = {
|
|
@@ -29,7 +23,8 @@ export class Container extends Component {
|
|
|
29
23
|
session: PropTypes.object.isRequired,
|
|
30
24
|
onSessionChange: PropTypes.func.isRequired,
|
|
31
25
|
imageDimensions: PropTypes.object.isRequired,
|
|
32
|
-
imageUrl: PropTypes.string.isRequired
|
|
26
|
+
imageUrl: PropTypes.string.isRequired,
|
|
27
|
+
backgroundImageEnabled: PropTypes.bool.isRequired,
|
|
33
28
|
};
|
|
34
29
|
|
|
35
30
|
constructor(props) {
|
|
@@ -37,23 +32,24 @@ export class Container extends Component {
|
|
|
37
32
|
const TextEntry = new DrawableText();
|
|
38
33
|
|
|
39
34
|
this.state = {
|
|
35
|
+
scale: 1,
|
|
40
36
|
drawableDimensions: {
|
|
41
37
|
height: 0,
|
|
42
|
-
width: 0
|
|
38
|
+
width: 0,
|
|
43
39
|
},
|
|
44
40
|
toolActive: TOOLS[0],
|
|
45
41
|
fillColor: 'white',
|
|
46
42
|
fillColorList: [
|
|
47
43
|
{ value: 'transparent', label: 'no fill' },
|
|
48
|
-
{ value: 'lightblue', label: '
|
|
49
|
-
{ value: 'lightyellow', label: '
|
|
50
|
-
...ROGVAIV
|
|
44
|
+
{ value: 'lightblue', label: 'light blue' },
|
|
45
|
+
{ value: 'lightyellow', label: 'light yellow' },
|
|
46
|
+
...ROGVAIV,
|
|
51
47
|
],
|
|
52
48
|
outlineColor: 'black',
|
|
53
49
|
outlineColorList: ROGVAIV,
|
|
54
50
|
paintColor: 'red',
|
|
55
51
|
paintColorList: ROGVAIV,
|
|
56
|
-
TextEntry
|
|
52
|
+
TextEntry,
|
|
57
53
|
};
|
|
58
54
|
}
|
|
59
55
|
|
|
@@ -65,8 +61,8 @@ export class Container extends Component {
|
|
|
65
61
|
this.setState({
|
|
66
62
|
drawableDimensions: {
|
|
67
63
|
height,
|
|
68
|
-
width
|
|
69
|
-
}
|
|
64
|
+
width,
|
|
65
|
+
},
|
|
70
66
|
});
|
|
71
67
|
}
|
|
72
68
|
} catch (e) {
|
|
@@ -80,12 +76,39 @@ export class Container extends Component {
|
|
|
80
76
|
|
|
81
77
|
componentDidMount() {
|
|
82
78
|
this.setDimensions();
|
|
79
|
+
|
|
80
|
+
this.observer = new MutationObserver((mutations) => {
|
|
81
|
+
mutations.forEach(() => {
|
|
82
|
+
const target = document.getElementById('question-container')?.style?.cssText;
|
|
83
|
+
const zoom = target?.substring(target.indexOf('--pie-zoom') + 11, target.lastIndexOf('%'));
|
|
84
|
+
const zoomParsed = zoom?.replace(/\s/g, '');
|
|
85
|
+
|
|
86
|
+
if (zoomParsed) {
|
|
87
|
+
const newScale = parseFloat(zoomParsed) / 100;
|
|
88
|
+
if (newScale !== this.state.scale) {
|
|
89
|
+
this.setState({
|
|
90
|
+
scale: parseFloat(zoomParsed) / 100,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
} else if (!zoomParsed && this.state.scale !== 1) {
|
|
94
|
+
this.setState({
|
|
95
|
+
scale: 1,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const target = document.getElementById('question-container');
|
|
102
|
+
if (target) {
|
|
103
|
+
this.observer.observe(target, { attributes: true, attributeFilter: ['style'] });
|
|
104
|
+
}
|
|
83
105
|
}
|
|
84
106
|
|
|
85
107
|
componentWillUnmount() {
|
|
86
108
|
const { TextEntry } = this.state;
|
|
87
109
|
|
|
88
110
|
TextEntry.removeEventListeners();
|
|
111
|
+
this.observer?.disconnect();
|
|
89
112
|
}
|
|
90
113
|
|
|
91
114
|
handleMakeToolActive(tool) {
|
|
@@ -94,21 +117,20 @@ export class Container extends Component {
|
|
|
94
117
|
|
|
95
118
|
if (type !== 'Text') {
|
|
96
119
|
this.setState({
|
|
97
|
-
toolActive: tool
|
|
120
|
+
toolActive: tool,
|
|
98
121
|
});
|
|
99
122
|
} else {
|
|
100
123
|
TextEntry.addNewTextEntry();
|
|
101
124
|
// Force update
|
|
102
125
|
this.setState({
|
|
103
|
-
updatedAt: new Date()
|
|
126
|
+
updatedAt: new Date(),
|
|
104
127
|
});
|
|
105
128
|
}
|
|
106
129
|
}
|
|
107
130
|
|
|
108
|
-
checkIfToolIsDisabled = type => {
|
|
131
|
+
checkIfToolIsDisabled = (type) => {
|
|
109
132
|
if (this.props.disabled) return true;
|
|
110
133
|
|
|
111
|
-
|
|
112
134
|
const { toolActive } = this.state;
|
|
113
135
|
// Text will never be disabled since on each "Text Entry" click a new text is added
|
|
114
136
|
if (type === 'Text') {
|
|
@@ -120,19 +142,13 @@ export class Container extends Component {
|
|
|
120
142
|
handleColorChange(type, color) {
|
|
121
143
|
const cType = `${type}Color`;
|
|
122
144
|
this.setState({
|
|
123
|
-
[cType]: color
|
|
145
|
+
[cType]: color,
|
|
124
146
|
});
|
|
125
147
|
}
|
|
126
148
|
|
|
127
149
|
render() {
|
|
128
|
-
const {
|
|
129
|
-
|
|
130
|
-
disabled,
|
|
131
|
-
imageUrl,
|
|
132
|
-
imageDimensions,
|
|
133
|
-
onSessionChange,
|
|
134
|
-
session
|
|
135
|
-
} = this.props;
|
|
150
|
+
const { classes, disabled, imageUrl, imageDimensions, onSessionChange, session, backgroundImageEnabled } =
|
|
151
|
+
this.props;
|
|
136
152
|
const {
|
|
137
153
|
drawableDimensions,
|
|
138
154
|
toolActive,
|
|
@@ -142,51 +158,53 @@ export class Container extends Component {
|
|
|
142
158
|
outlineColorList,
|
|
143
159
|
paintColor,
|
|
144
160
|
paintColorList,
|
|
145
|
-
TextEntry
|
|
161
|
+
TextEntry,
|
|
146
162
|
} = this.state;
|
|
147
163
|
|
|
164
|
+
const heightToUse = drawableDimensions.height * this.state.scale;
|
|
165
|
+
|
|
148
166
|
return (
|
|
149
167
|
<div className={classes.base}>
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
this.handleColorChange('outline', color)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
168
|
+
{!disabled && (
|
|
169
|
+
<DrawablePalette
|
|
170
|
+
fillColor={fillColor}
|
|
171
|
+
fillList={fillColorList}
|
|
172
|
+
outlineColor={outlineColor}
|
|
173
|
+
outlineList={outlineColorList}
|
|
174
|
+
paintColor={paintColor}
|
|
175
|
+
paintList={paintColorList}
|
|
176
|
+
onFillColorChange={(color) => this.handleColorChange('fill', color)}
|
|
177
|
+
onOutlineColorChange={(color) => this.handleColorChange('outline', color)}
|
|
178
|
+
onPaintColorChange={(color) => this.handleColorChange('paint', color)}
|
|
179
|
+
/>
|
|
180
|
+
)}
|
|
163
181
|
|
|
164
182
|
<div className={classes.box}>
|
|
165
183
|
<div className={classes.toolbar}>
|
|
166
|
-
|
|
167
|
-
{
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
})}
|
|
180
|
-
</div>
|
|
184
|
+
{TOOLS.map((tool) => {
|
|
185
|
+
const { type, label, icon } = tool;
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<Button
|
|
189
|
+
title={label}
|
|
190
|
+
key={type}
|
|
191
|
+
disabled={this.checkIfToolIsDisabled(type)}
|
|
192
|
+
onClick={() => this.handleMakeToolActive(tool)}
|
|
193
|
+
label={<Icon path={icon} />}
|
|
194
|
+
/>
|
|
195
|
+
);
|
|
196
|
+
})}
|
|
181
197
|
</div>
|
|
182
198
|
|
|
183
199
|
<div
|
|
184
|
-
ref={drawable => {
|
|
200
|
+
ref={(drawable) => {
|
|
185
201
|
this.drawable = drawable;
|
|
186
202
|
}}
|
|
187
203
|
className={classes.drawableHeight}
|
|
204
|
+
style={{ height: heightToUse, maxHeight: heightToUse }}
|
|
188
205
|
>
|
|
189
206
|
<DrawableMain
|
|
207
|
+
scale={this.state.scale}
|
|
190
208
|
session={session}
|
|
191
209
|
disabled={disabled}
|
|
192
210
|
onSessionChange={onSessionChange}
|
|
@@ -198,6 +216,7 @@ export class Container extends Component {
|
|
|
198
216
|
imageDimensions={imageDimensions}
|
|
199
217
|
toolActive={toolActive}
|
|
200
218
|
TextEntry={TextEntry}
|
|
219
|
+
backgroundImageEnabled={backgroundImageEnabled}
|
|
201
220
|
/>
|
|
202
221
|
</div>
|
|
203
222
|
</div>
|
|
@@ -206,27 +225,31 @@ export class Container extends Component {
|
|
|
206
225
|
}
|
|
207
226
|
}
|
|
208
227
|
|
|
209
|
-
const styles = theme => ({
|
|
228
|
+
const styles = (theme) => ({
|
|
210
229
|
base: {
|
|
211
|
-
marginTop: theme.spacing.unit * 2
|
|
230
|
+
marginTop: theme.spacing.unit * 2,
|
|
212
231
|
},
|
|
213
232
|
box: {
|
|
214
233
|
border: '1px solid #E0E1E6',
|
|
215
234
|
borderRadius: '5px',
|
|
216
|
-
marginTop: theme.spacing.unit * 2
|
|
235
|
+
marginTop: theme.spacing.unit * 2,
|
|
236
|
+
backgroundColor: '#ECEDF1',
|
|
217
237
|
},
|
|
218
238
|
drawableHeight: {
|
|
219
|
-
minHeight: 350
|
|
239
|
+
minHeight: 350,
|
|
240
|
+
backgroundColor: '#fff',
|
|
220
241
|
},
|
|
221
242
|
toolbar: {
|
|
222
|
-
backgroundColor: '#ECEDF1',
|
|
223
243
|
borderBottom: '1px solid #E0E1E6',
|
|
224
244
|
borderTopLeftRadius: '5px',
|
|
225
245
|
borderTopRightRadius: '5px',
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
246
|
+
padding: '12px 8px 4px',
|
|
247
|
+
boxSizing: 'border-box',
|
|
248
|
+
maxWidth: 'calc(100% - 163px)', // 163px is the width set on undoControls
|
|
249
|
+
'& button': {
|
|
250
|
+
marginBottom: '8px',
|
|
251
|
+
},
|
|
252
|
+
},
|
|
230
253
|
});
|
|
231
254
|
|
|
232
255
|
export default withStyles(styles)(Container);
|
|
@@ -5,6 +5,7 @@ import { withStyles } from '@material-ui/core/styles';
|
|
|
5
5
|
const DrawableImage = ({ classes, url, dimensions: { height, width } }) => (
|
|
6
6
|
<div className={classes.imageContainer}>
|
|
7
7
|
<img
|
|
8
|
+
alt="drawing-response-image"
|
|
8
9
|
className={classes.image}
|
|
9
10
|
src={url}
|
|
10
11
|
style={{
|
|
@@ -21,18 +22,18 @@ const styles = () => ({
|
|
|
21
22
|
image: {
|
|
22
23
|
alignItems: 'center',
|
|
23
24
|
display: 'flex',
|
|
24
|
-
justifyContent: 'center'
|
|
25
|
+
justifyContent: 'center',
|
|
25
26
|
},
|
|
26
27
|
imageContainer: {
|
|
27
28
|
position: 'relative',
|
|
28
|
-
width: 'fit-content'
|
|
29
|
-
}
|
|
29
|
+
width: 'fit-content',
|
|
30
|
+
},
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
DrawableImage.propTypes = {
|
|
33
34
|
classes: PropTypes.object.isRequired,
|
|
34
35
|
dimensions: PropTypes.object.isRequired,
|
|
35
|
-
url:PropTypes.string.isRequired
|
|
36
|
+
url: PropTypes.string.isRequired,
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
export default withStyles(styles)(DrawableImage);
|
|
@@ -89,14 +89,18 @@ export class DrawableMain extends React.Component {
|
|
|
89
89
|
onMouseOutElement = () => this.setState({ isOver: false });
|
|
90
90
|
|
|
91
91
|
handleMouseDown = e => {
|
|
92
|
+
// ONLY IF MOBILE?
|
|
93
|
+
document.body.style.overflow = 'hidden';
|
|
94
|
+
|
|
92
95
|
const { newDrawable, textIsSelected } = this.state;
|
|
93
|
-
const { toolActive, fillColor, outlineColor } = this.props;
|
|
96
|
+
const { toolActive, fillColor, outlineColor, scale } = this.props;
|
|
94
97
|
|
|
95
98
|
if (newDrawable.length === 0 && !textIsSelected) {
|
|
96
99
|
const { x, y } = e.target.getStage().getPointerPosition();
|
|
100
|
+
|
|
97
101
|
const newDrawable = factory(toolActive.type, {
|
|
98
|
-
startx: x,
|
|
99
|
-
starty: y,
|
|
102
|
+
startx: x / scale,
|
|
103
|
+
starty: y / scale,
|
|
100
104
|
fillColor,
|
|
101
105
|
outlineColor,
|
|
102
106
|
createdAt: new Date()
|
|
@@ -109,13 +113,17 @@ export class DrawableMain extends React.Component {
|
|
|
109
113
|
};
|
|
110
114
|
|
|
111
115
|
handleMouseUp = e => {
|
|
116
|
+
// ONLY IF MOBILE?
|
|
117
|
+
document.body.style.overflow = 'initial';
|
|
118
|
+
|
|
112
119
|
const { newDrawable, drawables } = this.state;
|
|
120
|
+
const { scale } = this.props;
|
|
113
121
|
|
|
114
122
|
if (newDrawable.length === 1) {
|
|
115
123
|
const { x, y } = e.target.getStage().getPointerPosition();
|
|
116
124
|
const drawableToAdd = newDrawable[0];
|
|
117
125
|
|
|
118
|
-
drawableToAdd.registerMovement(x, y);
|
|
126
|
+
drawableToAdd.registerMovement(x / scale, y / scale);
|
|
119
127
|
drawables.push(drawableToAdd);
|
|
120
128
|
|
|
121
129
|
this.setState(
|
|
@@ -130,12 +138,13 @@ export class DrawableMain extends React.Component {
|
|
|
130
138
|
|
|
131
139
|
handleMouseMove = e => {
|
|
132
140
|
const { newDrawable } = this.state;
|
|
141
|
+
const { scale } = this.props;
|
|
133
142
|
|
|
134
143
|
if (newDrawable.length === 1) {
|
|
135
144
|
const { x, y } = e.target.getStage().getPointerPosition();
|
|
136
145
|
const updatedNewDrawable = newDrawable[0];
|
|
137
146
|
|
|
138
|
-
updatedNewDrawable.registerMovement(x, y);
|
|
147
|
+
updatedNewDrawable.registerMovement(x / scale, y / scale);
|
|
139
148
|
|
|
140
149
|
this.setState({
|
|
141
150
|
newDrawable: [updatedNewDrawable]
|
|
@@ -185,7 +194,9 @@ export class DrawableMain extends React.Component {
|
|
|
185
194
|
paintColor,
|
|
186
195
|
outlineColor,
|
|
187
196
|
TextEntry,
|
|
188
|
-
|
|
197
|
+
backgroundImageEnabled = true,
|
|
198
|
+
toolActive: { type },
|
|
199
|
+
scale
|
|
189
200
|
} = this.props;
|
|
190
201
|
const { isOver, newDrawable } = this.state;
|
|
191
202
|
|
|
@@ -205,7 +216,8 @@ export class DrawableMain extends React.Component {
|
|
|
205
216
|
handleSessionChange: this.handleSessionChange,
|
|
206
217
|
stage: this.stage,
|
|
207
218
|
onMouseOverElement: this.onMouseOverElement,
|
|
208
|
-
onMouseOutElement: this.onMouseOutElement
|
|
219
|
+
onMouseOutElement: this.onMouseOutElement,
|
|
220
|
+
scale
|
|
209
221
|
};
|
|
210
222
|
|
|
211
223
|
let listeners = {};
|
|
@@ -213,35 +225,45 @@ export class DrawableMain extends React.Component {
|
|
|
213
225
|
if (!disabled) {
|
|
214
226
|
listeners = {
|
|
215
227
|
onMouseUp: this.handleMouseUp,
|
|
216
|
-
|
|
228
|
+
onTouchEnd: this.handleMouseUp,
|
|
229
|
+
onMouseMove: this.handleMouseMove,
|
|
230
|
+
onTouchMove: this.handleMouseMove,
|
|
217
231
|
};
|
|
218
232
|
|
|
219
233
|
if (!draggable) {
|
|
220
234
|
listeners.onMouseDown = this.handleMouseDown;
|
|
235
|
+
listeners.onTouchStart = this.handleMouseDown;
|
|
221
236
|
}
|
|
222
237
|
}
|
|
223
238
|
|
|
239
|
+
const imageHeight = imageDimensions?.height * scale;
|
|
240
|
+
const imageWidth = imageDimensions?.width * scale;
|
|
241
|
+
|
|
224
242
|
return (
|
|
225
|
-
<div>
|
|
243
|
+
<div className={classes.wrapper}>
|
|
226
244
|
<div className={classes.undoControls}>
|
|
227
|
-
<Button disabled={disabled} onClick={this.handleUndo} label="Undo"
|
|
228
|
-
<Button disabled={disabled} onClick={this.handleClearAll} label="Clear all"
|
|
245
|
+
<Button disabled={disabled} onClick={this.handleUndo} label="Undo"/>
|
|
246
|
+
<Button disabled={disabled} onClick={this.handleClearAll} label="Clear all"/>
|
|
229
247
|
</div>
|
|
230
248
|
<div className={classes.base}>
|
|
231
|
-
{imageUrl && (
|
|
232
|
-
<ImageBackground
|
|
249
|
+
{backgroundImageEnabled && imageUrl && (
|
|
250
|
+
<ImageBackground
|
|
251
|
+
dimensions={{ height: imageHeight, width: imageWidth }}
|
|
252
|
+
url={imageUrl}/>
|
|
233
253
|
)}
|
|
234
254
|
|
|
235
255
|
{TextEntry.renderTextareas()}
|
|
236
256
|
|
|
237
257
|
<Stage
|
|
258
|
+
scaleX={scale}
|
|
259
|
+
scaleY={scale}
|
|
238
260
|
ref={ref => {
|
|
239
261
|
this.stage = ref;
|
|
240
262
|
}}
|
|
241
263
|
className={classnames(classes.stage, {
|
|
242
264
|
[classes.active]:
|
|
243
|
-
|
|
244
|
-
|
|
265
|
+
draggable &&
|
|
266
|
+
(isOver || (newDrawable && newDrawable.length === 1))
|
|
245
267
|
})}
|
|
246
268
|
height={drawableDimensions.height}
|
|
247
269
|
width={drawableDimensions.width}
|
|
@@ -266,6 +288,11 @@ export class DrawableMain extends React.Component {
|
|
|
266
288
|
}
|
|
267
289
|
|
|
268
290
|
const styles = () => ({
|
|
291
|
+
wrapper: {
|
|
292
|
+
display: 'flex',
|
|
293
|
+
flexWrap: 'wrap',
|
|
294
|
+
justifyContent: 'flex-end'
|
|
295
|
+
},
|
|
269
296
|
base: {
|
|
270
297
|
position: 'relative',
|
|
271
298
|
width: '100%'
|
|
@@ -273,13 +300,13 @@ const styles = () => ({
|
|
|
273
300
|
stage: {
|
|
274
301
|
left: 0,
|
|
275
302
|
position: 'absolute',
|
|
303
|
+
touchAction: 'none',
|
|
276
304
|
top: 0
|
|
277
305
|
},
|
|
278
306
|
active: {
|
|
279
307
|
cursor: 'pointer'
|
|
280
308
|
},
|
|
281
309
|
undoControls: {
|
|
282
|
-
float: 'right',
|
|
283
310
|
marginTop: -43,
|
|
284
311
|
width: 163
|
|
285
312
|
}
|
|
@@ -297,7 +324,9 @@ DrawableMain.propTypes = {
|
|
|
297
324
|
imageUrl: PropTypes.string.isRequired,
|
|
298
325
|
TextEntry: PropTypes.object.isRequired,
|
|
299
326
|
toolActive: PropTypes.object.isRequired,
|
|
300
|
-
session: PropTypes.object.isRequired
|
|
327
|
+
session: PropTypes.object.isRequired,
|
|
328
|
+
backgroundImageEnabled: PropTypes.bool.isRequired,
|
|
329
|
+
scale: PropTypes.number.isRequired
|
|
301
330
|
};
|
|
302
331
|
|
|
303
332
|
export default withStyles(styles)(DrawableMain);
|
|
@@ -4,16 +4,13 @@ import { InputContainer } from '@pie-lib/render-ui';
|
|
|
4
4
|
import Select from '@material-ui/core/Select';
|
|
5
5
|
import MenuItem from '@material-ui/core/MenuItem';
|
|
6
6
|
import { withStyles } from '@material-ui/core/styles';
|
|
7
|
+
import classnames from 'classnames';
|
|
7
8
|
|
|
8
9
|
// TODO: Change Palette so will render inputs and colors dynamically
|
|
9
10
|
class Palette extends React.Component {
|
|
10
|
-
onChange = name => event => {
|
|
11
|
+
onChange = (name) => (event) => {
|
|
11
12
|
const { value } = event.target;
|
|
12
|
-
const {
|
|
13
|
-
onFillColorChange,
|
|
14
|
-
onOutlineColorChange,
|
|
15
|
-
onPaintColorChange
|
|
16
|
-
} = this.props;
|
|
13
|
+
const { onFillColorChange, onOutlineColorChange, onPaintColorChange } = this.props;
|
|
17
14
|
|
|
18
15
|
if (name === 'fill') {
|
|
19
16
|
onFillColorChange(value);
|
|
@@ -25,27 +22,19 @@ class Palette extends React.Component {
|
|
|
25
22
|
};
|
|
26
23
|
|
|
27
24
|
render() {
|
|
28
|
-
const {
|
|
29
|
-
classes,
|
|
30
|
-
fillColor,
|
|
31
|
-
outlineColor,
|
|
32
|
-
fillList,
|
|
33
|
-
outlineList
|
|
34
|
-
} = this.props;
|
|
25
|
+
const { classes, fillColor, outlineColor, fillList, outlineList } = this.props;
|
|
35
26
|
|
|
36
27
|
return (
|
|
37
28
|
<div className={classes.base}>
|
|
38
29
|
<InputContainer label="Fill Color" className={classes.input}>
|
|
39
|
-
<Select
|
|
40
|
-
className={classes.select}
|
|
41
|
-
onChange={this.onChange('fill')}
|
|
42
|
-
value={fillColor}
|
|
43
|
-
>
|
|
30
|
+
<Select className={classes.select} onChange={this.onChange('fill')} value={fillColor}>
|
|
44
31
|
{fillList.map(({ value, label }) => (
|
|
45
32
|
<MenuItem
|
|
46
33
|
key={value}
|
|
47
34
|
value={value}
|
|
48
|
-
className={classes.item
|
|
35
|
+
className={classnames(classes.item, {
|
|
36
|
+
[classes.blackColorItem]: value === 'black',
|
|
37
|
+
})}
|
|
49
38
|
style={{ backgroundColor: value }}
|
|
50
39
|
>
|
|
51
40
|
{label}
|
|
@@ -55,18 +44,9 @@ class Palette extends React.Component {
|
|
|
55
44
|
</InputContainer>
|
|
56
45
|
|
|
57
46
|
<InputContainer label="Outline Color" className={classes.input}>
|
|
58
|
-
<Select
|
|
59
|
-
className={classes.select}
|
|
60
|
-
onChange={this.onChange('outline')}
|
|
61
|
-
value={outlineColor}
|
|
62
|
-
>
|
|
47
|
+
<Select className={classes.select} onChange={this.onChange('outline')} value={outlineColor}>
|
|
63
48
|
{outlineList.map(({ value, label }) => (
|
|
64
|
-
<MenuItem
|
|
65
|
-
key={value}
|
|
66
|
-
value={value}
|
|
67
|
-
className={classes.item}
|
|
68
|
-
style={{ border: `2px solid ${value}` }}
|
|
69
|
-
>
|
|
49
|
+
<MenuItem key={value} value={value} className={classes.item} style={{ border: `2px solid ${value}` }}>
|
|
70
50
|
{label}
|
|
71
51
|
</MenuItem>
|
|
72
52
|
))}
|
|
@@ -77,10 +57,10 @@ class Palette extends React.Component {
|
|
|
77
57
|
}
|
|
78
58
|
}
|
|
79
59
|
|
|
80
|
-
const styles = theme => ({
|
|
60
|
+
const styles = (theme) => ({
|
|
81
61
|
base: {
|
|
82
62
|
marginTop: theme.spacing.unit * 2,
|
|
83
|
-
display: 'flex'
|
|
63
|
+
display: 'flex',
|
|
84
64
|
},
|
|
85
65
|
input: {
|
|
86
66
|
flex: 1,
|
|
@@ -93,12 +73,15 @@ const styles = theme => ({
|
|
|
93
73
|
height: '22px',
|
|
94
74
|
marginLeft: theme.spacing.unit * 2,
|
|
95
75
|
marginRight: theme.spacing.unit * 2,
|
|
96
|
-
marginTop: theme.spacing.unit * 2
|
|
76
|
+
marginTop: theme.spacing.unit * 2,
|
|
77
|
+
},
|
|
78
|
+
blackColorItem: {
|
|
79
|
+
color: theme.palette.background.paper,
|
|
97
80
|
},
|
|
98
81
|
select: {
|
|
99
82
|
fontSize: 'inherit',
|
|
100
83
|
transform: 'translate(0%, 40%)',
|
|
101
|
-
}
|
|
84
|
+
},
|
|
102
85
|
});
|
|
103
86
|
|
|
104
87
|
Palette.propTypes = {
|
|
@@ -109,7 +92,7 @@ Palette.propTypes = {
|
|
|
109
92
|
onOutlineColorChange: PropTypes.func.isRequired,
|
|
110
93
|
onPaintColorChange: PropTypes.func.isRequired,
|
|
111
94
|
outlineColor: PropTypes.string.isRequired,
|
|
112
|
-
outlineList: PropTypes.array.isRequired
|
|
95
|
+
outlineList: PropTypes.array.isRequired,
|
|
113
96
|
};
|
|
114
97
|
|
|
115
98
|
export default withStyles(styles)(Palette);
|