@khanacademy/perseus 6.5.0 → 6.6.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.
@@ -1,15 +1,15 @@
1
+ import type { APIOptions, Tracking } from "./types";
1
2
  /**
2
3
  * Wrapper for the trackInteraction apiOption.
3
4
  */
4
5
  declare class InteractionTracker {
5
6
  _tracked: boolean;
6
- setting: string;
7
+ setting: Tracking;
7
8
  track: (extraData?: any) => void;
8
9
  trackApi: any;
9
10
  widgetID: string;
10
11
  widgetType: string;
11
- constructor(trackApi: any, // original apiOptions.trackInteraction
12
- widgetType: string, widgetID: string, setting: "" | "all");
12
+ constructor(trackApi: APIOptions["trackInteraction"], widgetType: string, widgetID: string, setting: Tracking);
13
13
  /**
14
14
  * Function that actually calls the API to mark the interaction. This is
15
15
  * private. The public version is just `.track` and is bound to this object
@@ -18,6 +18,6 @@ declare class InteractionTracker {
18
18
  * @param extraData Any extra data to track about the event.
19
19
  * @private
20
20
  */
21
- _track: (extraData: unknown) => void;
21
+ _track: (extraData: Record<string, any>) => void;
22
22
  }
23
23
  export default InteractionTracker;
@@ -4,21 +4,23 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
+ import type { APIOptions, Tracking } from "./types";
8
+
7
9
  /**
8
10
  * Wrapper for the trackInteraction apiOption.
9
11
  */
10
12
  declare class InteractionTracker {
11
13
  _tracked: boolean;
12
- setting: string;
14
+ setting: Tracking;
13
15
  track: (extraData?: any) => void;
14
16
  trackApi: any;
15
17
  widgetID: string;
16
18
  widgetType: string;
17
19
  constructor(
18
- trackApi: any,
20
+ trackApi: $PropertyType<APIOptions, "trackInteraction">,
19
21
  widgetType: string,
20
22
  widgetID: string,
21
- setting: "" | "all"
23
+ setting: Tracking
22
24
  ): this;
23
25
 
24
26
  /**
@@ -28,6 +30,6 @@ declare class InteractionTracker {
28
30
  * @param extraData Any extra data to track about the event.
29
31
  * @private
30
32
  */
31
- _track: (extraData: mixed) => void;
33
+ _track: (extraData: { [key: string]: any }) => void;
32
34
  }
33
35
  declare export default typeof InteractionTracker;
@@ -78,7 +78,11 @@ export declare const ApiOptions: {
78
78
  Link: React.ComponentType<any>;
79
79
  } | undefined;
80
80
  imagePreloader?: ((dimensions: import("./types").Dimensions) => React.ReactNode) | undefined;
81
- trackInteraction?: (() => unknown) | undefined;
81
+ trackInteraction?: ((args: {
82
+ type: string;
83
+ id: string;
84
+ correct?: boolean | undefined;
85
+ } & Record<string, unknown>) => void) | undefined;
82
86
  customKeypad?: boolean | undefined;
83
87
  nativeKeypadProxy?: (() => unknown) | undefined;
84
88
  isMobile?: boolean | undefined;
@@ -78,7 +78,16 @@ declare export var ApiOptions: {|
78
78
  imagePreloader?:
79
79
  | ((dimensions: $Flowgen$Import$_2e__2f_types.Dimensions) => React.Node)
80
80
  | void,
81
- trackInteraction?: (() => mixed) | void,
81
+ trackInteraction?:
82
+ | ((args: {|
83
+ ...{|
84
+ type: string,
85
+ id: string,
86
+ correct?: boolean | void,
87
+ |},
88
+ ...{ [key: string]: mixed },
89
+ |}) => void)
90
+ | void,
82
91
  customKeypad?: boolean | void,
83
92
  nativeKeypadProxy?: (() => mixed) | void,
84
93
  isMobile?: boolean | void,
@@ -112,8 +112,8 @@ declare export class ServerItemRenderer
112
112
  setAssetStatus: (assetKey: string, status: boolean) => void;
113
113
  render(): React.Node;
114
114
  }
115
- declare var ref: React.ForwardRefExoticComponent<{|
116
- ...$Diff<
115
+ declare var ref: React.AbstractComponent<
116
+ $Diff<
117
117
  {|
118
118
  ...KeypadProps,
119
119
  ...{|
@@ -131,6 +131,6 @@ declare var ref: React.ForwardRefExoticComponent<{|
131
131
  |},
132
132
  { onRendered: any }
133
133
  >,
134
- ...React.RefAttributes<ServerItemRenderer>,
135
- |}>;
134
+ ServerItemRenderer
135
+ >;
136
136
  declare export default typeof ref;
package/dist/types.d.ts CHANGED
@@ -108,7 +108,11 @@ export type APIOptions = Readonly<{
108
108
  Link: React.ComponentType<any>;
109
109
  };
110
110
  imagePreloader?: (dimensions: Dimensions) => React.ReactNode;
111
- trackInteraction?: () => unknown;
111
+ trackInteraction?: (args: {
112
+ type: string;
113
+ id: string;
114
+ correct?: boolean;
115
+ } & Record<string, unknown>) => void;
112
116
  customKeypad?: boolean;
113
117
  nativeKeypadProxy?: () => unknown;
114
118
  isMobile?: boolean;
@@ -132,7 +132,14 @@ export type APIOptions = $ReadOnly<{|
132
132
  Link: React.ComponentType<any>,
133
133
  |},
134
134
  imagePreloader?: (dimensions: Dimensions) => React.Node,
135
- trackInteraction?: () => mixed,
135
+ trackInteraction?: (args: {|
136
+ ...{|
137
+ type: string,
138
+ id: string,
139
+ correct?: boolean,
140
+ |},
141
+ ...{ [key: string]: mixed },
142
+ |}) => void,
136
143
  customKeypad?: boolean,
137
144
  nativeKeypadProxy?: () => mixed,
138
145
  isMobile?: boolean,
@@ -25,8 +25,5 @@ export type ChoiceProps = {|
25
25
  crossedOut: boolean,
26
26
  |}) => void,
27
27
  |};
28
- declare var _default: React.ForwardRefExoticComponent<{|
29
- ...ChoiceProps,
30
- ...React.RefAttributes<HTMLButtonElement>,
31
- |}>;
28
+ declare var _default: React.AbstractComponent<ChoiceProps, HTMLButtonElement>;
32
29
  declare export default typeof _default;
@@ -1,56 +1,21 @@
1
- import PropTypes from "prop-types";
2
1
  import * as React from "react";
3
- declare class Sequence extends React.Component<any, any> {
4
- static propTypes: {
5
- apiOptions: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
6
- isArticle: PropTypes.Validator<boolean>;
7
- onInputError: PropTypes.Validator<(...args: any[]) => any>;
8
- onFocusChange: PropTypes.Validator<(...args: any[]) => any>;
9
- GroupMetadataEditor: PropTypes.Validator<(...args: any[]) => any>;
10
- showAlignmentOptions: PropTypes.Validator<boolean>;
11
- readOnly: PropTypes.Validator<boolean>;
12
- answerableCallback: PropTypes.Requireable<(...args: any[]) => any>;
13
- getAnotherHint: PropTypes.Requireable<(...args: any[]) => any>;
14
- interactionCallback: PropTypes.Requireable<(...args: any[]) => any>;
15
- groupAnnotator: PropTypes.Validator<(...args: any[]) => any>;
16
- imagePlaceholder: PropTypes.Requireable<PropTypes.ReactNodeLike>;
17
- widgetPlaceholder: PropTypes.Requireable<PropTypes.ReactNodeLike>;
18
- baseElements: PropTypes.Requireable<PropTypes.InferProps<{
19
- Link: PropTypes.Requireable<(...args: any[]) => any>;
20
- }>>;
21
- imagePreloader: PropTypes.Requireable<(...args: any[]) => any>;
22
- trackInteraction: PropTypes.Requireable<(...args: any[]) => any>;
23
- customKeypad: PropTypes.Requireable<boolean>;
24
- nativeKeypadProxy: PropTypes.Requireable<(...args: any[]) => any>;
25
- isMobile: PropTypes.Requireable<boolean>;
26
- setDrawingAreaAvailable: PropTypes.Requireable<(...args: any[]) => any>;
27
- useDraftEditor: PropTypes.Requireable<boolean>;
28
- hintProgressColor: PropTypes.Requireable<string>;
29
- canScrollPage: PropTypes.Requireable<boolean>;
30
- inModal: PropTypes.Requireable<boolean>;
31
- crossOutEnabled: PropTypes.Requireable<boolean>;
32
- editorChangeDelay: PropTypes.Requireable<number>;
33
- }>>>;
34
- json: PropTypes.Requireable<(PropTypes.InferProps<{
35
- content: PropTypes.Requireable<string>;
36
- images: PropTypes.Requireable<{
37
- [x: string]: any;
38
- }>;
39
- widgets: PropTypes.Requireable<{
40
- [x: string]: any;
41
- }>;
42
- }> | null | undefined)[]>;
43
- trackInteraction: PropTypes.Validator<(...args: any[]) => any>;
44
- linterContext: PropTypes.Requireable<PropTypes.InferProps<{
45
- contentType: PropTypes.Requireable<string>;
46
- highlightLint: PropTypes.Requireable<boolean>;
47
- paths: PropTypes.Requireable<(string | null | undefined)[]>;
48
- stack: PropTypes.Requireable<(string | null | undefined)[]>;
49
- }>>;
50
- onChange: PropTypes.Validator<(...args: any[]) => any>;
2
+ import { PerseusSequenceWidgetOptions } from "../perseus-types";
3
+ import type { WidgetProps } from "../types";
4
+ type Rubric = PerseusSequenceWidgetOptions;
5
+ type ExternalProps = WidgetProps<PerseusSequenceWidgetOptions, Rubric>;
6
+ type Props = ExternalProps;
7
+ type DefaultProps = {
8
+ json: Props["json"];
9
+ linterContext: Props["linterContext"];
10
+ };
11
+ type State = {
12
+ visible: number;
13
+ };
14
+ declare class Sequence extends React.Component<Props, State> {
15
+ static defaultProps: DefaultProps;
16
+ state: {
17
+ visible: number;
51
18
  };
52
- static defaultProps: any;
53
- state: any;
54
19
  shouldComponentUpdate(nextProps: any, nextState: any): boolean;
55
20
  change: (arg1: any, arg2: any, arg3: any) => any;
56
21
  _handleInteraction: (arg1: string) => void;
@@ -5,71 +5,24 @@
5
5
  * @flow
6
6
  */
7
7
  import * as $Flowgen$Import$_2e__2e__2f_types from "../types";
8
- import PropTypes from "prop-types";
9
8
  import * as React from "react";
10
- declare class Sequence extends React.Component<any, any> {
11
- static propTypes: {|
12
- apiOptions: PropTypes.Validator<
13
- $NonMaybeType<
14
- PropTypes.InferProps<{|
15
- isArticle: PropTypes.Validator<boolean>,
16
- onInputError: PropTypes.Validator<(...args: any[]) => any>,
17
- onFocusChange: PropTypes.Validator<(...args: any[]) => any>,
18
- GroupMetadataEditor: PropTypes.Validator<(...args: any[]) => any>,
19
- showAlignmentOptions: PropTypes.Validator<boolean>,
20
- readOnly: PropTypes.Validator<boolean>,
21
- answerableCallback: PropTypes.Requireable<(...args: any[]) => any>,
22
- getAnotherHint: PropTypes.Requireable<(...args: any[]) => any>,
23
- interactionCallback: PropTypes.Requireable<(...args: any[]) => any>,
24
- groupAnnotator: PropTypes.Validator<(...args: any[]) => any>,
25
- imagePlaceholder: PropTypes.Requireable<PropTypes.ReactNodeLike>,
26
- widgetPlaceholder: PropTypes.Requireable<PropTypes.ReactNodeLike>,
27
- baseElements: PropTypes.Requireable<
28
- PropTypes.InferProps<{|
29
- Link: PropTypes.Requireable<(...args: any[]) => any>,
30
- |}>
31
- >,
32
- imagePreloader: PropTypes.Requireable<(...args: any[]) => any>,
33
- trackInteraction: PropTypes.Requireable<(...args: any[]) => any>,
34
- customKeypad: PropTypes.Requireable<boolean>,
35
- nativeKeypadProxy: PropTypes.Requireable<(...args: any[]) => any>,
36
- isMobile: PropTypes.Requireable<boolean>,
37
- setDrawingAreaAvailable: PropTypes.Requireable<
38
- (...args: any[]) => any
39
- >,
40
- useDraftEditor: PropTypes.Requireable<boolean>,
41
- hintProgressColor: PropTypes.Requireable<string>,
42
- canScrollPage: PropTypes.Requireable<boolean>,
43
- inModal: PropTypes.Requireable<boolean>,
44
- crossOutEnabled: PropTypes.Requireable<boolean>,
45
- editorChangeDelay: PropTypes.Requireable<number>,
46
- |}>
47
- >
48
- >,
49
- json: PropTypes.Requireable<
50
- (PropTypes.InferProps<{|
51
- content: PropTypes.Requireable<string>,
52
- images: PropTypes.Requireable<{
53
- [x: string]: any,
54
- }>,
55
- widgets: PropTypes.Requireable<{
56
- [x: string]: any,
57
- }>,
58
- |}> | null | void)[]
59
- >,
60
- trackInteraction: PropTypes.Validator<(...args: any[]) => any>,
61
- linterContext: PropTypes.Requireable<
62
- PropTypes.InferProps<{|
63
- contentType: PropTypes.Requireable<string>,
64
- highlightLint: PropTypes.Requireable<boolean>,
65
- paths: PropTypes.Requireable<(string | null | void)[]>,
66
- stack: PropTypes.Requireable<(string | null | void)[]>,
67
- |}>
68
- >,
69
- onChange: PropTypes.Validator<(...args: any[]) => any>,
9
+ import { PerseusSequenceWidgetOptions } from "../perseus-types";
10
+ import type { WidgetProps } from "../types";
11
+ declare type Rubric = PerseusSequenceWidgetOptions;
12
+ declare type ExternalProps = WidgetProps<PerseusSequenceWidgetOptions, Rubric>;
13
+ declare type Props = ExternalProps;
14
+ declare type DefaultProps = {|
15
+ json: $PropertyType<Props, "json">,
16
+ linterContext: $PropertyType<Props, "linterContext">,
17
+ |};
18
+ declare type State = {|
19
+ visible: number,
20
+ |};
21
+ declare class Sequence extends React.Component<Props, State> {
22
+ static defaultProps: DefaultProps;
23
+ state: {|
24
+ visible: number,
70
25
  |};
71
- static defaultProps: any;
72
- state: any;
73
26
  shouldComponentUpdate(nextProps: any, nextState: any): boolean;
74
27
  change: (arg1: any, arg2: any, arg3: any) => any;
75
28
  _handleInteraction: (arg1: string) => void;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Core Perseus API (includes renderers and widgets)",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "6.5.0",
6
+ "version": "6.6.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -23,7 +23,7 @@
23
23
  "dependencies": {
24
24
  "@khanacademy/kas": "^0.3.1",
25
25
  "@khanacademy/kmath": "^0.1.1",
26
- "@khanacademy/math-input": "^6.0.3",
26
+ "@khanacademy/math-input": "^7.0.0",
27
27
  "@khanacademy/perseus-core": "0.0.2",
28
28
  "@khanacademy/perseus-linter": "^0.3.1",
29
29
  "@khanacademy/pure-markdown": "^0.2.3",
package/src/index.ts CHANGED
@@ -128,6 +128,7 @@ export type {
128
128
  PerseusImageBackground,
129
129
  PerseusInteractiveGraphWidgetOptions,
130
130
  PerseusRadioWidgetOptions,
131
+ PerseusExpressionWidgetOptions,
131
132
  PerseusRenderer,
132
133
  } from "./perseus-types";
133
134
  export type {Coord} from "./interactive2/types";
@@ -1,3 +1,5 @@
1
+ import type {APIOptions, Tracking} from "./types";
2
+
1
3
  /**
2
4
  * This alternate version of `.track` does nothing as an optimization.
3
5
  */
@@ -10,7 +12,7 @@ class InteractionTracker {
10
12
  // @ts-expect-error [FEI-5003] - TS2564 - Property '_tracked' has no initializer and is not definitely assigned in the constructor.
11
13
  _tracked: boolean;
12
14
  // @ts-expect-error [FEI-5003] - TS2564 - Property 'setting' has no initializer and is not definitely assigned in the constructor.
13
- setting: string;
15
+ setting: Tracking;
14
16
  track: (extraData?: any) => void;
15
17
  trackApi: any;
16
18
  // @ts-expect-error [FEI-5003] - TS2564 - Property 'widgetID' has no initializer and is not definitely assigned in the constructor.
@@ -19,10 +21,10 @@ class InteractionTracker {
19
21
  widgetType: string;
20
22
 
21
23
  constructor(
22
- trackApi: any, // original apiOptions.trackInteraction
24
+ trackApi: APIOptions["trackInteraction"],
23
25
  widgetType: string,
24
26
  widgetID: string,
25
- setting: "" | "all", // "" means track once
27
+ setting: Tracking,
26
28
  ) {
27
29
  if (!trackApi) {
28
30
  this.track = _noop;
@@ -44,7 +46,7 @@ class InteractionTracker {
44
46
  * @param extraData Any extra data to track about the event.
45
47
  * @private
46
48
  */
47
- _track: (extraData: unknown) => void = (extraData: unknown) => {
49
+ _track: (extraData: Record<string, any>) => void = (extraData) => {
48
50
  if (this._tracked && !this.setting) {
49
51
  return;
50
52
  }
@@ -52,7 +54,6 @@ class InteractionTracker {
52
54
  this.trackApi({
53
55
  type: this.widgetType,
54
56
  id: this.widgetID,
55
- // @ts-expect-error [FEI-5003] - TS2698 - Spread types may only be created from object types.
56
57
  ...extraData,
57
58
  });
58
59
  };
@@ -1,4 +1,6 @@
1
- .perseus-widget-passage-container {
1
+ // this selector increases specificity to beat out other stylesheets while still
2
+ // allowing for more than one passage widget on a page
3
+ [id^="perseus-widget-passage-container"] {
2
4
  // NOTE(mdr): This is similar to Wonder Blocks "BodySerif" typesetting, but
3
5
  // not quite: it's a bit smaller, for consistency with the sorta-small
4
6
  // type styles in rest of the Perseus.
@@ -8,7 +10,7 @@
8
10
  @font-size: 16px;
9
11
  @line-height: 20px;
10
12
 
11
- .perseus-widget-passage {
13
+ [id^="perseus-widget-passage"] {
12
14
  line-height: @line-height;
13
15
  margin: 22px;
14
16
  position: relative;
@@ -31,35 +33,43 @@
31
33
  // switch to the BodySerif component (TP-3112), and remove this
32
34
  // special font-family rule.
33
35
  div.paragraph {
34
- font-family: "minion-pro", KaTeX_Main, Times, "Times New Roman", serif;
36
+ font-family: "minion-pro", KaTeX_Main, Times, "Times New Roman",
37
+ serif;
35
38
  }
36
- }
37
- .katex {
38
- line-height: @line-height - 2;
39
- }
40
- .passage-title div.paragraph {
41
- font-family: "Noto Serif", serif;
42
- font-weight: 700;
43
- font-size: 20px;
44
- line-height: 22px;
45
39
 
46
- margin: 0 0 10px;
47
- }
40
+ .passage-title div.paragraph {
41
+ font-family: "Noto Serif", serif;
42
+ font-weight: 700;
43
+ font-size: 20px;
44
+ line-height: 22px;
48
45
 
49
- // note(matthewc): If you need to change any of this,
50
- // check that line numbers line up correctly.
51
- // The margin should probably be 0 or the line height
52
- .passage-text div.paragraph {
53
- font-weight: 400;
54
- font-size: @font-size;
55
- line-height: @line-height;
56
- text-indent: 20px;
57
- margin: 0;
46
+ margin: 0 0 10px;
47
+ }
58
48
 
59
- span {
60
- text-indent: 0;
49
+ // note(matthewc): If you need to change any of this,
50
+ // check that line numbers line up correctly.
51
+ // The margin should probably be 0 or the line height
52
+ .passage-text div.paragraph {
53
+ font-weight: 400;
54
+ font-size: @font-size;
55
+ line-height: @line-height;
56
+ text-indent: 20px;
57
+ margin: 0;
58
+
59
+ span {
60
+ text-indent: 0;
61
+ }
62
+
63
+ em {
64
+ // prevents italicized text from disrupting the line height
65
+ line-height: 0;
66
+ }
61
67
  }
62
68
  }
69
+ .katex {
70
+ line-height: @line-height - 2;
71
+ }
72
+
63
73
  .footnotes {
64
74
  margin-top: 22px;
65
75
  div.paragraph {
@@ -68,10 +78,10 @@
68
78
  }
69
79
  }
70
80
  .perseus-highlight {
71
- background-color: #FFFABE;
81
+ background-color: #fffabe;
72
82
  }
73
83
  .perseus-review-highlight {
74
- background-color: #EEE7B2;
84
+ background-color: #eee7b2;
75
85
  }
76
86
  .perseus-passage-square-label,
77
87
  .perseus-passage-circle-label,
@@ -138,7 +148,6 @@
138
148
  }
139
149
 
140
150
  .perseus-widget-passage-editor {
141
-
142
151
  .perseus-single-editor {
143
152
  font-family: Times, "Times New Roman", serif;
144
153
 
package/src/types.ts CHANGED
@@ -179,11 +179,18 @@ export type APIOptions = Readonly<{
179
179
  // Function that takes dimensions and returns a React component
180
180
  // to display while an image is loading
181
181
  imagePreloader?: (dimensions: Dimensions) => React.ReactNode;
182
- // Function that takes an object argument. The object should
183
- // include type and id, both strings, at least and can optionally
184
- // include a boolean "correct" value. This is used for keeping
185
- // track of widget interactions.
186
- trackInteraction?: () => unknown;
182
+ // A function that is called when the user has interacted with a widget. It
183
+ // also includes any extra parameters that the originating widget provided.
184
+ // This is used for keeping track of widget interactions.
185
+ trackInteraction?: (
186
+ args: {
187
+ // The widget type that this interaction originates from
188
+ type: string;
189
+ // The widget id that this interaction originates from
190
+ id: string;
191
+ correct?: boolean;
192
+ } & Record<string, unknown>,
193
+ ) => void;
187
194
  // A boolean that indicates whether or not a custom keypad is
188
195
  // being used. For mobile web this will be the ProvidedKeypad
189
196
  // component. In this situation we use the MathInput component
@@ -371,7 +378,12 @@ export type LinterContextProps = {
371
378
  // additional properties can be added to the context by widgets
372
379
  };
373
380
 
374
- export type Tracking = "" | "all";
381
+ export type Tracking =
382
+ // Track interactions once
383
+ | ""
384
+ // Track all interactions
385
+ | "all";
386
+
375
387
  export type Alignment =
376
388
  | "default"
377
389
  | "block"
@@ -462,6 +474,10 @@ export type WidgetProps<RenderProps, Rubric> = RenderProps & {
462
474
  findWidgets: (arg1: FilterCriterion) => ReadonlyArray<Widget>;
463
475
  reviewModeRubric: Rubric;
464
476
  onChange: ChangeHandler;
477
+ // This is slightly different from the `trackInteraction` function in
478
+ // APIOptions. This provides the widget an easy way to notify the renderer
479
+ // of an interaction. The Renderer then enriches the data provided with the
480
+ // widget's id and type before calling APIOptions.trackInteraction.
465
481
  trackInteraction: (extraData?: any) => void;
466
482
  isLastUsedWidget: boolean;
467
483
  // provided by widget-container.jsx#render()
@@ -1,9 +1,10 @@
1
+ import {View} from "@khanacademy/wonder-blocks-core";
1
2
  import * as React from "react";
2
3
 
3
4
  import {RendererWithDebugUI} from "../../../../../testing/renderer-with-debug-ui";
4
5
  import {question1, question2} from "../__testdata__/passage-ref.testdata";
5
6
 
6
- type StoryArgs = Record<any, any>;
7
+ import type {PerseusRenderer} from "../../perseus-types";
7
8
 
8
9
  type Story = {
9
10
  title: string;
@@ -13,10 +14,20 @@ export default {
13
14
  title: "Perseus/Widgets/PassageRef",
14
15
  } as Story;
15
16
 
16
- export const ShortPassage = (args: StoryArgs): React.ReactElement => {
17
- return <RendererWithDebugUI question={question1} />;
18
- };
17
+ const Template = (props: {question: PerseusRenderer}): React.ReactElement => (
18
+ <View
19
+ style={{
20
+ paddingLeft: 20,
21
+ }}
22
+ >
23
+ <RendererWithDebugUI question={props.question} />
24
+ </View>
25
+ );
19
26
 
20
- export const LongPassage = (args: StoryArgs): React.ReactElement => {
21
- return <RendererWithDebugUI question={question2} />;
22
- };
27
+ export const ShortPassage = (): React.ReactElement => (
28
+ <Template question={question1} />
29
+ );
30
+
31
+ export const LongPassage = (): React.ReactElement => (
32
+ <Template question={question2} />
33
+ );
@@ -1,3 +1,4 @@
1
+ import {View} from "@khanacademy/wonder-blocks-core";
1
2
  import * as React from "react";
2
3
 
3
4
  import {RendererWithDebugUI} from "../../../../../testing/renderer-with-debug-ui";
@@ -7,20 +8,32 @@ import {
7
8
  question3,
8
9
  } from "../__testdata__/passage.testdata";
9
10
 
11
+ import type {PerseusRenderer} from "../../perseus-types";
12
+
10
13
  export default {
11
14
  title: "Perseus/Widgets/Passage",
12
15
  };
13
16
 
14
17
  type StoryArgs = Record<any, any>;
15
18
 
19
+ const Template = (props: {question: PerseusRenderer}): React.ReactElement => (
20
+ <View
21
+ style={{
22
+ paddingLeft: 20,
23
+ }}
24
+ >
25
+ <RendererWithDebugUI question={props.question} />
26
+ </View>
27
+ );
28
+
16
29
  export const SimpleQuestion = (args: StoryArgs): React.ReactElement => {
17
- return <RendererWithDebugUI question={question1} />;
30
+ return <Template question={question1} />;
18
31
  };
19
32
 
20
33
  export const MultiPassageQuestion = (args: StoryArgs): React.ReactElement => {
21
- return <RendererWithDebugUI question={question2} />;
34
+ return <Template question={question2} />;
22
35
  };
23
36
 
24
37
  export const SingleNumberedPassage = (args: StoryArgs): React.ReactElement => {
25
- return <RendererWithDebugUI question={question3} />;
38
+ return <Template question={question3} />;
26
39
  };