@khanacademy/perseus 1.4.1 → 2.0.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.
- package/CHANGELOG.md +18 -0
- package/dist/es/index.css +10 -246
- package/dist/es/index.js +143 -585
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +10 -246
- package/dist/index.js +140 -582
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__stories__/hints-renderer.stories.jsx +9 -1
- package/src/__testdata__/graphie_testdata.js +53 -0
- package/src/__tests__/__snapshots__/perseus-markdown_test.jsx.snap +0 -9
- package/src/__tests__/__snapshots__/renderer_test.jsx.snap +0 -9
- package/src/components/__stories__/graphie.stories.jsx +5 -1
- package/src/hint-renderer.jsx +11 -14
- package/src/perseus-api.jsx +0 -23
- package/src/perseus-markdown.jsx +0 -25
- package/src/styles/articles.less +6 -1
- package/src/styles/constants.js +0 -21
- package/src/styles/global-constants.js +0 -6
- package/src/styles/khan-exercise.css +9 -1
- package/src/styles/perseus-renderer.less +0 -259
- package/src/styles/variables.less +0 -11
- package/src/styles/variables.shared.less +0 -10
- package/src/types.js +0 -16
- package/src/widget-container.jsx +4 -0
- package/src/widgets/__stories__/definition.stories.jsx +27 -1
- package/src/widgets/__stories__/input-number.stories.jsx +0 -14
- package/src/widgets/__stories__/radio.stories.jsx +0 -3
- package/src/widgets/__tests__/__snapshots__/definition_test.js.snap +20 -30
- package/src/widgets/__tests__/__snapshots__/group_test.jsx.snap +0 -9
- package/src/widgets/__tests__/__snapshots__/image_test.jsx.snap +0 -18
- package/src/widgets/__tests__/__snapshots__/numeric-input_test.jsx.snap +2 -440
- package/src/widgets/__tests__/__snapshots__/radio_test.jsx.snap +66 -3726
- package/src/widgets/__tests__/numeric-input_test.jsx +54 -118
- package/src/widgets/__tests__/radio/choice-icon_test.jsx +25 -75
- package/src/widgets/__tests__/radio_test.jsx +362 -394
- package/src/widgets/definition.jsx +27 -14
- package/src/widgets/input-number.jsx +2 -60
- package/src/widgets/numeric-input.jsx +17 -89
- package/src/widgets/radio/__stories__/base-radio.stories.jsx +1 -3
- package/src/widgets/radio/__stories__/choice-icon.stories.jsx +23 -105
- package/src/widgets/radio/__stories__/option-status.stories.jsx +0 -8
- package/src/widgets/radio/base-radio.jsx +13 -96
- package/src/widgets/radio/choice-icon/choice-icon.jsx +177 -50
- package/src/widgets/radio/choice-icon/cross-out-line.jsx +9 -13
- package/src/widgets/radio/choice-icon/shared-styles.js +2 -3
- package/src/widgets/radio/choice.jsx +5 -59
- package/src/widgets/radio/option-status.jsx +2 -14
- package/src/components/__stories__/possible-answers.stories.jsx +0 -22
- package/src/components/possible-answers.jsx +0 -36
- package/src/styles/widgets/definition.less +0 -86
- package/src/widgets/radio/__stories__/sat-styles.stories.jsx +0 -191
- package/src/widgets/radio/choice-icon/library-choice-icon.jsx +0 -225
- package/src/widgets/radio/choice-icon/sat-choice-icon.jsx +0 -120
package/src/types.js
CHANGED
|
@@ -142,7 +142,6 @@ type StubTagEditorType = $FlowFixMe; // from "./components/stub-tag-editor.jsx";
|
|
|
142
142
|
export type APIOptions = $ReadOnly<{|
|
|
143
143
|
isArticle?: boolean,
|
|
144
144
|
|
|
145
|
-
satStyling?: boolean,
|
|
146
145
|
// This should actually be required since renderer.jsx sets defaults for
|
|
147
146
|
// any missing properties in this object using this.getApiOptions() before
|
|
148
147
|
// passing the prop on to other components.
|
|
@@ -232,19 +231,6 @@ export type APIOptions = $ReadOnly<{|
|
|
|
232
231
|
// Whether to use the Draft.js editor or the legacy textarea
|
|
233
232
|
useDraftEditor?: boolean,
|
|
234
233
|
|
|
235
|
-
// Styling options that control the visual behavior of Perseus
|
|
236
|
-
// items.
|
|
237
|
-
// TODO(mdr): If we adopt this pattern, we'll need to think about
|
|
238
|
-
// how to make individual `styling` options be optional, and
|
|
239
|
-
// how to set their default values without overwriting provided
|
|
240
|
-
// values. For now, though, you must either specify all fields
|
|
241
|
-
// of `styling`, or omit the `styling` option entirely.
|
|
242
|
-
styling?: {|
|
|
243
|
-
// TODO(Nicole): Remove this after landing wonderblock-ifying
|
|
244
|
-
// the radio widget
|
|
245
|
-
primaryProductColor?: string,
|
|
246
|
-
|},
|
|
247
|
-
|
|
248
234
|
// The color used for the hint progress indicator (eg. 1 / 3)
|
|
249
235
|
hintProgressColor?: string,
|
|
250
236
|
|
|
@@ -399,13 +385,11 @@ export type APIOptionsWithDefaults = $ReadOnly<{|
|
|
|
399
385
|
onFocusChange: $NonMaybeType<APIOptions["onFocusChange"]>,
|
|
400
386
|
onInputError: $NonMaybeType<APIOptions["onInputError"]>,
|
|
401
387
|
readOnly: $NonMaybeType<APIOptions["readOnly"]>,
|
|
402
|
-
satStyling: $NonMaybeType<APIOptions["satStyling"]>,
|
|
403
388
|
setDrawingAreaAvailable: $NonMaybeType<
|
|
404
389
|
APIOptions["setDrawingAreaAvailable"],
|
|
405
390
|
>,
|
|
406
391
|
showAlignmentOptions: $NonMaybeType<APIOptions["showAlignmentOptions"]>,
|
|
407
392
|
staticRender: $NonMaybeType<APIOptions["staticRender"]>,
|
|
408
|
-
styling: $NonMaybeType<APIOptions["styling"]>,
|
|
409
393
|
useDraftEditor: $NonMaybeType<APIOptions["useDraftEditor"]>,
|
|
410
394
|
|}>;
|
|
411
395
|
|
package/src/widget-container.jsx
CHANGED
|
@@ -68,6 +68,10 @@ class WidgetContainer extends React.Component<Props, State> {
|
|
|
68
68
|
"perseus-widget-container": true,
|
|
69
69
|
"widget-highlight": this.props.shouldHighlight,
|
|
70
70
|
"widget-nohighlight": !this.props.shouldHighlight,
|
|
71
|
+
// HACK(matthewc): perseus-widget-container is setting a font-size
|
|
72
|
+
// but we want the definition prompt to match the surrounding font
|
|
73
|
+
// I'm sorry, but there's a time crunch
|
|
74
|
+
"perseus-widget__definition": this.props.type === "definition",
|
|
71
75
|
});
|
|
72
76
|
|
|
73
77
|
const type = this.props.type;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
|
|
4
4
|
import {RendererWithDebugUI} from "../../../../../testing/renderer-with-debug-ui.jsx";
|
|
5
|
+
import ArticleRenderer from "../../article-renderer.jsx";
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
title: "Perseus/Widgets/Definition",
|
|
@@ -71,12 +72,37 @@ const question2 = {
|
|
|
71
72
|
},
|
|
72
73
|
};
|
|
73
74
|
|
|
75
|
+
const article = {
|
|
76
|
+
content:
|
|
77
|
+
"###Backstory\n\nDuring World War II, in August of 1943, the [[☃ definition 1]] launched a massive bombing campaign on Milan and its outskirts. The explosions and the ensuing fires killed over 700 people and destroyed many of the city’s most important buildings and monuments, including a significant portion of Santa Maria delle Grazie. Miraculously, the wall with the painting survived, probably because it had been shored up with sandbags and mattresses, but the roof of the refectory was blown off and the other walls were decimated. The _Last Supper_ remained exposed to the elements, covered only with a tarp, for several months, until the refectory (the dining room of the monastery where the _Last Supper_ was painted), was rebuilt and a team of restorers began working to preserve and restore the painting.",
|
|
78
|
+
images: {},
|
|
79
|
+
widgets: {
|
|
80
|
+
"definition 1": {
|
|
81
|
+
alignment: "default",
|
|
82
|
+
graded: true,
|
|
83
|
+
options: {
|
|
84
|
+
definition:
|
|
85
|
+
"The Allies, led by the United Kingdom, the United States, and the Soviet Union, were the group of countries who opposed the Axis powers (Germany, Japan, and Italy) during World War II.",
|
|
86
|
+
static: false,
|
|
87
|
+
togglePrompt: "Allies",
|
|
88
|
+
},
|
|
89
|
+
static: false,
|
|
90
|
+
type: "definition",
|
|
91
|
+
version: {major: 0, minor: 0},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
|
|
74
96
|
type StoryArgs = {||};
|
|
75
97
|
|
|
76
98
|
export const Question1 = (args: StoryArgs): React.Node => {
|
|
77
99
|
return <RendererWithDebugUI question={question1} />;
|
|
78
100
|
};
|
|
79
101
|
|
|
80
|
-
export const
|
|
102
|
+
export const MultipleDefinitions = (args: StoryArgs): React.Node => {
|
|
81
103
|
return <RendererWithDebugUI question={question2} />;
|
|
82
104
|
};
|
|
105
|
+
|
|
106
|
+
export const ArticleDefintion = (args: StoryArgs): React.Node => {
|
|
107
|
+
return <ArticleRenderer json={article} useNewStyles />;
|
|
108
|
+
};
|
|
@@ -100,17 +100,3 @@ export const Percent = (args: InputNumberOptions): React.Node => {
|
|
|
100
100
|
return <RendererWithDebugUI question={question} />;
|
|
101
101
|
};
|
|
102
102
|
Percent.args = question3.widgets["input-number 1"].options;
|
|
103
|
-
|
|
104
|
-
export const RationalWithSatStyling = (
|
|
105
|
-
args: InputNumberOptions,
|
|
106
|
-
): React.Node => {
|
|
107
|
-
const question = updateWidgetOptions(question1, "input-number 1", args);
|
|
108
|
-
return (
|
|
109
|
-
<RendererWithDebugUI
|
|
110
|
-
question={question}
|
|
111
|
-
apiOptions={{satStyling: true}}
|
|
112
|
-
reviewMode={true}
|
|
113
|
-
/>
|
|
114
|
-
);
|
|
115
|
-
};
|
|
116
|
-
Rational.args = question1.widgets["input-number 1"].options;
|
|
@@ -17,7 +17,6 @@ type StoryArgs = {|
|
|
|
17
17
|
static: boolean,
|
|
18
18
|
|
|
19
19
|
// API Options
|
|
20
|
-
satStyling: boolean,
|
|
21
20
|
crossOutEnabled: boolean,
|
|
22
21
|
|
|
23
22
|
// Renderer Options
|
|
@@ -33,7 +32,6 @@ export default ({
|
|
|
33
32
|
title: "Perseus/Widgets/Radio",
|
|
34
33
|
args: {
|
|
35
34
|
static: false,
|
|
36
|
-
satStyling: false,
|
|
37
35
|
crossOutEnabled: false,
|
|
38
36
|
reviewMode: false,
|
|
39
37
|
},
|
|
@@ -57,7 +55,6 @@ const applyStoryArgs = (
|
|
|
57
55
|
|
|
58
56
|
const buildApiOptions = (args: StoryArgs): APIOptions => {
|
|
59
57
|
return {
|
|
60
|
-
satStyling: args.satStyling,
|
|
61
58
|
crossOutEnabled: args.crossOutEnabled,
|
|
62
59
|
};
|
|
63
60
|
};
|
|
@@ -27,27 +27,22 @@ exports[`Definition widget should have a default snapshot: first render 1`] = `
|
|
|
27
27
|
>
|
|
28
28
|
The Governor and Council of the Massachusetts had much conference many days; and at last . . . . concluded a peace and friendship with
|
|
29
29
|
<div
|
|
30
|
-
class="perseus-widget-container widget-nohighlight widget-inline"
|
|
30
|
+
class="perseus-widget-container widget-nohighlight perseus-widget__definition widget-inline"
|
|
31
31
|
>
|
|
32
|
-
<
|
|
32
|
+
<button
|
|
33
33
|
aria-controls="uid-popover-0-wb-id"
|
|
34
|
+
aria-disabled="false"
|
|
34
35
|
aria-expanded="false"
|
|
35
|
-
class="
|
|
36
|
+
class="button_vr44p2-o_O-reset_152ygtm-o_O-link_13xlah4"
|
|
36
37
|
id="uid-popover-0-wb-id-anchor"
|
|
38
|
+
type="button"
|
|
37
39
|
>
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
class="button_vr44p2-o_O-shared_lwskrm-o_O-default_1hl5pu8"
|
|
41
|
-
role="button"
|
|
42
|
-
type="button"
|
|
40
|
+
<span
|
|
41
|
+
style="color: rgb(24, 101, 242);"
|
|
43
42
|
>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
the Pequots
|
|
48
|
-
</span>
|
|
49
|
-
</button>
|
|
50
|
-
</span>
|
|
43
|
+
the Pequots
|
|
44
|
+
</span>
|
|
45
|
+
</button>
|
|
51
46
|
</div>
|
|
52
47
|
, upon these conditions.
|
|
53
48
|
</div>
|
|
@@ -84,27 +79,22 @@ exports[`Definition widget should have an open state snapshot: open state 1`] =
|
|
|
84
79
|
>
|
|
85
80
|
The Governor and Council of the Massachusetts had much conference many days; and at last . . . . concluded a peace and friendship with
|
|
86
81
|
<div
|
|
87
|
-
class="perseus-widget-container widget-nohighlight widget-inline"
|
|
82
|
+
class="perseus-widget-container widget-nohighlight perseus-widget__definition widget-inline"
|
|
88
83
|
>
|
|
89
|
-
<
|
|
84
|
+
<button
|
|
90
85
|
aria-controls="uid-popover-1-wb-id"
|
|
86
|
+
aria-disabled="false"
|
|
91
87
|
aria-expanded="true"
|
|
92
|
-
class="
|
|
88
|
+
class="button_vr44p2-o_O-reset_152ygtm-o_O-link_13xlah4"
|
|
93
89
|
id="uid-popover-1-wb-id-anchor"
|
|
90
|
+
type="button"
|
|
94
91
|
>
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
class="button_vr44p2-o_O-shared_lwskrm-o_O-default_1hl5pu8"
|
|
98
|
-
role="button"
|
|
99
|
-
type="button"
|
|
92
|
+
<span
|
|
93
|
+
style="color: rgb(24, 101, 242); border-bottom: 2px solid #1865f2;"
|
|
100
94
|
>
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
the Pequots
|
|
105
|
-
</span>
|
|
106
|
-
</button>
|
|
107
|
-
</span>
|
|
95
|
+
the Pequots
|
|
96
|
+
</span>
|
|
97
|
+
</button>
|
|
108
98
|
</div>
|
|
109
99
|
, upon these conditions.
|
|
110
100
|
</div>
|
|
@@ -58,15 +58,9 @@ exports[`group widget should snapshot: initial render 1`] = `
|
|
|
58
58
|
<div
|
|
59
59
|
class="perseus-column"
|
|
60
60
|
>
|
|
61
|
-
<div
|
|
62
|
-
class="sat-header-grafting-area"
|
|
63
|
-
/>
|
|
64
61
|
<div
|
|
65
62
|
class="perseus-column-content"
|
|
66
63
|
>
|
|
67
|
-
<div
|
|
68
|
-
class="sat-skill-subscore-grafting-area"
|
|
69
|
-
/>
|
|
70
64
|
<div
|
|
71
65
|
class="paragraph"
|
|
72
66
|
>
|
|
@@ -1270,9 +1264,6 @@ exports[`group widget should snapshot: initial render 1`] = `
|
|
|
1270
1264
|
</div>
|
|
1271
1265
|
</div>
|
|
1272
1266
|
</div>
|
|
1273
|
-
<div
|
|
1274
|
-
class="sat-grafting-area"
|
|
1275
|
-
/>
|
|
1276
1267
|
</div>
|
|
1277
1268
|
</div>
|
|
1278
1269
|
</div>
|
|
@@ -117,15 +117,9 @@ exports[`image widget - isMobile %b should snapshot: first render 1`] = `
|
|
|
117
117
|
<div
|
|
118
118
|
class="perseus-column"
|
|
119
119
|
>
|
|
120
|
-
<div
|
|
121
|
-
class="sat-header-grafting-area"
|
|
122
|
-
/>
|
|
123
120
|
<div
|
|
124
121
|
class="perseus-column-content"
|
|
125
122
|
>
|
|
126
|
-
<div
|
|
127
|
-
class="sat-skill-subscore-grafting-area"
|
|
128
|
-
/>
|
|
129
123
|
<div
|
|
130
124
|
class="paragraph"
|
|
131
125
|
>
|
|
@@ -191,9 +185,6 @@ exports[`image widget - isMobile %b should snapshot: first render 1`] = `
|
|
|
191
185
|
</span>
|
|
192
186
|
?
|
|
193
187
|
</div>
|
|
194
|
-
<div
|
|
195
|
-
class="sat-grafting-area"
|
|
196
|
-
/>
|
|
197
188
|
</div>
|
|
198
189
|
</div>
|
|
199
190
|
</div>
|
|
@@ -335,15 +326,9 @@ exports[`image widget - isMobile %b should snapshot: first render 2`] = `
|
|
|
335
326
|
<div
|
|
336
327
|
class="perseus-column"
|
|
337
328
|
>
|
|
338
|
-
<div
|
|
339
|
-
class="sat-header-grafting-area"
|
|
340
|
-
/>
|
|
341
329
|
<div
|
|
342
330
|
class="perseus-column-content"
|
|
343
331
|
>
|
|
344
|
-
<div
|
|
345
|
-
class="sat-skill-subscore-grafting-area"
|
|
346
|
-
/>
|
|
347
332
|
<div
|
|
348
333
|
class="paragraph"
|
|
349
334
|
>
|
|
@@ -409,9 +394,6 @@ exports[`image widget - isMobile %b should snapshot: first render 2`] = `
|
|
|
409
394
|
</span>
|
|
410
395
|
?
|
|
411
396
|
</div>
|
|
412
|
-
<div
|
|
413
|
-
class="sat-grafting-area"
|
|
414
|
-
/>
|
|
415
397
|
</div>
|
|
416
398
|
</div>
|
|
417
399
|
</div>
|