@pie-lib/graphing 2.34.2-next.0 → 2.36.0-mui-update.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 (155) hide show
  1. package/CHANGELOG.md +16 -6
  2. package/lib/axis/arrow.js +19 -55
  3. package/lib/axis/arrow.js.map +1 -1
  4. package/lib/axis/axes.js +104 -186
  5. package/lib/axis/axes.js.map +1 -1
  6. package/lib/axis/index.js +1 -6
  7. package/lib/axis/index.js.map +1 -1
  8. package/lib/bg.js +21 -49
  9. package/lib/bg.js.map +1 -1
  10. package/lib/container/actions.js +2 -8
  11. package/lib/container/actions.js.map +1 -1
  12. package/lib/container/index.js +14 -59
  13. package/lib/container/index.js.map +1 -1
  14. package/lib/container/marks.js +1 -6
  15. package/lib/container/marks.js.map +1 -1
  16. package/lib/container/middleware.js +2 -8
  17. package/lib/container/middleware.js.map +1 -1
  18. package/lib/container/reducer.js +1 -8
  19. package/lib/container/reducer.js.map +1 -1
  20. package/lib/coordinates-label.js +23 -55
  21. package/lib/coordinates-label.js.map +1 -1
  22. package/lib/graph-with-controls.js +120 -184
  23. package/lib/graph-with-controls.js.map +1 -1
  24. package/lib/graph.js +59 -116
  25. package/lib/graph.js.map +1 -1
  26. package/lib/grid-setup.js +174 -224
  27. package/lib/grid-setup.js.map +1 -1
  28. package/lib/grid.js +28 -73
  29. package/lib/grid.js.map +1 -1
  30. package/lib/index.js +1 -13
  31. package/lib/index.js.map +1 -1
  32. package/lib/key-legend.js +41 -85
  33. package/lib/key-legend.js.map +1 -1
  34. package/lib/label-svg-icon.js +1 -7
  35. package/lib/label-svg-icon.js.map +1 -1
  36. package/lib/labels.js +61 -119
  37. package/lib/labels.js.map +1 -1
  38. package/lib/mark-label.js +113 -163
  39. package/lib/mark-label.js.map +1 -1
  40. package/lib/toggle-bar.js +158 -242
  41. package/lib/toggle-bar.js.map +1 -1
  42. package/lib/tool-menu.js +16 -48
  43. package/lib/tool-menu.js.map +1 -1
  44. package/lib/tools/absolute/component.js +4 -10
  45. package/lib/tools/absolute/component.js.map +1 -1
  46. package/lib/tools/absolute/index.js +3 -16
  47. package/lib/tools/absolute/index.js.map +1 -1
  48. package/lib/tools/circle/bg-circle.js +42 -92
  49. package/lib/tools/circle/bg-circle.js.map +1 -1
  50. package/lib/tools/circle/component.js +79 -165
  51. package/lib/tools/circle/component.js.map +1 -1
  52. package/lib/tools/circle/index.js +3 -13
  53. package/lib/tools/circle/index.js.map +1 -1
  54. package/lib/tools/exponential/component.js +4 -10
  55. package/lib/tools/exponential/component.js.map +1 -1
  56. package/lib/tools/exponential/index.js +3 -18
  57. package/lib/tools/exponential/index.js.map +1 -1
  58. package/lib/tools/index.js +3 -16
  59. package/lib/tools/index.js.map +1 -1
  60. package/lib/tools/line/component.js +27 -48
  61. package/lib/tools/line/component.js.map +1 -1
  62. package/lib/tools/line/index.js +1 -6
  63. package/lib/tools/line/index.js.map +1 -1
  64. package/lib/tools/parabola/component.js +4 -10
  65. package/lib/tools/parabola/component.js.map +1 -1
  66. package/lib/tools/parabola/index.js +3 -16
  67. package/lib/tools/parabola/index.js.map +1 -1
  68. package/lib/tools/point/component.js +24 -71
  69. package/lib/tools/point/component.js.map +1 -1
  70. package/lib/tools/point/index.js +3 -11
  71. package/lib/tools/point/index.js.map +1 -1
  72. package/lib/tools/polygon/component.js +82 -183
  73. package/lib/tools/polygon/component.js.map +1 -1
  74. package/lib/tools/polygon/index.js +6 -23
  75. package/lib/tools/polygon/index.js.map +1 -1
  76. package/lib/tools/polygon/line.js +48 -91
  77. package/lib/tools/polygon/line.js.map +1 -1
  78. package/lib/tools/polygon/polygon.js +65 -98
  79. package/lib/tools/polygon/polygon.js.map +1 -1
  80. package/lib/tools/ray/component.js +41 -60
  81. package/lib/tools/ray/component.js.map +1 -1
  82. package/lib/tools/ray/index.js +1 -6
  83. package/lib/tools/ray/index.js.map +1 -1
  84. package/lib/tools/segment/component.js +25 -43
  85. package/lib/tools/segment/component.js.map +1 -1
  86. package/lib/tools/segment/index.js +1 -6
  87. package/lib/tools/segment/index.js.map +1 -1
  88. package/lib/tools/shared/arrow-head.js +69 -28
  89. package/lib/tools/shared/arrow-head.js.map +1 -1
  90. package/lib/tools/shared/icons/CorrectSVG.js +3 -8
  91. package/lib/tools/shared/icons/CorrectSVG.js.map +1 -1
  92. package/lib/tools/shared/icons/IncorrectSVG.js +3 -8
  93. package/lib/tools/shared/icons/IncorrectSVG.js.map +1 -1
  94. package/lib/tools/shared/icons/MissingSVG.js +3 -8
  95. package/lib/tools/shared/icons/MissingSVG.js.map +1 -1
  96. package/lib/tools/shared/line/index.js +126 -187
  97. package/lib/tools/shared/line/index.js.map +1 -1
  98. package/lib/tools/shared/line/line-path.js +70 -100
  99. package/lib/tools/shared/line/line-path.js.map +1 -1
  100. package/lib/tools/shared/line/with-root-edge.js +21 -55
  101. package/lib/tools/shared/line/with-root-edge.js.map +1 -1
  102. package/lib/tools/shared/point/arrow-point.js +23 -62
  103. package/lib/tools/shared/point/arrow-point.js.map +1 -1
  104. package/lib/tools/shared/point/arrow.js +24 -52
  105. package/lib/tools/shared/point/arrow.js.map +1 -1
  106. package/lib/tools/shared/point/base-point.js +54 -72
  107. package/lib/tools/shared/point/base-point.js.map +1 -1
  108. package/lib/tools/shared/point/index.js +22 -57
  109. package/lib/tools/shared/point/index.js.map +1 -1
  110. package/lib/tools/shared/styles.js +10 -38
  111. package/lib/tools/shared/styles.js.map +1 -1
  112. package/lib/tools/shared/types.js +2 -9
  113. package/lib/tools/shared/types.js.map +1 -1
  114. package/lib/tools/sine/component.js +8 -19
  115. package/lib/tools/sine/component.js.map +1 -1
  116. package/lib/tools/sine/index.js +3 -16
  117. package/lib/tools/sine/index.js.map +1 -1
  118. package/lib/tools/vector/component.js +24 -44
  119. package/lib/tools/vector/component.js.map +1 -1
  120. package/lib/tools/vector/index.js +1 -6
  121. package/lib/tools/vector/index.js.map +1 -1
  122. package/lib/undo-redo.js +29 -69
  123. package/lib/undo-redo.js.map +1 -1
  124. package/lib/use-debounce.js +4 -11
  125. package/lib/use-debounce.js.map +1 -1
  126. package/lib/utils.js +51 -128
  127. package/lib/utils.js.map +1 -1
  128. package/package.json +16 -13
  129. package/src/axis/arrow.jsx +7 -12
  130. package/src/axis/axes.jsx +40 -45
  131. package/src/coordinates-label.jsx +13 -18
  132. package/src/graph-with-controls.jsx +52 -59
  133. package/src/grid-setup.jsx +210 -206
  134. package/src/grid.jsx +1 -3
  135. package/src/key-legend.jsx +52 -56
  136. package/src/labels.jsx +21 -30
  137. package/src/mark-label.jsx +83 -81
  138. package/src/toggle-bar.jsx +155 -166
  139. package/src/tools/circle/bg-circle.jsx +20 -28
  140. package/src/tools/circle/component.jsx +28 -63
  141. package/src/tools/line/component.jsx +22 -15
  142. package/src/tools/polygon/component.jsx +1 -2
  143. package/src/tools/polygon/line.jsx +28 -32
  144. package/src/tools/polygon/polygon.jsx +52 -45
  145. package/src/tools/ray/component.jsx +38 -25
  146. package/src/tools/segment/component.jsx +19 -18
  147. package/src/tools/shared/arrow-head.jsx +60 -7
  148. package/src/tools/shared/line/index.jsx +39 -2
  149. package/src/tools/shared/line/line-path.jsx +54 -58
  150. package/src/tools/shared/point/arrow-point.jsx +10 -24
  151. package/src/tools/shared/point/arrow.jsx +5 -11
  152. package/src/tools/shared/point/base-point.jsx +42 -19
  153. package/src/tools/shared/point/index.jsx +27 -44
  154. package/src/tools/vector/component.jsx +11 -16
  155. package/src/undo-redo.jsx +19 -21
@@ -1,44 +1,42 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import classNames from 'classnames';
4
- import { withStyles } from '@material-ui/core/styles';
3
+ import { styled } from '@mui/material/styles';
5
4
  import { color } from '@pie-lib/render-ui';
6
5
 
7
- const styles = (theme) => ({
8
- container: {
9
- backgroundColor: color.defaults.WHITE,
10
- padding: '20px',
11
- width: '355px',
12
- boxShadow: '0px 1px 5px 0px #9297A6',
13
- },
14
- row: {
15
- display: 'flex',
16
- alignItems: 'center',
17
- padding: '10px',
18
- },
19
- title: {
20
- fontSize: theme.typography.h6.fontSize,
21
- marginLeft: '30px',
22
- fontWeight: '700',
23
- marginBottom: '10px',
24
- },
25
- text: {
26
- textAlign: 'right',
27
- marginRight: '10px',
28
- width: '175px',
29
- fontSize: '15px',
30
- },
6
+ const StyledContainer = styled('div')(({ theme }) => ({
7
+ backgroundColor: color.defaults.WHITE,
8
+ padding: '20px',
9
+ width: '355px',
10
+ boxShadow: '0px 1px 5px 0px #9297A6',
11
+ }));
12
+
13
+ const StyledRow = styled('div')({
14
+ display: 'flex',
15
+ alignItems: 'center',
16
+ padding: '10px',
31
17
  });
32
18
 
33
- const KeyLegend = ({ className, classes, isLabelAvailable }) => {
34
- const names = classNames(classes.formControl, className);
19
+ const StyledTitle = styled('div')(({ theme }) => ({
20
+ fontSize: theme.typography.h6.fontSize,
21
+ marginLeft: '30px',
22
+ fontWeight: '700',
23
+ marginBottom: '10px',
24
+ }));
25
+
26
+ const StyledText = styled('div')({
27
+ textAlign: 'right',
28
+ marginRight: '10px',
29
+ width: '175px',
30
+ fontSize: '15px',
31
+ });
35
32
 
33
+ const KeyLegend = ({ className, isLabelAvailable }) => {
36
34
  return (
37
- <div className={classes.container}>
38
- <div className={classes.title}>Key</div>
35
+ <StyledContainer className={className}>
36
+ <StyledTitle>Key</StyledTitle>
39
37
  {isLabelAvailable && (
40
- <div className={classes.row}>
41
- <div className={classes.text}> Missing Required Label </div>
38
+ <StyledRow>
39
+ <StyledText> Missing Required Label </StyledText>
42
40
  <svg width="34" height="16" viewBox="0 0 34 16" fill="none" xmlns="http://www.w3.org/2000/svg">
43
41
  <rect x="0.5" y="0.5" width="33" height="15" rx="3.5" fill="white" stroke="#BF0D00" />
44
42
  <path
@@ -50,10 +48,10 @@ const KeyLegend = ({ className, classes, isLabelAvailable }) => {
50
48
  fill="#BF0D00"
51
49
  />
52
50
  </svg>
53
- </div>
51
+ </StyledRow>
54
52
  )}
55
- <div className={classes.row}>
56
- <div className={classes.text}> Answer Key Correct </div>
53
+ <StyledRow>
54
+ <StyledText> Answer Key Correct </StyledText>
57
55
  <svg width="75" height="15" viewBox="0 0 75 15" fill="none" xmlns="http://www.w3.org/2000/svg">
58
56
  <circle cx="7.5" cy="7.5" r="7.5" fill="#6A78A1" />
59
57
  <path
@@ -62,10 +60,10 @@ const KeyLegend = ({ className, classes, isLabelAvailable }) => {
62
60
  />
63
61
  <path d="M75 7L15 7" stroke="#6A78A1" strokeDasharray="4 2" />
64
62
  </svg>
65
- </div>
63
+ </StyledRow>
66
64
  {isLabelAvailable && (
67
- <div className={classes.row}>
68
- <div className={classes.text}> Answer Key Correct Label </div>
65
+ <StyledRow>
66
+ <StyledText> Answer Key Correct Label </StyledText>
69
67
  <svg width="30" height="16" viewBox="0 0 30 16" fill="none" xmlns="http://www.w3.org/2000/svg">
70
68
  <rect x="0.5" y="0.5" width="29" height="15" rx="3.5" fill="white" />
71
69
  <rect x="0.5" y="0.5" width="29" height="15" rx="3.5" stroke="#6A78A1" />
@@ -74,10 +72,10 @@ const KeyLegend = ({ className, classes, isLabelAvailable }) => {
74
72
  fill="#6A78A1"
75
73
  />
76
74
  </svg>
77
- </div>
75
+ </StyledRow>
78
76
  )}
79
- <div className={classes.row}>
80
- <div className={classes.text}> Student Incorrect </div>
77
+ <StyledRow>
78
+ <StyledText> Student Incorrect </StyledText>
81
79
  <svg width="77" height="16" viewBox="0 0 77 16" fill="none" xmlns="http://www.w3.org/2000/svg">
82
80
  <circle cx="8" cy="8" r="8" fill="#BF0D00" />
83
81
  <path
@@ -86,10 +84,10 @@ const KeyLegend = ({ className, classes, isLabelAvailable }) => {
86
84
  />
87
85
  <path d="M77 8L15 8" stroke="#BF0D00" strokeWidth="3" />
88
86
  </svg>
89
- </div>
87
+ </StyledRow>
90
88
  {isLabelAvailable && (
91
- <div className={classes.row}>
92
- <div className={classes.text}> Incorrect Student Label </div>
89
+ <StyledRow>
90
+ <StyledText> Incorrect Student Label </StyledText>
93
91
  <svg width="42" height="16" viewBox="0 0 42 16" fill="none" xmlns="http://www.w3.org/2000/svg">
94
92
  <rect x="0.5" y="0.5" width="41" height="15" rx="3.5" fill="white" />
95
93
  <rect x="0.5" y="0.5" width="41" height="15" rx="3.5" stroke="#BF0D00" />
@@ -102,22 +100,21 @@ const KeyLegend = ({ className, classes, isLabelAvailable }) => {
102
100
  fill="#BF0D00"
103
101
  />
104
102
  </svg>
105
- </div>
103
+ </StyledRow>
106
104
  )}
107
- <div className={classes.row}>
108
- <div className={classes.text}> Student Correct </div>
105
+ <StyledRow>
106
+ <StyledText> Student Correct </StyledText>
109
107
  <svg width="76" height="16" viewBox="0 0 76 16" fill="none" xmlns="http://www.w3.org/2000/svg">
110
108
  <path d="M76 8L14 8" stroke="#0B7D38" strokeWidth="3" />
111
109
  <circle cx="8" cy="8" r="8" fill="#0B7D38" />
112
110
  <path
113
111
  d="M12.1953 4.46875C12.3125 4.35156 12.5 4.35156 12.5938 4.46875L13.2734 5.125C13.3672 5.24219 13.3672 5.42969 13.2734 5.52344L6.24219 12.5547C6.125 12.6719 5.96094 12.6719 5.84375 12.5547L2.70312 9.4375C2.60938 9.32031 2.60938 9.13281 2.70312 9.03906L3.38281 8.35938C3.47656 8.26562 3.66406 8.26562 3.78125 8.35938L6.03125 10.6328L12.1953 4.46875Z"
114
112
  fill="white"
115
- />
116
- </svg>
117
- </div>
113
+ /> </svg>
114
+ </StyledRow>
118
115
  {isLabelAvailable && (
119
- <div className={classes.row}>
120
- <div className={classes.text}> Student Correct Label </div>
116
+ <StyledRow>
117
+ <StyledText> Student Correct Label </StyledText>
121
118
  <svg width="43" height="16" viewBox="0 0 43 16" fill="none" xmlns="http://www.w3.org/2000/svg">
122
119
  <rect x="0.5" y="0.5" width="42" height="15" rx="3.5" fill="white" />
123
120
  <rect x="0.5" y="0.5" width="42" height="15" rx="3.5" stroke="#0B7D38" />
@@ -130,16 +127,15 @@ const KeyLegend = ({ className, classes, isLabelAvailable }) => {
130
127
  fill="#0B7D38"
131
128
  />
132
129
  </svg>
133
- </div>
130
+ </StyledRow>
134
131
  )}
135
- </div>
132
+ </StyledContainer>
136
133
  );
137
134
  };
138
135
 
139
136
  KeyLegend.propTypes = {
140
137
  className: PropTypes.string,
141
- classes: PropTypes.object.isRequired,
142
138
  isLabelAvailable: PropTypes.bool,
143
139
  };
144
140
 
145
- export default withStyles(styles)(KeyLegend);
141
+ export default KeyLegend;
package/src/labels.jsx CHANGED
@@ -1,10 +1,9 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { withStyles } from '@material-ui/core/styles';
3
+ import { styled } from '@mui/material/styles';
4
4
  import { types } from '@pie-lib/plot';
5
- import { color, Readable } from '@pie-lib/render-ui';
5
+ import { Readable } from '@pie-lib/render-ui';
6
6
  import EditableHtml from '@pie-lib/editable-html';
7
- import cn from 'classnames';
8
7
 
9
8
  const rotations = {
10
9
  left: -90,
@@ -43,11 +42,24 @@ const getY = (side, height) => {
43
42
  }
44
43
  };
45
44
 
45
+ const StyledEditableHtml = styled(EditableHtml, {
46
+ shouldForwardProp: (prop) => !['side', 'disabledLabel'].includes(prop),
47
+ })(({ theme, side, disabledLabel }) => ({
48
+ fontSize: theme.typography.fontSize - 2,
49
+ textAlign: 'center',
50
+ padding: '0 4px',
51
+ ...(side === 'bottom' && {
52
+ marginTop: '44px',
53
+ }),
54
+ ...(disabledLabel && {
55
+ pointerEvents: 'none',
56
+ }),
57
+ }));
58
+
46
59
  class RawLabel extends React.Component {
47
60
  static propTypes = {
48
61
  text: PropTypes.string,
49
62
  side: PropTypes.string,
50
- classes: PropTypes.object,
51
63
  disabledLabel: PropTypes.bool,
52
64
  placeholder: PropTypes.string,
53
65
  graphProps: types.GraphPropsType.isRequired,
@@ -59,7 +71,7 @@ class RawLabel extends React.Component {
59
71
  };
60
72
 
61
73
  render() {
62
- const { disabledLabel, placeholder, text, side, graphProps, classes, onChange, mathMlOptions = {} } = this.props;
74
+ const { disabledLabel, placeholder, text, side, graphProps, onChange, mathMlOptions = {} } = this.props;
63
75
  const { size, domain, range } = graphProps;
64
76
  const totalHeight = (size.height || 500) + (range.padding || 0) * 2;
65
77
  const totalWidth = (size.width || 500) + (domain.padding || 0) * 2;
@@ -89,14 +101,9 @@ class RawLabel extends React.Component {
89
101
  textAnchor="middle"
90
102
  >
91
103
  <Readable false>
92
- <EditableHtml
93
- className={cn(
94
- {
95
- [classes.bottomLabel]: side === 'bottom',
96
- [classes.disabledAxisLabel]: disabledLabel,
97
- },
98
- classes.axisLabel,
99
- )}
104
+ <StyledEditableHtml
105
+ side={side}
106
+ disabledLabel={disabledLabel}
100
107
  markup={text || ''}
101
108
  onChange={onChange}
102
109
  placeholder={!disabledLabel && placeholder}
@@ -114,22 +121,7 @@ class RawLabel extends React.Component {
114
121
  }
115
122
  }
116
123
 
117
- const Label = withStyles((theme) => ({
118
- label: {
119
- fill: color.defaults.SECONDARY,
120
- },
121
- axisLabel: {
122
- fontSize: theme.typography.fontSize - 2,
123
- textAlign: 'center',
124
- padding: '0 4px',
125
- },
126
- disabledAxisLabel: {
127
- pointerEvents: 'none',
128
- },
129
- bottomLabel: {
130
- marginTop: '44px',
131
- },
132
- }))(RawLabel);
124
+ const Label = RawLabel;
133
125
 
134
126
  export const LabelType = {
135
127
  left: PropTypes.string,
@@ -140,7 +132,6 @@ export const LabelType = {
140
132
 
141
133
  export class Labels extends React.Component {
142
134
  static propTypes = {
143
- classes: PropTypes.object,
144
135
  className: PropTypes.string,
145
136
  disabledLabels: PropTypes.bool,
146
137
  placeholders: PropTypes.object,
@@ -1,71 +1,75 @@
1
1
  import React, { useState, useCallback, useEffect } from 'react';
2
- import cn from 'classnames';
3
2
  import PropTypes from 'prop-types';
4
- import { withStyles } from '@material-ui/core/styles';
3
+ import { styled, useTheme } from '@mui/material/styles';
5
4
  import AutosizeInput from 'react-input-autosize';
6
5
  import { useDebounce } from './use-debounce';
7
6
  import { types } from '@pie-lib/plot';
8
7
  import { color } from '@pie-lib/render-ui';
9
8
  import SvgIcon from './label-svg-icon';
10
9
 
11
- const inputStyles = (theme) => ({
10
+ const StyledInputCorrect = styled('div')(({ theme }) => ({
12
11
  float: 'right',
13
- padding: theme.spacing.unit * 0.5,
12
+ padding: theme.spacing(0.5),
14
13
  borderRadius: '4px',
15
14
  fontSize: '10px',
16
15
  backgroundColor: color.defaults.WHITE,
16
+ color: color.defaults.CORRECT_WITH_ICON,
17
+ border: `solid 1px ${color.defaults.CORRECT_WITH_ICON}`,
18
+ }));
19
+
20
+ const StyledInputIncorrect = styled('div')(({ theme }) => ({
21
+ float: 'right',
22
+ padding: theme.spacing(0.5),
23
+ borderRadius: '4px',
24
+ fontSize: '10px',
25
+ backgroundColor: color.defaults.WHITE,
26
+ color: color.defaults.INCORRECT_WITH_ICON,
27
+ border: `solid 1px ${color.defaults.INCORRECT_WITH_ICON}`,
28
+ }));
29
+
30
+ const StyledInputMissing = styled('div')(({ theme }) => ({
31
+ float: 'right',
32
+ padding: theme.spacing(0.5),
33
+ borderRadius: '4px',
34
+ fontSize: '10px',
35
+ backgroundColor: color.defaults.WHITE,
36
+ color: color.defaults.MISSING_WITH_ICON,
37
+ border: `solid 1px ${color.defaults.MISSING_WITH_ICON}`,
38
+ fontWeight: 'bold',
39
+ }));
40
+
41
+ const StyledIncorrect = styled('div')(({ theme }) => ({
42
+ float: 'right',
43
+ padding: 0,
44
+ borderRadius: '4px',
45
+ fontSize: '10px',
46
+ backgroundColor: color.defaults.WHITE,
47
+ color: color.defaults.INCORRECT_WITH_ICON,
48
+ fontWeight: 'bold',
49
+ }));
50
+
51
+ const getInputStyles = (theme, disabled, markDisabled) => ({
52
+ float: 'right',
53
+ padding: theme.spacing(0.5),
54
+ fontFamily: theme.typography.fontFamily,
55
+ fontSize: '10px',
56
+ border: disabled
57
+ ? `solid 1px ${color.defaults.PRIMARY_DARK}`
58
+ : markDisabled
59
+ ? `solid 1px ${color.disabled()}`
60
+ : `solid 1px ${color.defaults.SECONDARY}`,
61
+ borderRadius: '3px',
62
+ color: markDisabled ? color.disabled() : color.defaults.PRIMARY_DARK,
63
+ backgroundColor: color.defaults.WHITE,
64
+ WebkitOpacity: disabled ? '1' : undefined,
65
+ WebkitTextFillColor: markDisabled ? color.disabled() : undefined,
17
66
  });
18
67
 
19
- const styles = (theme) => ({
20
- inputStudent: {
21
- ...inputStyles(theme),
22
- padding: '0',
23
- border: 'none',
24
- color: 'inherit',
25
- fontWeight: 'bold',
26
- },
27
- input: {
28
- float: 'right',
29
- padding: theme.spacing.unit * 0.5,
30
- fontFamily: theme.typography.fontFamily,
31
- fontSize: '10px',
32
- border: `solid 1px ${color.defaults.SECONDARY}`,
33
- borderRadius: '3px',
34
- color: color.defaults.PRIMARY_DARK,
35
- backgroundColor: color.defaults.WHITE,
36
- },
37
- disabled: {
38
- border: `solid 1px ${color.defaults.PRIMARY_DARK}`,
39
- backgroundColor: color.defaults.WHITE,
40
- '-webkit-opacity': '1',
41
- },
42
- disabledMark: {
43
- border: `solid 1px ${color.disabled()}`,
44
- color: color.disabled(),
45
- '-webkit-text-fill-color': color.disabled(),
46
- },
47
- inputCorrect: {
48
- ...inputStyles(theme),
49
- color: color.defaults.CORRECT_WITH_ICON,
50
- border: `solid 1px ${color.defaults.CORRECT_WITH_ICON}`,
51
- },
52
- inputIncorrect: {
53
- ...inputStyles(theme),
54
- color: color.defaults.INCORRECT_WITH_ICON,
55
- border: `solid 1px ${color.defaults.INCORRECT_WITH_ICON}`,
56
- },
57
- inputMissing: {
58
- ...inputStyles(theme),
59
- color: color.defaults.MISSING_WITH_ICON,
60
- border: `solid 1px ${color.defaults.MISSING_WITH_ICON}`,
61
- fontWeight: 'bold',
62
- },
63
- incorrect: {
64
- ...inputStyles(theme),
65
- color: color.defaults.INCORRECT_WITH_ICON,
66
- fontWeight: 'bold',
67
- padding: '0',
68
- },
68
+ const getStudentInputStyles = () => ({
69
+ padding: '0',
70
+ border: 'none',
71
+ color: 'inherit',
72
+ fontWeight: 'bold',
69
73
  });
70
74
 
71
75
  export const position = (graphProps, mark, rect = { width: 0, height: 0 }) => {
@@ -99,14 +103,14 @@ export const coordinates = (graphProps, mark, rect = { width: 0, height: 0 }, po
99
103
  }
100
104
  };
101
105
 
102
- const LabelInput = ({ _ref, externalInputRef, label, disabled, inputClassName, onChange }) => (
106
+ const LabelInput = ({ _ref, externalInputRef, label, disabled, inputStyle, onChange }) => (
103
107
  <AutosizeInput
104
108
  inputRef={(r) => {
105
109
  _ref(r);
106
110
  externalInputRef(r);
107
111
  }}
108
112
  disabled={disabled}
109
- inputClassName={inputClassName}
113
+ inputStyle={inputStyle}
110
114
  value={label}
111
115
  onChange={onChange}
112
116
  />
@@ -115,8 +119,9 @@ const LabelInput = ({ _ref, externalInputRef, label, disabled, inputClassName, o
115
119
  export const MarkLabel = (props) => {
116
120
  const [input, setInput] = useState(null);
117
121
  const _ref = useCallback((node) => setInput(node));
122
+ const theme = useTheme();
118
123
 
119
- const { mark, graphProps, classes, disabled, inputRef: externalInputRef, theme } = props;
124
+ const { mark, graphProps, disabled, inputRef: externalInputRef } = props;
120
125
 
121
126
  const [label, setLabel] = useState(mark.label);
122
127
  const { correctness, correctnesslabel, correctlabel } = mark;
@@ -156,23 +161,25 @@ export const MarkLabel = (props) => {
156
161
 
157
162
  const disabledInput = disabled || mark.disabled;
158
163
 
159
- const renderInput = (inputClass, labelValue) => (
164
+ const renderInput = (inputStyle, labelValue) => (
160
165
  <LabelInput
161
166
  _ref={_ref}
162
167
  externalInputRef={externalInputRef}
163
168
  label={labelValue}
164
169
  disabled={disabledInput}
165
- inputClassName={cn(inputClass)}
170
+ inputStyle={inputStyle}
166
171
  onChange={onChange}
167
172
  />
168
173
  );
169
174
 
175
+ const studentInputStyle = getStudentInputStyles();
176
+
170
177
  if (correctness === 'correct' && correctnesslabel === 'correct' && correctlabel) {
171
178
  return (
172
- <div className={classes.inputCorrect} style={style}>
179
+ <StyledInputCorrect style={style}>
173
180
  <SvgIcon type="correct" />
174
- {renderInput(classes.inputStudent, correctlabel)}
175
- </div>
181
+ {renderInput(studentInputStyle, correctlabel)}
182
+ </StyledInputCorrect>
176
183
  );
177
184
  }
178
185
 
@@ -184,44 +191,41 @@ export const MarkLabel = (props) => {
184
191
  if (correctness === 'correct' && correctnesslabel === 'incorrect') {
185
192
  return (
186
193
  <>
187
- <div className={classes.inputIncorrect} style={style}>
194
+ <StyledInputIncorrect style={style}>
188
195
  <SvgIcon type="incorrect" />
189
196
  {label === '' ? (
190
197
  <SvgIcon type="empty" style={{ marginLeft: '3px' }} />
191
198
  ) : (
192
- renderInput(classes.inputStudent, label)
199
+ renderInput(studentInputStyle, label)
193
200
  )}
194
- </div>
195
- <div className={classes.inputMissing} style={secondLabelStyle}>
196
- {renderInput(classes.inputStudent, correctlabel)}
197
- </div>
201
+ </StyledInputIncorrect>
202
+ <StyledInputMissing style={secondLabelStyle}>
203
+ {renderInput(studentInputStyle, correctlabel)}
204
+ </StyledInputMissing>
198
205
  </>
199
206
  );
200
207
  }
201
208
 
202
209
  if (correctness === 'missing') {
203
210
  return (
204
- <div className={classes.inputMissing} style={style}>
205
- {renderInput(classes.inputStudent, label)}
206
- </div>
211
+ <StyledInputMissing style={style}>
212
+ {renderInput(studentInputStyle, label)}
213
+ </StyledInputMissing>
207
214
  );
208
215
  }
209
216
 
210
217
  if (correctness === 'incorrect') {
211
218
  return (
212
- <div className={classes.incorrect} style={style}>
213
- {renderInput(classes.inputStudent, label)}
214
- </div>
219
+ <StyledIncorrect style={style}>
220
+ {renderInput(studentInputStyle, label)}
221
+ </StyledIncorrect>
215
222
  );
216
223
  }
217
224
 
218
225
  return (
219
226
  <div style={style}>
220
227
  {renderInput(
221
- cn(classes.input, {
222
- [classes.disabled]: disabled,
223
- [classes.disabledMark]: mark.disabled,
224
- }),
228
+ getInputStyles(theme, disabled, mark.disabled),
225
229
  label,
226
230
  )}
227
231
  </div>
@@ -232,10 +236,8 @@ MarkLabel.propTypes = {
232
236
  disabled: PropTypes.bool,
233
237
  onChange: PropTypes.func,
234
238
  graphProps: types.GraphPropsType,
235
- classes: PropTypes.object,
236
239
  inputRef: PropTypes.func,
237
240
  mark: PropTypes.object,
238
- theme: PropTypes.object,
239
241
  };
240
242
 
241
- export default withStyles(styles, { withTheme: true })(MarkLabel);
243
+ export default MarkLabel;