@khanacademy/perseus 0.3.4 → 0.4.1

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 (52) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/es/index.css +436 -1
  3. package/dist/es/index.js +8232 -5591
  4. package/dist/es/index.js.map +1 -1
  5. package/dist/index.css +436 -1
  6. package/dist/index.js +17876 -15237
  7. package/dist/index.js.map +1 -1
  8. package/dist/strings.js +0 -1
  9. package/package.json +9 -8
  10. package/src/__tests__/__snapshots__/item-renderer_test.jsx.snap +2 -3
  11. package/src/__tests__/__snapshots__/server-item-renderer_test.jsx.snap +2 -3
  12. package/src/__tests__/renderer-api_test.jsx +3 -27
  13. package/src/components/__stories__/svg-image.stories.jsx +11 -0
  14. package/src/components/fixed-to-responsive.jsx +1 -0
  15. package/src/components/input-with-examples.jsx +3 -1
  16. package/src/components/svg-image.jsx +10 -7
  17. package/src/components/text-input.jsx +65 -16
  18. package/src/definition-context.js +59 -0
  19. package/src/index.js +5 -1
  20. package/src/multi-items/__tests__/__snapshots__/multi-renderer_test.js.snap +438 -523
  21. package/src/multi-items/__tests__/multi-renderer_test.js +9 -9
  22. package/src/renderer.jsx +13 -6
  23. package/src/types.js +3 -4
  24. package/src/widgets/__stories__/definition.stories.jsx +44 -0
  25. package/src/widgets/__tests__/__snapshots__/categorizer_test.jsx.snap +76 -8
  26. package/src/widgets/__tests__/__snapshots__/graded-group-set-jipt_test.jsx.snap +6 -9
  27. package/src/widgets/__tests__/__snapshots__/graded-group-set_test.jsx.snap +2 -3
  28. package/src/widgets/__tests__/__snapshots__/grapher_test.jsx.snap +19 -2
  29. package/src/widgets/__tests__/__snapshots__/group_test.jsx.snap +338 -390
  30. package/src/widgets/__tests__/__snapshots__/image_test.jsx.snap +38 -4
  31. package/src/widgets/__tests__/__snapshots__/interactive-graph_test.jsx.snap +114 -12
  32. package/src/widgets/__tests__/__snapshots__/matrix_test.jsx.snap +120 -48
  33. package/src/widgets/__tests__/__snapshots__/numeric-input_test.jsx.snap +8 -12
  34. package/src/widgets/__tests__/__snapshots__/radio_test.jsx.snap +3615 -4517
  35. package/src/widgets/__tests__/graded-group-set-jipt_test.jsx +0 -1
  36. package/src/widgets/__tests__/grapher.cypress.jsx +236 -176
  37. package/src/widgets/__tests__/group_test.jsx +4 -4
  38. package/src/widgets/__tests__/interactive-graph.cypress.jsx +371 -291
  39. package/src/widgets/__tests__/radio_test.jsx +73 -114
  40. package/src/widgets/definition.jsx +34 -29
  41. package/src/widgets/numeric-input.jsx +2 -15
  42. package/src/widgets/radio/base-radio.jsx +1 -1
  43. package/src/widgets/radio/choice-icon.jsx +11 -10
  44. package/src/widgets/radio/choice.jsx +164 -396
  45. package/src/widgets/radio/cross-out-button.jsx +3 -5
  46. package/src/widgets/radio/option-status.jsx +4 -5
  47. package/src/widgets/radio/__stories__/cross-out-menu.stories.jsx +0 -59
  48. package/src/widgets/radio/__stories__/cross-out-tooltip.stories.jsx +0 -59
  49. package/src/widgets/radio/__stories__/toggleable-radio-button.stories.jsx +0 -28
  50. package/src/widgets/radio/cross-out-menu-wrapper.jsx +0 -492
  51. package/src/widgets/radio/cross-out-tooltip.jsx +0 -129
  52. package/src/widgets/radio/toggleable-radio-button.jsx +0 -133
@@ -3,14 +3,12 @@
3
3
  * The button that appears when you open the `CrossOutMenu`, enabling the user
4
4
  * to toggle a choice's `crossedOut` state.
5
5
  */
6
- import colors from "@khanacademy/wonder-blocks-color";
6
+ import Color from "@khanacademy/wonder-blocks-color";
7
7
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
8
8
  import {LabelLarge} from "@khanacademy/wonder-blocks-typography";
9
9
  import {StyleSheet, css} from "aphrodite";
10
10
  import * as React from "react";
11
11
 
12
- import {colors as oldColors} from "../../styles/global-styles.js";
13
-
14
12
  import ChoiceIcon from "./choice-icon.jsx";
15
13
  import {getChoiceLetter} from "./util.js";
16
14
 
@@ -37,7 +35,7 @@ export type CrossOutButtonProps = {
37
35
 
38
36
  export default class CrossOutButton extends React.PureComponent<CrossOutButtonProps> {
39
37
  static defaultProps: {|primaryProductColor: string|} = {
40
- primaryProductColor: oldColors.kaGreen,
38
+ primaryProductColor: Color.blue,
41
39
  };
42
40
 
43
41
  /**
@@ -67,7 +65,7 @@ export default class CrossOutButton extends React.PureComponent<CrossOutButtonPr
67
65
  const {crossedOut, pos, primaryProductColor, theme} = this.props;
68
66
 
69
67
  const buttonAndTextColor =
70
- theme === "day" ? primaryProductColor : colors.white;
68
+ theme === "day" ? primaryProductColor : Color.white;
71
69
 
72
70
  return (
73
71
  <button
@@ -7,12 +7,11 @@
7
7
  * between the states more immediately clear to users.
8
8
  */
9
9
 
10
+ import Color from "@khanacademy/wonder-blocks-color";
10
11
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
11
12
  import {StyleSheet, css} from "aphrodite";
12
13
  import * as React from "react";
13
14
 
14
- import * as styleConstants from "../../styles/constants.js";
15
-
16
15
  class OptionStatus extends React.Component<{
17
16
  // Was this option the correct answer?
18
17
  correct: boolean,
@@ -76,13 +75,13 @@ const styles = StyleSheet.create({
76
75
  textTransform: "uppercase",
77
76
  },
78
77
  correct: {
79
- color: styleConstants.kaGreen,
78
+ color: Color.green,
80
79
  },
81
80
  incorrectAnswered: {
82
- color: styleConstants.warning1,
81
+ color: Color.red,
83
82
  },
84
83
  incorrect: {
85
- color: styleConstants.gray68,
84
+ color: Color.offBlack64,
86
85
  },
87
86
  });
88
87
 
@@ -1,59 +0,0 @@
1
- // @flow
2
- import colors from "@khanacademy/wonder-blocks-color";
3
- import * as React from "react";
4
-
5
- import CrossOutMenuWrapper from "../cross-out-menu-wrapper.jsx";
6
-
7
- type StoryArgs = {||};
8
-
9
- type Story = {|
10
- title: string,
11
- |};
12
-
13
- export default ({
14
- title: "Perseus/Widgets/Radio/Cross Out Menu",
15
- }: Story);
16
-
17
- export const CrossOutMenuForChoiceAColoredDefaultKaGreen = (
18
- args: StoryArgs,
19
- ): React.Node => {
20
- return (
21
- <CrossOutMenuWrapper
22
- enabled={true}
23
- pos={0}
24
- crossedOut={false}
25
- onCrossedOutChange={() => {}}
26
- >
27
- <div>Hello, world!</div>
28
- </CrossOutMenuWrapper>
29
- );
30
- };
31
-
32
- export const ReEnableMenuForChoiceCColoredWonderBlocksBlue = (
33
- args: StoryArgs,
34
- ): React.Node => {
35
- return (
36
- <CrossOutMenuWrapper
37
- enabled={true}
38
- pos={0}
39
- primaryProductColor={colors.blue}
40
- crossedOut={true}
41
- onCrossedOutChange={() => {}}
42
- >
43
- <div>Hello, world!</div>
44
- </CrossOutMenuWrapper>
45
- );
46
- };
47
-
48
- export const NoCrossOutMenu = (args: StoryArgs): React.Node => {
49
- return (
50
- <CrossOutMenuWrapper
51
- enabled={true}
52
- pos={0}
53
- crossedOut={false}
54
- onCrossedOutChange={() => {}}
55
- >
56
- <div>Hello, world!</div>
57
- </CrossOutMenuWrapper>
58
- );
59
- };
@@ -1,59 +0,0 @@
1
- // @flow
2
- import colors from "@khanacademy/wonder-blocks-color";
3
- import * as React from "react";
4
-
5
- import {colors as oldColors} from "../../../styles/global-styles.js";
6
- import CrossOutTooltip from "../cross-out-tooltip.jsx";
7
-
8
- type StoryArgs = {||};
9
-
10
- type Story = {|
11
- title: string,
12
- |};
13
-
14
- export default ({
15
- title: "Perseus/Widgets/Radio/Cross Out Tooltip",
16
- }: Story);
17
-
18
- export const TooltipToCrossOutChoiceAGreen = (args: StoryArgs): React.Node => {
19
- return (
20
- <CrossOutTooltip
21
- dismissed={false}
22
- onDismiss={() => {}}
23
- buttonProps={{
24
- onClick: () => {},
25
- onFocus: () => {},
26
- onBlur: () => {},
27
-
28
- pos: 0,
29
- primaryProductColor: oldColors.kaGreen,
30
- crossedOut: false,
31
- usingKeyboardFocus: false,
32
- theme: "day",
33
- }}
34
- >
35
- <div style={{textAlign: "center"}}>Tooltip target!</div>
36
- </CrossOutTooltip>
37
- );
38
- };
39
- export const TooltipToCrossOutChoiceBBlue = (args: StoryArgs): React.Node => {
40
- return (
41
- <CrossOutTooltip
42
- dismissed={false}
43
- onDismiss={() => {}}
44
- buttonProps={{
45
- onClick: () => {},
46
- onFocus: () => {},
47
- onBlur: () => {},
48
-
49
- pos: 1,
50
- primaryProductColor: colors.blue,
51
- crossedOut: false,
52
- usingKeyboardFocus: false,
53
- theme: "day",
54
- }}
55
- >
56
- <div style={{textAlign: "center"}}>Tooltip target!</div>
57
- </CrossOutTooltip>
58
- );
59
- };
@@ -1,28 +0,0 @@
1
- // @flow
2
- import * as React from "react";
3
-
4
- import ToggleableRadioWidget from "../toggleable-radio-button.jsx";
5
-
6
- type StoryArgs = {||};
7
-
8
- type Story = {|
9
- title: string,
10
- |};
11
-
12
- const defaultObject = {
13
- onChecked: () => {},
14
- goToPrevChoice: () => {},
15
- goToNextChoice: () => {},
16
- };
17
-
18
- export default ({
19
- title: "Perseus/Widgets/Radio/Toggleable Radio Button",
20
- }: Story);
21
-
22
- export const Checked = (args: StoryArgs): React.Node => {
23
- return <ToggleableRadioWidget {...defaultObject} checked={true} />;
24
- };
25
-
26
- export const Unchecked = (args: StoryArgs): React.Node => {
27
- return <ToggleableRadioWidget {...defaultObject} checked={false} />;
28
- };