@pie-element/hotspot 5.9.1-next.4 → 5.9.1-next.78

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.
@@ -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,24 @@ class HotspotComponent extends React.Component {
98
91
  </Collapsible>
99
92
  )}
100
93
 
101
- <Typography className={classes.prompt}>
102
- <PreviewPrompt className="prompt" prompt={prompt} />
103
- </Typography>
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
+ )}
103
+
104
+ {showCorrectAnswerToggle && <br />}
105
+ {showCorrectAnswerToggle && (
106
+ <CorrectAnswerToggle
107
+ show={showCorrectAnswerToggle}
108
+ toggled={showCorrect}
109
+ onToggle={this.onToggle.bind(this)}
110
+ />
111
+ )}
104
112
 
105
113
  {imageUrl ? (
106
114
  <Container
@@ -121,7 +129,7 @@ class HotspotComponent extends React.Component {
121
129
  ) : null}
122
130
 
123
131
  {rationale && hasText(rationale) && (
124
- <Collapsible labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }} className={classes.collapsible}>
132
+ <Collapsible labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}>
125
133
  <PreviewPrompt className="prompt" prompt={rationale} />
126
134
  </Collapsible>
127
135
  )}
@@ -143,8 +151,7 @@ HotspotComponent.defaultProps = {
143
151
 
144
152
  const styles = (theme) => ({
145
153
  collapsible: {
146
- paddingTop: theme.spacing.unit * 2,
147
- paddingBottom: theme.spacing.unit * 2,
154
+ marginBottom: theme.spacing.unit * 2,
148
155
  },
149
156
  prompt: {
150
157
  fontSize: 'inherit',