@pie-lib/graphing 2.14.22-next.0 → 2.14.22-next.1618

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 (194) hide show
  1. package/CHANGELOG.json +1 -1017
  2. package/CHANGELOG.md +159 -24
  3. package/NEXT.CHANGELOG.json +1 -0
  4. package/lib/axis/axes.js +5 -5
  5. package/lib/axis/axes.js.map +1 -1
  6. package/lib/container/index.js +1 -4
  7. package/lib/container/index.js.map +1 -1
  8. package/lib/coordinates-label.js +5 -3
  9. package/lib/coordinates-label.js.map +1 -1
  10. package/lib/graph-with-controls.js +8 -15
  11. package/lib/graph-with-controls.js.map +1 -1
  12. package/lib/graph.js +29 -12
  13. package/lib/graph.js.map +1 -1
  14. package/lib/grid.js +6 -14
  15. package/lib/grid.js.map +1 -1
  16. package/lib/index.js +8 -0
  17. package/lib/index.js.map +1 -1
  18. package/lib/key-legend.js +246 -0
  19. package/lib/key-legend.js.map +1 -0
  20. package/lib/label-svg-icon.js +56 -0
  21. package/lib/label-svg-icon.js.map +1 -0
  22. package/lib/labels.js +2 -1
  23. package/lib/labels.js.map +1 -1
  24. package/lib/mark-label.js +167 -56
  25. package/lib/mark-label.js.map +1 -1
  26. package/lib/toggle-bar.js +3 -4
  27. package/lib/toggle-bar.js.map +1 -1
  28. package/lib/tool-menu.js +2 -22
  29. package/lib/tool-menu.js.map +1 -1
  30. package/lib/tools/absolute/component.js +35 -0
  31. package/lib/tools/absolute/component.js.map +1 -0
  32. package/lib/tools/absolute/index.js +63 -0
  33. package/lib/tools/absolute/index.js.map +1 -0
  34. package/lib/tools/circle/bg-circle.js +4 -3
  35. package/lib/tools/circle/bg-circle.js.map +1 -1
  36. package/lib/tools/circle/component.js +34 -15
  37. package/lib/tools/circle/component.js.map +1 -1
  38. package/lib/tools/exponential/component.js +34 -0
  39. package/lib/tools/exponential/component.js.map +1 -0
  40. package/lib/tools/exponential/index.js +71 -0
  41. package/lib/tools/exponential/index.js.map +1 -0
  42. package/lib/tools/index.js +26 -6
  43. package/lib/tools/index.js.map +1 -1
  44. package/lib/tools/line/component.js +2 -1
  45. package/lib/tools/line/component.js.map +1 -1
  46. package/lib/tools/parabola/component.js +6 -5
  47. package/lib/tools/parabola/component.js.map +1 -1
  48. package/lib/tools/point/component.js +14 -9
  49. package/lib/tools/point/component.js.map +1 -1
  50. package/lib/tools/polygon/component.js +25 -12
  51. package/lib/tools/polygon/component.js.map +1 -1
  52. package/lib/tools/polygon/line.js +12 -6
  53. package/lib/tools/polygon/line.js.map +1 -1
  54. package/lib/tools/polygon/polygon.js +6 -3
  55. package/lib/tools/polygon/polygon.js.map +1 -1
  56. package/lib/tools/ray/component.js +2 -1
  57. package/lib/tools/ray/component.js.map +1 -1
  58. package/lib/tools/segment/component.js +2 -1
  59. package/lib/tools/segment/component.js.map +1 -1
  60. package/lib/tools/shared/icons/CorrectSVG.js +36 -0
  61. package/lib/tools/shared/icons/CorrectSVG.js.map +1 -0
  62. package/lib/tools/shared/icons/IncorrectSVG.js +36 -0
  63. package/lib/tools/shared/icons/IncorrectSVG.js.map +1 -0
  64. package/lib/tools/shared/icons/MissingSVG.js +35 -0
  65. package/lib/tools/shared/icons/MissingSVG.js.map +1 -0
  66. package/lib/tools/shared/line/index.js +51 -19
  67. package/lib/tools/shared/line/index.js.map +1 -1
  68. package/lib/tools/shared/line/line-path.js +13 -7
  69. package/lib/tools/shared/line/line-path.js.map +1 -1
  70. package/lib/tools/shared/line/with-root-edge.js +19 -8
  71. package/lib/tools/shared/line/with-root-edge.js.map +1 -1
  72. package/lib/tools/shared/point/arrow-point.js +1 -1
  73. package/lib/tools/shared/point/arrow-point.js.map +1 -1
  74. package/lib/tools/shared/point/arrow.js +1 -1
  75. package/lib/tools/shared/point/arrow.js.map +1 -1
  76. package/lib/tools/shared/point/base-point.js +43 -7
  77. package/lib/tools/shared/point/base-point.js.map +1 -1
  78. package/lib/tools/shared/point/index.js +4 -1
  79. package/lib/tools/shared/point/index.js.map +1 -1
  80. package/lib/tools/shared/styles.js +16 -7
  81. package/lib/tools/shared/styles.js.map +1 -1
  82. package/lib/tools/sine/component.js +13 -4
  83. package/lib/tools/sine/component.js.map +1 -1
  84. package/lib/tools/vector/component.js +2 -1
  85. package/lib/tools/vector/component.js.map +1 -1
  86. package/lib/undo-redo.js +0 -1
  87. package/lib/undo-redo.js.map +1 -1
  88. package/lib/utils.js +1 -1
  89. package/lib/utils.js.map +1 -1
  90. package/package.json +12 -7
  91. package/src/__tests__/__snapshots__/graph-with-controls.test.jsx.snap +237 -0
  92. package/src/__tests__/__snapshots__/graph.test.jsx.snap +211 -0
  93. package/src/__tests__/__snapshots__/grid.test.jsx.snap +54 -0
  94. package/src/__tests__/__snapshots__/labels.test.jsx.snap +30 -0
  95. package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +45 -0
  96. package/src/__tests__/__snapshots__/toggle-bar.test.jsx.snap +7 -0
  97. package/src/__tests__/__snapshots__/tool-menu.test.jsx.snap +13 -0
  98. package/src/__tests__/__snapshots__/undo-redo.test.jsx.snap +14 -0
  99. package/src/__tests__/graph-with-controls.test.jsx +147 -0
  100. package/src/__tests__/graph.test.jsx +230 -0
  101. package/src/__tests__/grid.test.jsx +20 -0
  102. package/src/__tests__/labels.test.jsx +38 -0
  103. package/src/__tests__/mark-label.test.jsx +68 -0
  104. package/src/__tests__/toggle-bar.test.jsx +36 -0
  105. package/src/__tests__/tool-menu.test.jsx +29 -0
  106. package/src/__tests__/undo-redo.test.jsx +25 -0
  107. package/src/__tests__/use-debounce.test.js +21 -0
  108. package/src/__tests__/utils.js +38 -0
  109. package/src/__tests__/utils.test.js +151 -0
  110. package/src/axis/__tests__/__snapshots__/arrow.test.jsx.snap +33 -0
  111. package/src/axis/__tests__/__snapshots__/axes.test.jsx.snap +122 -0
  112. package/src/axis/__tests__/arrow.test.jsx +39 -0
  113. package/src/axis/__tests__/axes.test.jsx +220 -0
  114. package/src/axis/axes.jsx +5 -5
  115. package/src/container/index.jsx +2 -4
  116. package/src/coordinates-label.jsx +4 -3
  117. package/src/graph-with-controls.jsx +8 -10
  118. package/src/graph.jsx +22 -10
  119. package/src/grid.jsx +8 -10
  120. package/src/index.js +2 -2
  121. package/src/key-legend.jsx +145 -0
  122. package/src/label-svg-icon.jsx +39 -0
  123. package/src/labels.jsx +2 -1
  124. package/src/mark-label.jsx +149 -52
  125. package/src/toggle-bar.jsx +1 -2
  126. package/src/tool-menu.jsx +3 -26
  127. package/src/tools/absolute/__tests__/component.test.jsx +54 -0
  128. package/src/tools/absolute/component.jsx +23 -0
  129. package/src/tools/absolute/index.js +31 -0
  130. package/src/tools/circle/__tests__/__snapshots__/bg-circle.test.jsx.snap +46 -0
  131. package/src/tools/circle/__tests__/__snapshots__/component.test.jsx.snap +293 -0
  132. package/src/tools/circle/__tests__/bg-circle.test.jsx +28 -0
  133. package/src/tools/circle/__tests__/component.test.jsx +228 -0
  134. package/src/tools/circle/bg-circle.jsx +5 -4
  135. package/src/tools/circle/component.jsx +22 -8
  136. package/src/tools/exponential/__tests__/component.test.jsx +54 -0
  137. package/src/tools/exponential/component.jsx +23 -0
  138. package/src/tools/exponential/index.js +39 -0
  139. package/src/tools/index.js +38 -5
  140. package/src/tools/line/__tests__/__snapshots__/component.test.jsx.snap +20 -0
  141. package/src/tools/line/__tests__/component.test.jsx +36 -0
  142. package/src/tools/line/component.jsx +2 -1
  143. package/src/tools/parabola/__tests__/component.test.jsx +49 -0
  144. package/src/tools/parabola/component.jsx +7 -6
  145. package/src/tools/point/__tests__/__snapshots__/component.test.jsx.snap +40 -0
  146. package/src/tools/point/__tests__/component.test.jsx +66 -0
  147. package/src/tools/point/component.jsx +12 -6
  148. package/src/tools/polygon/__tests__/__snapshots__/component.test.jsx.snap +415 -0
  149. package/src/tools/polygon/__tests__/__snapshots__/line.test.jsx.snap +45 -0
  150. package/src/tools/polygon/__tests__/__snapshots__/polygon.test.jsx.snap +52 -0
  151. package/src/tools/polygon/__tests__/component.test.jsx +226 -0
  152. package/src/tools/polygon/__tests__/index.test.js +65 -0
  153. package/src/tools/polygon/__tests__/line.test.jsx +25 -0
  154. package/src/tools/polygon/__tests__/polygon.test.jsx +44 -0
  155. package/src/tools/polygon/component.jsx +39 -11
  156. package/src/tools/polygon/line.jsx +15 -7
  157. package/src/tools/polygon/polygon.jsx +7 -3
  158. package/src/tools/ray/__tests__/__snapshots__/component.test.jsx.snap +23 -0
  159. package/src/tools/ray/__tests__/component.test.jsx +29 -0
  160. package/src/tools/ray/component.jsx +2 -1
  161. package/src/tools/segment/__tests__/__snapshots__/component.test.jsx.snap +14 -0
  162. package/src/tools/segment/__tests__/component.test.jsx +28 -0
  163. package/src/tools/segment/component.jsx +2 -1
  164. package/src/tools/shared/__tests__/__snapshots__/arrow-head.test.jsx.snap +27 -0
  165. package/src/tools/shared/__tests__/arrow-head.test.jsx +34 -0
  166. package/src/tools/shared/icons/CorrectSVG.jsx +22 -0
  167. package/src/tools/shared/icons/IncorrectSVG.jsx +20 -0
  168. package/src/tools/shared/icons/MissingSVG.jsx +21 -0
  169. package/src/tools/shared/line/__tests__/__snapshots__/index.test.jsx.snap +360 -0
  170. package/src/tools/shared/line/__tests__/__snapshots__/line-path.test.jsx.snap +58 -0
  171. package/src/tools/shared/line/__tests__/__snapshots__/with-root-edge.test.jsx.snap +63 -0
  172. package/src/tools/shared/line/__tests__/index.test.jsx +255 -0
  173. package/src/tools/shared/line/__tests__/line-path.test.jsx +53 -0
  174. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +73 -0
  175. package/src/tools/shared/line/index.jsx +39 -13
  176. package/src/tools/shared/line/line-path.jsx +18 -7
  177. package/src/tools/shared/line/with-root-edge.jsx +10 -3
  178. package/src/tools/shared/point/__tests__/__snapshots__/arrow-point.test.jsx.snap +56 -0
  179. package/src/tools/shared/point/__tests__/__snapshots__/base-point.test.jsx.snap +44 -0
  180. package/src/tools/shared/point/__tests__/arrow-point.test.jsx +87 -0
  181. package/src/tools/shared/point/__tests__/base-point.test.jsx +84 -0
  182. package/src/tools/shared/point/arrow-point.jsx +4 -1
  183. package/src/tools/shared/point/arrow.jsx +4 -1
  184. package/src/tools/shared/point/base-point.jsx +28 -3
  185. package/src/tools/shared/point/index.jsx +7 -2
  186. package/src/tools/shared/styles.js +8 -3
  187. package/src/tools/sine/__tests__/component.test.jsx +51 -0
  188. package/src/tools/sine/component.jsx +7 -7
  189. package/src/tools/vector/__tests__/__snapshots__/component.test.jsx.snap +12 -0
  190. package/src/tools/vector/__tests__/component.test.jsx +26 -0
  191. package/src/tools/vector/component.jsx +2 -1
  192. package/src/undo-redo.jsx +0 -1
  193. package/src/utils.js +1 -1
  194. package/legacy.png +0 -0
@@ -0,0 +1,44 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`BasePoint snapshot renders 1`] = `
4
+ <RawBp
5
+ className="className"
6
+ classes={
7
+ Object {
8
+ "correct": "RawBp-correct-4",
9
+ "disabled": "RawBp-disabled-2",
10
+ "disabledSecondary": "RawBp-disabledSecondary-3",
11
+ "incorrect": "RawBp-incorrect-5",
12
+ "missing": "RawBp-missing-6",
13
+ "point": "RawBp-point-1",
14
+ }
15
+ }
16
+ graphProps={
17
+ Object {
18
+ "domain": Object {
19
+ "max": 1,
20
+ "min": 0,
21
+ "step": 1,
22
+ },
23
+ "range": Object {
24
+ "max": 1,
25
+ "min": 0,
26
+ "step": 1,
27
+ },
28
+ "scale": Object {
29
+ "x": [MockFunction],
30
+ "y": [MockFunction],
31
+ },
32
+ "size": Object {
33
+ "height": 400,
34
+ "width": 400,
35
+ },
36
+ "snap": Object {
37
+ "x": [MockFunction],
38
+ "y": [MockFunction],
39
+ },
40
+ }
41
+ }
42
+ onChange={[MockFunction]}
43
+ />
44
+ `;
@@ -0,0 +1,87 @@
1
+ import { shallow } from 'enzyme/build';
2
+ import React from 'react';
3
+ import { ArrowPoint } from '../index';
4
+ import { graphProps } from '../../../../__tests__/utils';
5
+ import { bounds } from '../../../../utils';
6
+ import { gridDraggable, utils } from '@pie-lib/plot';
7
+
8
+ const { xy } = utils;
9
+ jest.mock('../../../../utils', () => {
10
+ const { point } = jest.requireActual('../../../../utils');
11
+ return {
12
+ bounds: jest.fn(),
13
+ point,
14
+ };
15
+ });
16
+
17
+ jest.mock('@pie-lib/plot', () => {
18
+ const { types, utils } = jest.requireActual('@pie-lib/plot');
19
+ return {
20
+ gridDraggable: jest.fn((opts) => (Comp) => Comp),
21
+ types,
22
+ utils,
23
+ };
24
+ });
25
+
26
+ describe('ArrowPoint', () => {
27
+ let w;
28
+ let onChange = jest.fn();
29
+ const wrapper = (extras) => {
30
+ const defaults = {
31
+ classes: {},
32
+ className: 'className',
33
+ onChange,
34
+ graphProps: graphProps(),
35
+ from: xy(0, 0),
36
+ to: xy(1, 1),
37
+ };
38
+ const props = { ...defaults, ...extras };
39
+ return shallow(<ArrowPoint {...props} />);
40
+ };
41
+
42
+ describe('snapshot', () => {
43
+ it('renders', () => {
44
+ w = wrapper();
45
+ expect(w).toMatchSnapshot();
46
+ });
47
+ });
48
+ describe('gridDraggable options', () => {
49
+ let opts;
50
+ let domain;
51
+ let range;
52
+ beforeEach(() => {
53
+ domain = {
54
+ min: 0,
55
+ max: 1,
56
+ step: 1,
57
+ };
58
+ range = {
59
+ min: 0,
60
+ max: 1,
61
+ step: 1,
62
+ };
63
+ const w = wrapper();
64
+ opts = gridDraggable.mock.calls[0][0];
65
+ });
66
+
67
+ describe('bounds', () => {
68
+ it('calls utils.bounds with area', () => {
69
+ const result = opts.bounds({ x: 0, y: 0 }, { domain, range });
70
+ expect(bounds).toHaveBeenCalledWith({ left: 0, top: 0, bottom: 0, right: 0 }, domain, range);
71
+ });
72
+ });
73
+ describe('anchorPoint', () => {
74
+ it('returns x/y', () => {
75
+ const result = opts.anchorPoint({ x: 0, y: 0 });
76
+ expect(result).toEqual({ x: 0, y: 0 });
77
+ });
78
+ });
79
+
80
+ describe('fromDelta', () => {
81
+ it('returns a new point from the x/y + delta', () => {
82
+ const result = opts.fromDelta({ x: -1, y: 0 }, { x: 1, y: 3 });
83
+ expect(result).toEqual({ x: 0, y: 3 });
84
+ });
85
+ });
86
+ });
87
+ });
@@ -0,0 +1,84 @@
1
+ import { shallow } from 'enzyme/build';
2
+ import React from 'react';
3
+ import { BasePoint } from '../index';
4
+ import { gridDraggable } from '@pie-lib/plot';
5
+ import { graphProps } from '../../../../__tests__/utils';
6
+ import { bounds } from '../../../../utils';
7
+
8
+ jest.mock('../../../../utils', () => {
9
+ const { point } = jest.requireActual('../../../../utils');
10
+ return {
11
+ bounds: jest.fn(),
12
+ point,
13
+ };
14
+ });
15
+
16
+ jest.mock('@pie-lib/plot', () => {
17
+ const { types, utils } = jest.requireActual('@pie-lib/plot');
18
+ return {
19
+ gridDraggable: jest.fn((opts) => (Comp) => Comp),
20
+ types,
21
+ utils,
22
+ };
23
+ });
24
+
25
+ describe('BasePoint', () => {
26
+ let w;
27
+ let onChange = jest.fn();
28
+ const wrapper = (extras) => {
29
+ const defaults = {
30
+ classes: {},
31
+ className: 'className',
32
+ onChange,
33
+ graphProps: graphProps(),
34
+ };
35
+ const props = { ...defaults, ...extras };
36
+ return shallow(<BasePoint {...props} />);
37
+ };
38
+
39
+ describe('snapshot', () => {
40
+ it('renders', () => {
41
+ w = wrapper();
42
+ expect(w).toMatchSnapshot();
43
+ });
44
+ });
45
+ describe('gridDraggable options', () => {
46
+ let opts;
47
+ let domain;
48
+ let range;
49
+ beforeEach(() => {
50
+ domain = {
51
+ min: 0,
52
+ max: 1,
53
+ step: 1,
54
+ };
55
+ range = {
56
+ min: 0,
57
+ max: 1,
58
+ step: 1,
59
+ };
60
+ const w = wrapper();
61
+ opts = gridDraggable.mock.calls[0][0];
62
+ });
63
+
64
+ describe('bounds', () => {
65
+ it('calls utils.bounds with area', () => {
66
+ const result = opts.bounds({ x: 0, y: 0 }, { domain, range });
67
+ expect(bounds).toHaveBeenCalledWith({ left: 0, top: 0, bottom: 0, right: 0 }, domain, range);
68
+ });
69
+ });
70
+ describe('anchorPoint', () => {
71
+ it('returns x/y', () => {
72
+ const result = opts.anchorPoint({ x: 0, y: 0 });
73
+ expect(result).toEqual({ x: 0, y: 0 });
74
+ });
75
+ });
76
+
77
+ describe('fromDelta', () => {
78
+ it('returns a new point from the x/y + delta', () => {
79
+ const result = opts.fromDelta({ x: -1, y: 0 }, { x: 1, y: 3 });
80
+ expect(result).toEqual({ x: 0, y: 3 });
81
+ });
82
+ });
83
+ });
84
+ });
@@ -47,7 +47,10 @@ export class RawArrow extends React.Component {
47
47
  }
48
48
 
49
49
  return (
50
- <g className={classNames(classes.point, disabled && classes.disabled, classes[correctness], className)} {...rest}>
50
+ <g
51
+ className={classNames(classes.point, disabled && classes.disabledSecondary, classes[correctness], className)}
52
+ {...rest}
53
+ >
51
54
  <polygon
52
55
  points={points}
53
56
  transform={`
@@ -32,7 +32,10 @@ export default class Arrow extends React.Component {
32
32
  ${scaledX - size}, ${scaledY + size / 2}`;
33
33
 
34
34
  return (
35
- <g className={classNames(classes.point, disabled && classes.disabled, classes[correctness], className)} {...rest}>
35
+ <g
36
+ className={classNames(classes.point, disabled && classes.disabledSecondary, classes[correctness], className)}
37
+ {...rest}
38
+ >
36
39
  <ArrowHead size={size} transform={transform} points={points} />
37
40
  </g>
38
41
  );
@@ -5,6 +5,9 @@ import { types } from '@pie-lib/plot';
5
5
  import CoordinatesLabel from '../../../coordinates-label';
6
6
  import ReactDOM from 'react-dom';
7
7
  import { thinnerShapesNeeded } from '../../../utils';
8
+ import MissingSVG from '../icons/MissingSVG';
9
+ import CorrectSVG from '../icons/CorrectSVG';
10
+ import IncorrectSVG from '../icons/IncorrectSVG';
8
11
 
9
12
  export class RawBp extends React.Component {
10
13
  static propTypes = {
@@ -38,11 +41,31 @@ export class RawBp extends React.Component {
38
41
  // we need to remove style from props
39
42
  // eslint-disable-next-line no-unused-vars,react/prop-types
40
43
  style,
44
+ onClick,
45
+ // Refactored RawBp component by isolating onTouchStart and onTouchEnd handlers to the outer circle, resolving erratic touch event behavior.
46
+ // Remaining props are now applied only to the inner circle for improved event handling consistency.
47
+ onTouchStart,
48
+ onTouchEnd,
41
49
  ...rest
42
50
  } = this.props;
43
51
  const { showCoordinates } = this.state;
44
52
  const { scale } = graphProps;
45
53
  const r = thinnerShapesNeeded(graphProps) ? 5 : 7;
54
+ let SvgComponent;
55
+ switch (correctness) {
56
+ case 'missing':
57
+ SvgComponent = MissingSVG;
58
+ break;
59
+ case 'correct':
60
+ SvgComponent = CorrectSVG;
61
+ break;
62
+ case 'incorrect':
63
+ SvgComponent = IncorrectSVG;
64
+ break;
65
+ default:
66
+ SvgComponent = null;
67
+ break;
68
+ }
46
69
 
47
70
  return (
48
71
  <>
@@ -53,15 +76,17 @@ export class RawBp extends React.Component {
53
76
  cy={scale.y(y)}
54
77
  onMouseEnter={() => this.setState({ showCoordinates: true })}
55
78
  onMouseLeave={() => this.setState({ showCoordinates: false })}
56
- {...rest}
79
+ onTouchStart={onTouchStart}
80
+ onTouchEnd={onTouchEnd}
81
+ onClick={onClick}
57
82
  />
58
83
  <g
59
- className={classNames(classes.point, disabled && classes.disabled, classes[correctness], className)}
84
+ className={classNames(classes.point, disabled && classes.disabledSecondary, classes[correctness], className)}
60
85
  onMouseEnter={() => this.setState({ showCoordinates: true })}
61
86
  onMouseLeave={() => this.setState({ showCoordinates: false })}
62
- {...rest}
63
87
  >
64
88
  <circle {...rest} r={r} cx={scale.x(x)} cy={scale.y(y)} />
89
+ {SvgComponent && <SvgComponent scale={scale} x={x} y={y} />}
65
90
  {labelNode &&
66
91
  coordinatesOnHover &&
67
92
  showCoordinates &&
@@ -1,7 +1,7 @@
1
1
  import { withStyles } from '@material-ui/core/styles/index';
2
2
  import { gridDraggable } from '@pie-lib/plot';
3
3
  import * as utils from '../../../utils';
4
- import { disabled, correct, incorrect, missing } from '../styles';
4
+ import { disabled, correct, incorrect, missing, disabledSecondary } from '../styles';
5
5
  import { RawBp } from './base-point';
6
6
  import { RawArrow } from './arrow-point';
7
7
  import { color } from '@pie-lib/render-ui';
@@ -29,7 +29,7 @@ const styles = () => {
29
29
  point: {
30
30
  '& circle, & polygon': {
31
31
  cursor: 'pointer',
32
- fill: color.secondary(),
32
+ fill: color.defaults.BLACK,
33
33
  },
34
34
  },
35
35
  disabled: {
@@ -37,6 +37,11 @@ const styles = () => {
37
37
  ...disabled(),
38
38
  },
39
39
  },
40
+ disabledSecondary: {
41
+ '& circle, & polygon': {
42
+ ...disabledSecondary(),
43
+ },
44
+ },
40
45
  correct: {
41
46
  '& circle, & polygon': {
42
47
  ...correct(),
@@ -5,16 +5,21 @@ export const disabled = (key = 'fill') => ({
5
5
  pointerEvents: 'none',
6
6
  });
7
7
 
8
+ export const disabledSecondary = (key = 'fill') => ({
9
+ [key]: color.disabledSecondary(),
10
+ pointerEvents: 'none',
11
+ });
12
+
8
13
  export const correct = (key = 'fill') => ({
9
- [key]: color.correct(),
14
+ [key]: color.correctWithIcon(),
10
15
  pointerEvents: 'none',
11
16
  });
12
17
  export const incorrect = (key = 'fill') => ({
13
- [key]: color.incorrect(),
18
+ [key]: color.incorrectWithIcon(),
14
19
  pointerEvents: 'none',
15
20
  });
16
21
 
17
22
  export const missing = (key = 'fill') => ({
18
- [key]: color.missing(),
23
+ [key]: color.missingWithIcon(),
19
24
  pointerEvents: 'none',
20
25
  });
@@ -0,0 +1,51 @@
1
+ import { withRootEdge } from '../../shared/line/with-root-edge';
2
+ import { buildDataPoints, sinY } from '@pie-lib/graphing-utils';
3
+ import { utils } from '@pie-lib/plot';
4
+
5
+ import { graphProps as getGraphProps } from '../../../__tests__/utils';
6
+
7
+ const { xy } = utils;
8
+ jest.mock('@pie-lib/graphing-utils', () => ({
9
+ sinY: jest.fn().mockReturnValue(0),
10
+ buildDataPoints: jest.fn().mockReturnValue([]),
11
+ parabolaFromTwoPoints: jest.fn(() => jest.fn()),
12
+ getAmplitudeAndFreq: jest.fn().mockReturnValue({ freq: 4, amplitude: 1 }),
13
+ FREQ_DIVIDER: 16,
14
+ }));
15
+
16
+ jest.mock('../../shared/line/with-root-edge', () => ({
17
+ withRootEdge: jest.fn(),
18
+ rootEdgeComponent: jest.fn(),
19
+ }));
20
+ describe('Parabola', () => {
21
+ let fnBody;
22
+ let graphProps;
23
+ let root;
24
+ let edge;
25
+ let result;
26
+ beforeEach(() => {
27
+ require('../component');
28
+ fnBody = withRootEdge.mock.calls[0][0];
29
+ graphProps = getGraphProps();
30
+ root = xy(0, 0);
31
+ edge = xy(1, 1);
32
+
33
+ result = fnBody({ graphProps, root, edge });
34
+ });
35
+ it('fnBody is not null', () => {
36
+ expect(fnBody).toBeDefined();
37
+ });
38
+
39
+ it('calls buildDataPoints', () => {
40
+ const { domain, range } = graphProps;
41
+ expect(buildDataPoints).toHaveBeenCalledWith({ ...domain, step: 0.25 }, range, root, edge, expect.anything());
42
+ });
43
+
44
+ it('calls sinY', () => {
45
+ expect(sinY).toHaveBeenCalledWith(1, 4, expect.anything());
46
+ });
47
+
48
+ it('returns dataPoints', () => {
49
+ expect(result).toEqual({ root, edge, dataPoints: [] });
50
+ });
51
+ });
@@ -4,29 +4,29 @@ import { withRootEdge, rootEdgeComponent } from '../shared/line/with-root-edge';
4
4
 
5
5
  const log = debug('pie-lib:graphing:sine');
6
6
 
7
- log('sine...');
8
-
9
7
  const Sine = withRootEdge((props) => {
10
- const { domain } = props.graphProps;
8
+ const { root, edge, graphProps } = props;
9
+ const { domain, range } = graphProps;
11
10
 
12
- const { root, edge } = props;
13
11
  const { amplitude, freq } = getAmplitudeAndFreq(root, edge);
14
12
  const interval = freq / FREQ_DIVIDER;
13
+
15
14
  log('[getPoints] amplitude:', amplitude, 'freq:', freq);
16
15
 
17
16
  const dataPoints =
18
17
  edge && edge.x === root.x
19
18
  ? []
20
19
  : buildDataPoints(
21
- domain.min,
22
- domain.max,
20
+ { ...domain, step: interval },
21
+ range,
23
22
  root,
24
23
  edge,
25
- interval,
26
24
  sinY(amplitude, freq, { phase: root.x, vertical: root.y }),
27
25
  );
26
+
28
27
  return { root: props.root, edge: props.edge, dataPoints };
29
28
  });
30
29
 
31
30
  const Component = rootEdgeComponent(Sine);
31
+
32
32
  export default Component;
@@ -0,0 +1,12 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Line snapshot renders 1`] = `
4
+ <line
5
+ className="className"
6
+ strokeDasharray={-5.585786437626905}
7
+ x1={0}
8
+ x2={1}
9
+ y1={0}
10
+ y2={1}
11
+ />
12
+ `;
@@ -0,0 +1,26 @@
1
+ import { shallow } from 'enzyme';
2
+ import React from 'react';
3
+ import { Line } from '../component';
4
+ import { graphProps as getGraphProps } from '../../../__tests__/utils';
5
+ import { utils } from '@pie-lib/plot';
6
+
7
+ describe('Line', () => {
8
+ let w;
9
+ const wrapper = (extras) => {
10
+ const defaults = {
11
+ classes: {},
12
+ className: 'className',
13
+ graphProps: getGraphProps(),
14
+ from: utils.xy(0, 0),
15
+ to: utils.xy(1, 1),
16
+ };
17
+ const props = { ...defaults, ...extras };
18
+ return shallow(<Line {...props} />);
19
+ };
20
+ describe('snapshot', () => {
21
+ it('renders', () => {
22
+ const w = wrapper();
23
+ expect(w).toMatchSnapshot();
24
+ });
25
+ });
26
+ });
@@ -10,6 +10,7 @@ import { getDistanceBetweenTwoPoints } from '../../utils';
10
10
  const lineStyles = (theme) => ({
11
11
  line: styles.line(theme),
12
12
  disabled: styles.disabled(theme),
13
+ disabledSecondary: styles.disabledSecondary(theme),
13
14
  correct: styles.correct(theme, 'stroke'),
14
15
  incorrect: styles.incorrect(theme, 'stroke'),
15
16
  missing: styles.missing(theme, 'stroke'),
@@ -32,7 +33,7 @@ export const Line = (props) => {
32
33
 
33
34
  return (
34
35
  <line
35
- className={classNames(classes.line, disabled && classes.disabled, classes[correctness], className)}
36
+ className={classNames(classes.line, disabled && classes.disabledSecondary, classes[correctness], className)}
36
37
  x1={startPoint.x}
37
38
  y1={startPoint.y}
38
39
  x2={endPoint.x}
package/src/undo-redo.jsx CHANGED
@@ -40,7 +40,6 @@ export class UndoRedo extends React.Component {
40
40
  const styles = (theme) => ({
41
41
  button: {
42
42
  color: color.text(),
43
- backgroundColor: color.background(),
44
43
  marginBottom: theme.spacing.unit / 2,
45
44
  '&:not(:last-of-type)': {
46
45
  marginRight: theme.spacing.unit / 2,
package/src/utils.js CHANGED
@@ -203,7 +203,7 @@ export const isDuplicatedMark = (mark, marks, oldMark) => {
203
203
  }
204
204
 
205
205
  const duplicated = filteredMarks.find((m) => {
206
- if (type === 'circle' || type === 'parabola' || type === 'sine') {
206
+ if (type === 'circle' || type === 'parabola' || type === 'sine' || type === 'absolute' || type === 'exponential') {
207
207
  const { root, edge } = mark;
208
208
 
209
209
  return (equalPoints(root, m.root) && equalPoints(edge, m.edge)) || (type === 'circle' && isSameCircle(m, mark));
package/legacy.png DELETED
Binary file