@pie-element/hotspot 5.9.1-next.36 → 5.9.1-next.51
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/configure/lib/hotspot-container.js +2 -1
- package/configure/lib/hotspot-container.js.map +1 -1
- package/configure/lib/root.js +29 -51
- package/configure/lib/root.js.map +1 -1
- package/configure/src/__tests__/__snapshots__/root.test.js.snap +271 -279
- package/configure/src/hotspot-container.jsx +2 -1
- package/configure/src/root.jsx +130 -152
- package/lib/hotspot/container.js +2 -1
- package/lib/hotspot/container.js.map +1 -1
- package/lib/hotspot/index.js +9 -15
- package/lib/hotspot/index.js.map +1 -1
- package/package.json +2 -2
- package/src/hotspot/container.jsx +2 -1
- package/src/hotspot/index.jsx +14 -16
package/configure/src/root.jsx
CHANGED
|
@@ -8,7 +8,6 @@ import Info from '@material-ui/icons/Info';
|
|
|
8
8
|
import Tooltip from '@material-ui/core/Tooltip';
|
|
9
9
|
import HotspotPalette from './hotspot-palette';
|
|
10
10
|
import HotspotContainer from './hotspot-container';
|
|
11
|
-
import classNames from 'classnames';
|
|
12
11
|
import { updateImageDimensions, generateValidationMessage, getUpdatedShapes, getAllShapes, groupShapes } from './utils';
|
|
13
12
|
|
|
14
13
|
const { Panel, toggle } = settings;
|
|
@@ -108,193 +107,172 @@ export class Root extends React.Component {
|
|
|
108
107
|
};
|
|
109
108
|
|
|
110
109
|
return (
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
110
|
+
<layout.ConfigLayout
|
|
111
|
+
hideSettings={settingsPanelDisabled}
|
|
112
|
+
settings={
|
|
113
|
+
<Panel
|
|
114
|
+
model={model}
|
|
115
|
+
onChangeModel={onModelChangedByConfig}
|
|
116
|
+
configuration={configuration}
|
|
117
|
+
onChangeConfiguration={onConfigurationChanged}
|
|
118
|
+
groups={{
|
|
119
|
+
Settings: panelSettings,
|
|
120
|
+
Properties: panelProperties,
|
|
121
|
+
}}
|
|
122
|
+
/>
|
|
123
|
+
}
|
|
124
|
+
>
|
|
125
|
+
{teacherInstructionsEnabled && (
|
|
126
|
+
<InputContainer label={teacherInstructions.label} className={classes.promptContainer}>
|
|
127
|
+
<EditableHtml
|
|
128
|
+
markup={model.teacherInstructions || ''}
|
|
129
|
+
onChange={onTeacherInstructionsChanged}
|
|
130
|
+
imageSupport={imageSupport}
|
|
131
|
+
nonEmpty={false}
|
|
132
|
+
toolbarOpts={toolbarOpts}
|
|
133
|
+
spellCheck={spellCheckEnabled}
|
|
134
|
+
maxImageWidth={(maxImageWidth && maxImageWidth.teacherInstructions) || defaultImageMaxWidth}
|
|
135
|
+
maxImageHeight={(maxImageHeight && maxImageHeight.teacherInstructions) || defaultImageMaxHeight}
|
|
136
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
137
|
+
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
124
138
|
/>
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
<div className={classes.regular}>
|
|
128
|
-
{teacherInstructionsEnabled && (
|
|
129
|
-
<InputContainer label={teacherInstructions.label} className={classes.prompt}>
|
|
130
|
-
<EditableHtml
|
|
131
|
-
markup={model.teacherInstructions || ''}
|
|
132
|
-
onChange={onTeacherInstructionsChanged}
|
|
133
|
-
imageSupport={imageSupport}
|
|
134
|
-
nonEmpty={false}
|
|
135
|
-
toolbarOpts={toolbarOpts}
|
|
136
|
-
spellCheck={spellCheckEnabled}
|
|
137
|
-
maxImageWidth={(maxImageWidth && maxImageWidth.teacherInstructions) || defaultImageMaxWidth}
|
|
138
|
-
maxImageHeight={(maxImageHeight && maxImageHeight.teacherInstructions) || defaultImageMaxHeight}
|
|
139
|
-
uploadSoundSupport={uploadSoundSupport}
|
|
140
|
-
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
141
|
-
/>
|
|
142
|
-
</InputContainer>
|
|
143
|
-
)}
|
|
139
|
+
</InputContainer>
|
|
140
|
+
)}
|
|
144
141
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
142
|
+
{promptEnabled && (
|
|
143
|
+
<InputContainer label={prompt.label} className={classes.promptContainer}>
|
|
144
|
+
<EditableHtml
|
|
145
|
+
markup={model.prompt || ''}
|
|
146
|
+
onChange={onPromptChanged}
|
|
147
|
+
imageSupport={imageSupport}
|
|
148
|
+
nonEmpty={false}
|
|
149
|
+
toolbarOpts={toolbarOpts}
|
|
150
|
+
spellCheck={spellCheckEnabled}
|
|
151
|
+
maxImageWidth={defaultImageMaxWidth}
|
|
152
|
+
maxImageHeight={defaultImageMaxHeight}
|
|
153
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
154
|
+
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
155
|
+
/>
|
|
156
|
+
</InputContainer>
|
|
157
|
+
)}
|
|
161
158
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
)}
|
|
159
|
+
<div className={classes.flexContainer}>
|
|
160
|
+
<Typography className={classes.subheading} variant="subheading">
|
|
161
|
+
Define Hotspot
|
|
162
|
+
</Typography>
|
|
163
|
+
<Tooltip
|
|
164
|
+
classes={{ tooltip: classes.tooltip }}
|
|
165
|
+
disableFocusListener
|
|
166
|
+
disableTouchListener
|
|
167
|
+
placement={'left'}
|
|
168
|
+
title={validationMessage}
|
|
169
|
+
>
|
|
170
|
+
<Info fontSize={'small'} color={'primary'} style={{ float: 'right' }} />
|
|
171
|
+
</Tooltip>
|
|
172
|
+
</div>
|
|
177
173
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
placement={'left'}
|
|
187
|
-
title={validationMessage}
|
|
188
|
-
>
|
|
189
|
-
<Info fontSize={'small'} color={'primary'} style={{ float: 'right' }} />
|
|
190
|
-
</Tooltip>
|
|
191
|
-
</div>
|
|
174
|
+
<HotspotPalette
|
|
175
|
+
hotspotColor={model.hotspotColor}
|
|
176
|
+
hotspotList={model.hotspotList}
|
|
177
|
+
outlineColor={model.outlineColor}
|
|
178
|
+
outlineList={model.outlineList}
|
|
179
|
+
onHotspotColorChange={(color) => this.handleColorChange('hotspot', color)}
|
|
180
|
+
onOutlineColorChange={(color) => this.handleColorChange('outline', color)}
|
|
181
|
+
/>
|
|
192
182
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
183
|
+
<HotspotContainer
|
|
184
|
+
dimensions={model.dimensions}
|
|
185
|
+
imageUrl={model.imageUrl}
|
|
186
|
+
multipleCorrect={model.multipleCorrect}
|
|
187
|
+
hasErrors={!!shapesError || !!selectionsError}
|
|
188
|
+
hotspotColor={model.hotspotColor}
|
|
189
|
+
outlineColor={model.outlineColor}
|
|
190
|
+
onUpdateImageDimension={onUpdateImageDimension}
|
|
191
|
+
onUpdateShapes={onUpdateShapes}
|
|
192
|
+
onImageUpload={onImageUpload}
|
|
193
|
+
shapes={model.shapes}
|
|
194
|
+
strokeWidth={model.strokeWidth}
|
|
195
|
+
preserveAspectRatioEnabled={preserveAspectRatio.enabled}
|
|
196
|
+
/>
|
|
197
|
+
{shapesError && <div className={classes.errorText}>{shapesError}</div>}
|
|
198
|
+
{selectionsError && <div className={classes.errorText}>{selectionsError}</div>}
|
|
201
199
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
multipleCorrect={model.multipleCorrect}
|
|
206
|
-
hasErrors={!!shapesError || !!selectionsError}
|
|
207
|
-
hotspotColor={model.hotspotColor}
|
|
208
|
-
outlineColor={model.outlineColor}
|
|
209
|
-
onUpdateImageDimension={onUpdateImageDimension}
|
|
210
|
-
onUpdateShapes={onUpdateShapes}
|
|
211
|
-
onImageUpload={onImageUpload}
|
|
212
|
-
shapes={model.shapes}
|
|
213
|
-
strokeWidth={model.strokeWidth}
|
|
214
|
-
preserveAspectRatioEnabled={preserveAspectRatio.enabled}
|
|
215
|
-
/>
|
|
216
|
-
{shapesError && <div className={classes.errorText}>{shapesError}</div>}
|
|
217
|
-
{selectionsError && <div className={classes.errorText}>{selectionsError}</div>}
|
|
200
|
+
{model.imageUrl && (
|
|
201
|
+
<React.Fragment>
|
|
202
|
+
<Typography variant="subheading">Image Dimensions</Typography>
|
|
218
203
|
|
|
219
|
-
{
|
|
220
|
-
<
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
204
|
+
<div className={classes.dimensions}>
|
|
205
|
+
<NumberTextField
|
|
206
|
+
key="hotspot-manual-width"
|
|
207
|
+
label="Width"
|
|
208
|
+
value={model.dimensions.width}
|
|
209
|
+
min={0}
|
|
210
|
+
onChange={(e, value) => this.handleOnUpdateImageDimensions(value, 'width')}
|
|
211
|
+
showErrorWhenOutsideRange
|
|
212
|
+
className={classes.field}
|
|
213
|
+
/>
|
|
224
214
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
215
|
+
<NumberTextField
|
|
216
|
+
key="hotspot-manual-height"
|
|
217
|
+
label="Height"
|
|
218
|
+
value={model.dimensions.height}
|
|
219
|
+
min={0}
|
|
220
|
+
onChange={(e, value) => this.handleOnUpdateImageDimensions(value, 'height')}
|
|
221
|
+
showErrorWhenOutsideRange
|
|
222
|
+
className={classes.field}
|
|
223
|
+
/>
|
|
224
|
+
</div>
|
|
225
|
+
</React.Fragment>
|
|
226
|
+
)}
|
|
235
227
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
228
|
+
{rationaleEnabled && (
|
|
229
|
+
<InputContainer label={rationale.label} className={classes.promptContainer}>
|
|
230
|
+
<EditableHtml
|
|
231
|
+
markup={model.rationale || ''}
|
|
232
|
+
onChange={onRationaleChanged}
|
|
233
|
+
imageSupport={imageSupport}
|
|
234
|
+
toolbarOpts={toolbarOpts}
|
|
235
|
+
spellCheck={spellCheckEnabled}
|
|
236
|
+
maxImageWidth={(maxImageWidth && maxImageWidth.rationale) || defaultImageMaxWidth}
|
|
237
|
+
maxImageHeight={(maxImageHeight && maxImageHeight.rationale) || defaultImageMaxHeight}
|
|
238
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
239
|
+
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
240
|
+
/>
|
|
241
|
+
</InputContainer>
|
|
242
|
+
)}
|
|
243
|
+
</layout.ConfigLayout>
|
|
251
244
|
);
|
|
252
245
|
}
|
|
253
246
|
}
|
|
254
247
|
|
|
255
248
|
const styles = (theme) => ({
|
|
256
|
-
base: {
|
|
257
|
-
marginTop: theme.spacing.unit * 3,
|
|
258
|
-
},
|
|
259
|
-
container: {
|
|
260
|
-
display: 'flex',
|
|
261
|
-
marginTop: theme.spacing.unit,
|
|
262
|
-
},
|
|
263
249
|
dimensions: {
|
|
264
250
|
display: 'flex',
|
|
251
|
+
marginBottom: theme.spacing.unit * 1.5,
|
|
265
252
|
},
|
|
266
253
|
field: {
|
|
267
254
|
flex: 1,
|
|
268
255
|
width: '90%',
|
|
269
256
|
},
|
|
270
|
-
|
|
271
|
-
marginTop: theme.spacing.unit * 4,
|
|
272
|
-
},
|
|
273
|
-
prompt: {
|
|
257
|
+
promptContainer: {
|
|
274
258
|
paddingTop: theme.spacing.unit * 2,
|
|
259
|
+
marginBottom: theme.spacing.unit * 2,
|
|
275
260
|
width: '100%',
|
|
276
261
|
},
|
|
277
262
|
subheading: {
|
|
278
263
|
marginRight: theme.spacing.unit,
|
|
279
264
|
},
|
|
280
|
-
regular: {
|
|
281
|
-
marginBottom: theme.spacing.unit * 3,
|
|
282
|
-
},
|
|
283
|
-
switchElement: {
|
|
284
|
-
justifyContent: 'space-between',
|
|
285
|
-
margin: 0,
|
|
286
|
-
},
|
|
287
265
|
flexContainer: {
|
|
288
266
|
display: 'flex',
|
|
289
267
|
alignItems: 'center',
|
|
290
268
|
},
|
|
291
269
|
tooltip: {
|
|
292
|
-
fontSize:
|
|
270
|
+
fontSize: theme.typography.fontSize - 2,
|
|
293
271
|
whiteSpace: 'pre',
|
|
294
272
|
maxWidth: '500px',
|
|
295
273
|
},
|
|
296
274
|
errorText: {
|
|
297
|
-
fontSize:
|
|
275
|
+
fontSize: theme.typography.fontSize - 2,
|
|
298
276
|
color: theme.palette.error.main,
|
|
299
277
|
paddingTop: theme.spacing.unit,
|
|
300
278
|
},
|
package/lib/hotspot/container.js
CHANGED
|
@@ -191,7 +191,8 @@ exports.Container = Container;
|
|
|
191
191
|
var styles = function styles(theme) {
|
|
192
192
|
return {
|
|
193
193
|
base: {
|
|
194
|
-
marginTop: theme.spacing.unit *
|
|
194
|
+
marginTop: theme.spacing.unit * 2,
|
|
195
|
+
marginBottom: theme.spacing.unit * 2,
|
|
195
196
|
position: 'relative'
|
|
196
197
|
},
|
|
197
198
|
image: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hotspot/container.jsx"],"names":["Container","isCorrect","isChecked","selected","shape","selectedShape","props","session","answers","filter","answer","id","classes","dimensions","withProp","width","heightProp","height","disabled","hotspotColor","imageUrl","isEvaluateMode","outlineColor","onSelectChoice","shapes","rectangles","polygons","SCALE","scale","strokeWidth","showCorrect","base","padding","imageContainer","image","maxWidth","maxHeight","stage","map","isSelected","correctness","correct","undefined","evaluateText","getEvaluateText","markAsCorrect","x","y","polygon","points","React","Component","styles","theme","marginTop","spacing","unit","position","alignItems","display","justifyContent","left","top","resize","borderBottom","color","borderRight","bottom","cursor","right","propTypes","PropTypes","object","isRequired","bool","string","func","number","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;IAEaA,S;;;;;;;;;;;;;;;oGAMG,UAACC,SAAD,EAAYC,SAAZ;AAAA,aAA2BD,SAAS,GAAGC,SAAH,GAAe,CAACA,SAApD;AAAA,K;wGAEI,UAACD,SAAD,EAAYE,QAAZ,EAAyB;AACzC,UAAIA,QAAQ,IAAIF,SAAhB,EAA2B;AACzB,eAAO,qBAAP;AACD;;AAED,UAAIE,QAAQ,IAAI,CAACF,SAAjB,EAA4B;AAC1B,eAAO,gCAAP;AACD;;AAED,UAAI,CAACE,QAAD,IAAaF,SAAjB,EAA4B;AAC1B,eAAO,4BAAP;AACD;;AAED,aAAO,IAAP;AACD,K;;;;;;WArBD,oBAAWG,KAAX,EAAkB;AAChB,UAAMC,aAAa,GAAG,KAAKC,KAAL,CAAWC,OAAX,CAAmBC,OAAnB,CAA2BC,MAA3B,CAAkC,UAACC,MAAD;AAAA,eAAYA,MAAM,CAACC,EAAP,KAAcP,KAAK,CAACO,EAAhC;AAAA,OAAlC,EAAsE,CAAtE,CAAtB;AACA,aAAO,CAAC,CAACN,aAAT;AACD;;;WAoBD,kBAAS;AAAA;;AACP,wBAaI,KAAKC,KAbT;AAAA,UACEM,OADF,eACEA,OADF;AAAA,8CAEEC,UAFF;AAAA,UAEuBC,QAFvB,yBAEgBC,KAFhB;AAAA,U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gD,sBAAUK,IAAV,CAAeH,UAPX;AAQpBnD,EAAAA,YAAY,EAAEiD,sBAAUI,MAAV,CAAiBF,UARX;AASpBlE,EAAAA,OAAO,EAAEgE,sBAAUC,MAAV,CAAiBC,UATN;AAUpBjD,EAAAA,MAAM,EAAE+C,sBAAUC,MAAV,CAAiBC,UAVL;AAWpB5C,EAAAA,WAAW,EAAE0C,sBAAUM,MAXH;AAYpBjD,EAAAA,KAAK,EAAE2C,sBAAUM,MAZG;AAapB/C,EAAAA,WAAW,EAAEyC,sBAAUG;AAbH,CAAtB;AAgBA1E,SAAS,CAAC8E,YAAV,GAAyB;AACvBlD,EAAAA,KAAK,EAAE;AADgB,CAAzB;;eAIe,wBAAWwB,MAAX,EAAmBpD,SAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Layer, Stage } from 'react-konva';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color } from '@pie-lib/render-ui';\n\nimport Rectangle from './rectangle';\nimport Polygon from './polygon';\n\nexport class Container extends React.Component {\n isSelected(shape) {\n const selectedShape = this.props.session.answers.filter((answer) => answer.id === shape.id)[0];\n return !!selectedShape;\n }\n\n correctness = (isCorrect, isChecked) => (isCorrect ? isChecked : !isChecked);\n\n getEvaluateText = (isCorrect, selected) => {\n if (selected && isCorrect) {\n return 'Correctly\\nselected';\n }\n\n if (selected && !isCorrect) {\n return 'Should not have\\nbeen selected';\n }\n\n if (!selected && isCorrect) {\n return 'Should have\\nbeen selected';\n }\n\n return null;\n };\n\n render() {\n const {\n classes,\n dimensions: { width: withProp, height: heightProp },\n disabled,\n hotspotColor,\n imageUrl,\n isEvaluateMode,\n outlineColor,\n onSelectChoice,\n shapes: { rectangles, polygons },\n scale: SCALE,\n strokeWidth,\n showCorrect,\n } = this.props;\n\n const width = withProp * SCALE;\n const height = heightProp * SCALE;\n\n return (\n <div className={classes.base} style={{ padding: strokeWidth / 2 }}>\n {imageUrl ? (\n <div className={classes.imageContainer}>\n <img\n alt=\"hotspot-image\"\n className={classes.image}\n height=\"auto\"\n src={imageUrl}\n style={{ width, height, maxWidth: width, maxHeight: height }}\n />\n </div>\n ) : null}\n\n <Stage\n className={classes.stage}\n height={height + strokeWidth}\n width={width + strokeWidth}\n x={strokeWidth / 2}\n y={strokeWidth / 2}\n >\n <Layer>\n {rectangles.map((shape) => {\n const selected = this.isSelected(shape);\n const isCorrect = isEvaluateMode ? this.correctness(shape.correct, selected) : undefined;\n const evaluateText = isEvaluateMode ? this.getEvaluateText(shape.correct, selected) : null;\n const markAsCorrect = !!(isEvaluateMode && showCorrect && shape.correct);\n\n return (\n <Rectangle\n scale={SCALE}\n isEvaluateMode={isEvaluateMode}\n isCorrect={isCorrect}\n evaluateText={evaluateText}\n disabled={disabled}\n selected={selected}\n height={shape.height}\n hotspotColor={hotspotColor}\n id={shape.id}\n key={shape.id}\n onClick={onSelectChoice}\n outlineColor={outlineColor}\n width={shape.width}\n x={shape.x}\n y={shape.y}\n strokeWidth={strokeWidth}\n markAsCorrect={markAsCorrect}\n showCorrectEnabled={showCorrect}\n />\n );\n })}\n {polygons.map((polygon) => {\n const selected = this.isSelected(polygon);\n const isCorrect = isEvaluateMode ? this.correctness(polygon.correct, selected) : undefined;\n const evaluateText = isEvaluateMode ? this.getEvaluateText(polygon.correct, selected) : null;\n const markAsCorrect = !!(isEvaluateMode && showCorrect && polygon.correct);\n\n return (\n <Polygon\n scale={SCALE}\n isEvaluateMode={isEvaluateMode}\n isCorrect={!!isCorrect}\n evaluateText={evaluateText}\n disabled={disabled}\n selected={selected}\n hotspotColor={hotspotColor}\n id={polygon.id}\n key={polygon.id}\n onClick={onSelectChoice}\n outlineColor={outlineColor}\n points={polygon.points}\n strokeWidth={strokeWidth}\n markAsCorrect={markAsCorrect}\n showCorrectEnabled={showCorrect}\n />\n );\n })}\n </Layer>\n </Stage>\n </div>\n );\n }\n}\n\nconst styles = (theme) => ({\n base: {\n marginTop: theme.spacing.unit * 3,\n position: 'relative',\n },\n image: {\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'center',\n },\n imageContainer: {\n position: 'relative',\n width: 'fit-content',\n },\n stage: {\n left: 0,\n top: 0,\n position: 'absolute',\n },\n resize: {\n borderBottom: `1px solid ${color.disabled()}`,\n borderRight: `1px solid ${color.disabled()}`,\n bottom: '-10px',\n cursor: 'se-resize',\n height: '10px',\n position: 'absolute',\n right: '-10px',\n width: '10px',\n },\n});\n\nContainer.propTypes = {\n classes: PropTypes.object.isRequired,\n dimensions: PropTypes.object.isRequired,\n disabled: PropTypes.bool.isRequired,\n hotspotColor: PropTypes.string.isRequired,\n imageUrl: PropTypes.string.isRequired,\n isEvaluateMode: PropTypes.bool.isRequired,\n onSelectChoice: PropTypes.func.isRequired,\n outlineColor: PropTypes.string.isRequired,\n session: PropTypes.object.isRequired,\n shapes: PropTypes.object.isRequired,\n strokeWidth: PropTypes.number,\n scale: PropTypes.number,\n showCorrect: PropTypes.bool,\n};\n\nContainer.defaultProps = {\n scale: 1,\n};\n\nexport default withStyles(styles)(Container);\n"],"file":"container.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/hotspot/container.jsx"],"names":["Container","isCorrect","isChecked","selected","shape","selectedShape","props","session","answers","filter","answer","id","classes","dimensions","withProp","width","heightProp","height","disabled","hotspotColor","imageUrl","isEvaluateMode","outlineColor","onSelectChoice","shapes","rectangles","polygons","SCALE","scale","strokeWidth","showCorrect","base","padding","imageContainer","image","maxWidth","maxHeight","stage","map","isSelected","correctness","correct","undefined","evaluateText","getEvaluateText","markAsCorrect","x","y","polygon","points","React","Component","styles","theme","marginTop","spacing","unit","marginBottom","position","alignItems","display","justifyContent","left","top","resize","borderBottom","color","borderRight","bottom","cursor","right","propTypes","PropTypes","object","isRequired","bool","string","func","number","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;IAEaA,S;;;;;;;;;;;;;;;oGAMG,UAACC,SAAD,EAAYC,SA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AE;AADgB,CAAzB;;eAIe,wBAAWwB,MAAX,EAAmBpD,SAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Layer, Stage } from 'react-konva';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color } from '@pie-lib/render-ui';\n\nimport Rectangle from './rectangle';\nimport Polygon from './polygon';\n\nexport class Container extends React.Component {\n isSelected(shape) {\n const selectedShape = this.props.session.answers.filter((answer) => answer.id === shape.id)[0];\n return !!selectedShape;\n }\n\n correctness = (isCorrect, isChecked) => (isCorrect ? isChecked : !isChecked);\n\n getEvaluateText = (isCorrect, selected) => {\n if (selected && isCorrect) {\n return 'Correctly\\nselected';\n }\n\n if (selected && !isCorrect) {\n return 'Should not have\\nbeen selected';\n }\n\n if (!selected && isCorrect) {\n return 'Should have\\nbeen selected';\n }\n\n return null;\n };\n\n render() {\n const {\n classes,\n dimensions: { width: withProp, height: heightProp },\n disabled,\n hotspotColor,\n imageUrl,\n isEvaluateMode,\n outlineColor,\n onSelectChoice,\n shapes: { rectangles, polygons },\n scale: SCALE,\n strokeWidth,\n showCorrect,\n } = this.props;\n\n const width = withProp * SCALE;\n const height = heightProp * SCALE;\n\n return (\n <div className={classes.base} style={{ padding: strokeWidth / 2 }}>\n {imageUrl ? (\n <div className={classes.imageContainer}>\n <img\n alt=\"hotspot-image\"\n className={classes.image}\n height=\"auto\"\n src={imageUrl}\n style={{ width, height, maxWidth: width, maxHeight: height }}\n />\n </div>\n ) : null}\n\n <Stage\n className={classes.stage}\n height={height + strokeWidth}\n width={width + strokeWidth}\n x={strokeWidth / 2}\n y={strokeWidth / 2}\n >\n <Layer>\n {rectangles.map((shape) => {\n const selected = this.isSelected(shape);\n const isCorrect = isEvaluateMode ? this.correctness(shape.correct, selected) : undefined;\n const evaluateText = isEvaluateMode ? this.getEvaluateText(shape.correct, selected) : null;\n const markAsCorrect = !!(isEvaluateMode && showCorrect && shape.correct);\n\n return (\n <Rectangle\n scale={SCALE}\n isEvaluateMode={isEvaluateMode}\n isCorrect={isCorrect}\n evaluateText={evaluateText}\n disabled={disabled}\n selected={selected}\n height={shape.height}\n hotspotColor={hotspotColor}\n id={shape.id}\n key={shape.id}\n onClick={onSelectChoice}\n outlineColor={outlineColor}\n width={shape.width}\n x={shape.x}\n y={shape.y}\n strokeWidth={strokeWidth}\n markAsCorrect={markAsCorrect}\n showCorrectEnabled={showCorrect}\n />\n );\n })}\n {polygons.map((polygon) => {\n const selected = this.isSelected(polygon);\n const isCorrect = isEvaluateMode ? this.correctness(polygon.correct, selected) : undefined;\n const evaluateText = isEvaluateMode ? this.getEvaluateText(polygon.correct, selected) : null;\n const markAsCorrect = !!(isEvaluateMode && showCorrect && polygon.correct);\n\n return (\n <Polygon\n scale={SCALE}\n isEvaluateMode={isEvaluateMode}\n isCorrect={!!isCorrect}\n evaluateText={evaluateText}\n disabled={disabled}\n selected={selected}\n hotspotColor={hotspotColor}\n id={polygon.id}\n key={polygon.id}\n onClick={onSelectChoice}\n outlineColor={outlineColor}\n points={polygon.points}\n strokeWidth={strokeWidth}\n markAsCorrect={markAsCorrect}\n showCorrectEnabled={showCorrect}\n />\n );\n })}\n </Layer>\n </Stage>\n </div>\n );\n }\n}\n\nconst styles = (theme) => ({\n base: {\n marginTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n position: 'relative',\n },\n image: {\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'center',\n },\n imageContainer: {\n position: 'relative',\n width: 'fit-content',\n },\n stage: {\n left: 0,\n top: 0,\n position: 'absolute',\n },\n resize: {\n borderBottom: `1px solid ${color.disabled()}`,\n borderRight: `1px solid ${color.disabled()}`,\n bottom: '-10px',\n cursor: 'se-resize',\n height: '10px',\n position: 'absolute',\n right: '-10px',\n width: '10px',\n },\n});\n\nContainer.propTypes = {\n classes: PropTypes.object.isRequired,\n dimensions: PropTypes.object.isRequired,\n disabled: PropTypes.bool.isRequired,\n hotspotColor: PropTypes.string.isRequired,\n imageUrl: PropTypes.string.isRequired,\n isEvaluateMode: PropTypes.bool.isRequired,\n onSelectChoice: PropTypes.func.isRequired,\n outlineColor: PropTypes.string.isRequired,\n session: PropTypes.object.isRequired,\n shapes: PropTypes.object.isRequired,\n strokeWidth: PropTypes.number,\n scale: PropTypes.number,\n showCorrect: PropTypes.bool,\n};\n\nContainer.defaultProps = {\n scale: 1,\n};\n\nexport default withStyles(styles)(Container);\n"],"file":"container.js"}
|
package/lib/hotspot/index.js
CHANGED
|
@@ -25,8 +25,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
25
25
|
|
|
26
26
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
27
|
|
|
28
|
-
var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
|
|
29
|
-
|
|
30
28
|
var _correctAnswerToggle = _interopRequireDefault(require("@pie-lib/correct-answer-toggle"));
|
|
31
29
|
|
|
32
30
|
var _renderUi = require("@pie-lib/render-ui");
|
|
@@ -132,11 +130,7 @@ var HotspotComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
132
130
|
var showCorrect = this.state.showCorrect;
|
|
133
131
|
var isEvaluateMode = mode === 'evaluate';
|
|
134
132
|
var showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;
|
|
135
|
-
return /*#__PURE__*/_react["default"].createElement("div", null,
|
|
136
|
-
show: showCorrectAnswerToggle,
|
|
137
|
-
toggled: showCorrect,
|
|
138
|
-
onToggle: this.onToggle.bind(this)
|
|
139
|
-
}), showCorrectAnswerToggle && /*#__PURE__*/_react["default"].createElement("br", null), teacherInstructions && (0, _renderUi.hasText)(teacherInstructions) && /*#__PURE__*/_react["default"].createElement(_renderUi.Collapsible, {
|
|
133
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, teacherInstructions && (0, _renderUi.hasText)(teacherInstructions) && /*#__PURE__*/_react["default"].createElement(_renderUi.Collapsible, {
|
|
140
134
|
labels: {
|
|
141
135
|
hidden: 'Show Teacher Instructions',
|
|
142
136
|
visible: 'Hide Teacher Instructions'
|
|
@@ -145,12 +139,14 @@ var HotspotComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
145
139
|
}, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
|
|
146
140
|
className: "prompt",
|
|
147
141
|
prompt: teacherInstructions
|
|
148
|
-
})), /*#__PURE__*/_react["default"].createElement(
|
|
149
|
-
className: classes.prompt
|
|
150
|
-
}, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
|
|
142
|
+
})), prompt && /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
|
|
151
143
|
className: "prompt",
|
|
152
144
|
prompt: prompt
|
|
153
|
-
})
|
|
145
|
+
}), showCorrectAnswerToggle && /*#__PURE__*/_react["default"].createElement(_correctAnswerToggle["default"], {
|
|
146
|
+
show: showCorrectAnswerToggle,
|
|
147
|
+
toggled: showCorrect,
|
|
148
|
+
onToggle: this.onToggle.bind(this)
|
|
149
|
+
}), imageUrl ? /*#__PURE__*/_react["default"].createElement(_container["default"], {
|
|
154
150
|
isEvaluateMode: isEvaluateMode,
|
|
155
151
|
session: session,
|
|
156
152
|
dimensions: dimensions,
|
|
@@ -168,8 +164,7 @@ var HotspotComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
168
164
|
labels: {
|
|
169
165
|
hidden: 'Show Rationale',
|
|
170
166
|
visible: 'Hide Rationale'
|
|
171
|
-
}
|
|
172
|
-
className: classes.collapsible
|
|
167
|
+
}
|
|
173
168
|
}, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
|
|
174
169
|
className: "prompt",
|
|
175
170
|
prompt: rationale
|
|
@@ -192,8 +187,7 @@ HotspotComponent.defaultProps = {
|
|
|
192
187
|
var styles = function styles(theme) {
|
|
193
188
|
return {
|
|
194
189
|
collapsible: {
|
|
195
|
-
|
|
196
|
-
paddingBottom: theme.spacing.unit * 2
|
|
190
|
+
marginBottom: theme.spacing.unit * 2
|
|
197
191
|
},
|
|
198
192
|
prompt: {
|
|
199
193
|
fontSize: 'inherit'
|
package/lib/hotspot/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hotspot/index.jsx"],"names":["HotspotComponent","props","showCorrect","state","setState","observer","scale","MutationObserver","mutations","forEach","target","document","getElementById","style","cssText","zoom","substring","indexOf","lastIndexOf","zoomParsed","replace","newScale","parseFloat","observe","attributes","attributeFilter","disconnect","session","model","disabled","imageUrl","prompt","mode","multipleCorrect","shapes","outlineColor","hotspotColor","dimensions","rationale","teacherInstructions","strokeWidth","responseCorrect","onSelectChoice","classes","isEvaluateMode","showCorrectAnswerToggle","
|
|
1
|
+
{"version":3,"sources":["../../src/hotspot/index.jsx"],"names":["HotspotComponent","props","showCorrect","state","setState","observer","scale","MutationObserver","mutations","forEach","target","document","getElementById","style","cssText","zoom","substring","indexOf","lastIndexOf","zoomParsed","replace","newScale","parseFloat","observe","attributes","attributeFilter","disconnect","session","model","disabled","imageUrl","prompt","mode","multipleCorrect","shapes","outlineColor","hotspotColor","dimensions","rationale","teacherInstructions","strokeWidth","responseCorrect","onSelectChoice","classes","isEvaluateMode","showCorrectAnswerToggle","hidden","visible","collapsible","onToggle","bind","React","Component","propTypes","PropTypes","object","isRequired","func","defaultProps","styles","theme","marginBottom","spacing","unit","fontSize"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;IAEMA,gB;;;;;AACJ,4BAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,iGA2CR,YAAM;AACf,UAAQC,WAAR,GAAwB,MAAKC,KAA7B,CAAQD,WAAR;;AACA,YAAKE,QAAL,CAAc;AAAEF,QAAAA,WAAW,EAAE,CAACA;AAAhB,OAAd;AACD,KA9CkB;AAEjB,UAAKC,KAAL,GAAa;AACXD,MAAAA,WAAW,EAAE,KADF;AAEXG,MAAAA,QAAQ,EAAE,IAFC;AAGXC,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G;AAG3Bd,EAAAA,cAAc,EAAEY,sBAAUG,IAAV,CAAeD,UAHJ;AAI3B7B,EAAAA,OAAO,EAAE2B,sBAAUC,MAAV,CAAiBC;AAJC,CAA7B;AAOAxD,gBAAgB,CAAC0D,YAAjB,GAAgC;AAC9Bf,EAAAA,OAAO,EAAE;AADqB,CAAhC;;AAIA,IAAMgB,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBZ,IAAAA,WAAW,EAAE;AACXa,MAAAA,YAAY,EAAED,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB;AADxB,KADY;AAIzBhC,IAAAA,MAAM,EAAE;AACNiC,MAAAA,QAAQ,EAAE;AADJ;AAJiB,GAAZ;AAAA,CAAf;;eASe,wBAAWL,MAAX,EAAmB3D,gBAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';\nimport { Collapsible, hasText, PreviewPrompt } from '@pie-lib/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\n\nimport Container from './container';\n\nclass HotspotComponent extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n showCorrect: false,\n observer: null,\n scale: 1,\n };\n }\n\n componentDidMount() {\n this.observer = new MutationObserver((mutations) => {\n mutations.forEach(() => {\n const target = document.getElementById('question-container')?.style?.cssText;\n const zoom = target?.substring(target.indexOf('--pie-zoom') + 11, target.lastIndexOf('%'));\n const zoomParsed = zoom?.replace(/\\s/g, '');\n\n if (zoomParsed) {\n const newScale = parseFloat(zoomParsed) / 100;\n\n if (newScale !== this.state.scale) {\n this.setState({\n scale: parseFloat(zoomParsed) / 100,\n });\n }\n } else if (!zoomParsed && this.state.scale !== 1) {\n this.setState({\n scale: 1,\n });\n }\n });\n });\n\n const target = document.getElementById('question-container');\n\n if (target) {\n this.observer.observe(target, { attributes: true, attributeFilter: ['style'] });\n }\n }\n\n componentWillUnmount() {\n this.observer?.disconnect();\n }\n\n onToggle = () => {\n const { showCorrect } = this.state;\n this.setState({ showCorrect: !showCorrect });\n };\n\n render() {\n const {\n session,\n model: {\n disabled,\n imageUrl,\n prompt,\n mode,\n multipleCorrect,\n shapes,\n outlineColor,\n hotspotColor,\n dimensions,\n rationale,\n teacherInstructions,\n strokeWidth,\n responseCorrect,\n },\n onSelectChoice,\n classes,\n } = this.props;\n const { showCorrect } = this.state;\n const isEvaluateMode = mode === 'evaluate';\n const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;\n\n return (\n <div>\n {teacherInstructions && hasText(teacherInstructions) && (\n <Collapsible\n labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}\n className={classes.collapsible}\n >\n <PreviewPrompt className=\"prompt\" prompt={teacherInstructions} />\n </Collapsible>\n )}\n\n {prompt && <PreviewPrompt className=\"prompt\" prompt={prompt} />}\n\n {showCorrectAnswerToggle && (\n <CorrectAnswerToggle\n show={showCorrectAnswerToggle}\n toggled={showCorrect}\n onToggle={this.onToggle.bind(this)}\n />\n )}\n\n {imageUrl ? (\n <Container\n isEvaluateMode={isEvaluateMode}\n session={session}\n dimensions={dimensions}\n imageUrl={imageUrl}\n hotspotColor={hotspotColor}\n multipleCorrect={multipleCorrect}\n outlineColor={outlineColor}\n onSelectChoice={onSelectChoice}\n shapes={shapes}\n disabled={disabled}\n strokeWidth={strokeWidth}\n scale={this.state.scale}\n showCorrect={showCorrect}\n />\n ) : null}\n\n {rationale && hasText(rationale) && (\n <Collapsible labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}>\n <PreviewPrompt className=\"prompt\" prompt={rationale} />\n </Collapsible>\n )}\n </div>\n );\n }\n}\n\nHotspotComponent.propTypes = {\n classes: PropTypes.object,\n model: PropTypes.object.isRequired,\n onSelectChoice: PropTypes.func.isRequired,\n session: PropTypes.object.isRequired,\n};\n\nHotspotComponent.defaultProps = {\n classes: {},\n};\n\nconst styles = (theme) => ({\n collapsible: {\n marginBottom: theme.spacing.unit * 2,\n },\n prompt: {\n fontSize: 'inherit',\n },\n});\n\nexport default withStyles(styles)(HotspotComponent);\n"],"file":"index.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/hotspot",
|
|
3
|
-
"version": "5.9.1-next.
|
|
3
|
+
"version": "5.9.1-next.51+a42a408d1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": "pie-framework/pie-elements",
|
|
6
6
|
"publishConfig": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"author": "pie framework developers",
|
|
23
23
|
"license": "ISC",
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "a42a408d1d238e52cbcf907fbbaec2ee98550385",
|
|
25
25
|
"scripts": {
|
|
26
26
|
"postpublish": "../../scripts/postpublish"
|
|
27
27
|
},
|
|
@@ -136,7 +136,8 @@ export class Container extends React.Component {
|
|
|
136
136
|
|
|
137
137
|
const styles = (theme) => ({
|
|
138
138
|
base: {
|
|
139
|
-
marginTop: theme.spacing.unit *
|
|
139
|
+
marginTop: theme.spacing.unit * 2,
|
|
140
|
+
marginBottom: theme.spacing.unit * 2,
|
|
140
141
|
position: 'relative',
|
|
141
142
|
},
|
|
142
143
|
image: {
|
package/src/hotspot/index.jsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import Typography from '@material-ui/core/Typography';
|
|
4
3
|
import CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';
|
|
5
4
|
import { Collapsible, hasText, PreviewPrompt } from '@pie-lib/render-ui';
|
|
6
5
|
import { withStyles } from '@material-ui/core/styles';
|
|
@@ -22,10 +21,11 @@ class HotspotComponent extends React.Component {
|
|
|
22
21
|
mutations.forEach(() => {
|
|
23
22
|
const target = document.getElementById('question-container')?.style?.cssText;
|
|
24
23
|
const zoom = target?.substring(target.indexOf('--pie-zoom') + 11, target.lastIndexOf('%'));
|
|
25
|
-
|
|
26
24
|
const zoomParsed = zoom?.replace(/\s/g, '');
|
|
25
|
+
|
|
27
26
|
if (zoomParsed) {
|
|
28
27
|
const newScale = parseFloat(zoomParsed) / 100;
|
|
28
|
+
|
|
29
29
|
if (newScale !== this.state.scale) {
|
|
30
30
|
this.setState({
|
|
31
31
|
scale: parseFloat(zoomParsed) / 100,
|
|
@@ -40,6 +40,7 @@ class HotspotComponent extends React.Component {
|
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
const target = document.getElementById('question-container');
|
|
43
|
+
|
|
43
44
|
if (target) {
|
|
44
45
|
this.observer.observe(target, { attributes: true, attributeFilter: ['style'] });
|
|
45
46
|
}
|
|
@@ -81,14 +82,6 @@ class HotspotComponent extends React.Component {
|
|
|
81
82
|
|
|
82
83
|
return (
|
|
83
84
|
<div>
|
|
84
|
-
{showCorrectAnswerToggle && (
|
|
85
|
-
<CorrectAnswerToggle
|
|
86
|
-
show={showCorrectAnswerToggle}
|
|
87
|
-
toggled={showCorrect}
|
|
88
|
-
onToggle={this.onToggle.bind(this)}
|
|
89
|
-
/>
|
|
90
|
-
)}
|
|
91
|
-
{showCorrectAnswerToggle && <br />}
|
|
92
85
|
{teacherInstructions && hasText(teacherInstructions) && (
|
|
93
86
|
<Collapsible
|
|
94
87
|
labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}
|
|
@@ -98,9 +91,15 @@ class HotspotComponent extends React.Component {
|
|
|
98
91
|
</Collapsible>
|
|
99
92
|
)}
|
|
100
93
|
|
|
101
|
-
<
|
|
102
|
-
|
|
103
|
-
|
|
94
|
+
{prompt && <PreviewPrompt className="prompt" prompt={prompt} />}
|
|
95
|
+
|
|
96
|
+
{showCorrectAnswerToggle && (
|
|
97
|
+
<CorrectAnswerToggle
|
|
98
|
+
show={showCorrectAnswerToggle}
|
|
99
|
+
toggled={showCorrect}
|
|
100
|
+
onToggle={this.onToggle.bind(this)}
|
|
101
|
+
/>
|
|
102
|
+
)}
|
|
104
103
|
|
|
105
104
|
{imageUrl ? (
|
|
106
105
|
<Container
|
|
@@ -121,7 +120,7 @@ class HotspotComponent extends React.Component {
|
|
|
121
120
|
) : null}
|
|
122
121
|
|
|
123
122
|
{rationale && hasText(rationale) && (
|
|
124
|
-
<Collapsible labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}
|
|
123
|
+
<Collapsible labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}>
|
|
125
124
|
<PreviewPrompt className="prompt" prompt={rationale} />
|
|
126
125
|
</Collapsible>
|
|
127
126
|
)}
|
|
@@ -143,8 +142,7 @@ HotspotComponent.defaultProps = {
|
|
|
143
142
|
|
|
144
143
|
const styles = (theme) => ({
|
|
145
144
|
collapsible: {
|
|
146
|
-
|
|
147
|
-
paddingBottom: theme.spacing.unit * 2,
|
|
145
|
+
marginBottom: theme.spacing.unit * 2,
|
|
148
146
|
},
|
|
149
147
|
prompt: {
|
|
150
148
|
fontSize: 'inherit',
|