diff --git a/.changeset/honest-geckos-brush.md b/.changeset/honest-geckos-brush.md new file mode 100644 index 0000000000..48296181b5 --- /dev/null +++ b/.changeset/honest-geckos-brush.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/perseus": patch +--- + +Cleanup widget option types diff --git a/packages/perseus/src/perseus-types.ts b/packages/perseus/src/perseus-types.ts index f29f6bdcf6..3b50bc88ad 100644 --- a/packages/perseus/src/perseus-types.ts +++ b/packages/perseus/src/perseus-types.ts @@ -986,7 +986,7 @@ export type PerseusMeasurerWidgetOptions = { // The number of units to display on the ruler rulerLength: number; // Containing area [width, height] - box: ReadonlyArray; + box: [number, number]; // Always false. Not used for this widget static: boolean; }; @@ -1200,24 +1200,6 @@ export type PerseusRadioChoice = { widgets?: PerseusWidgetsMap; }; -export type PerseusSequenceWidgetOptions = { - // A list of Renderers to display in sequence - json: ReadonlyArray; -}; - -export type PerseusSimulatorWidgetOptions = { - // Translatable Text; The X Axis - xAxisLabel: string; - // Translatable Text; The Y Axis - yAxisLabel: string; - // Translatable Text; A lable to define the proportion of the simulation - proportionLabel: string; - // The type of simulation. options: "proportion", "percentage" - proportionOrPercentage: string; - // The number of times to run the simulation - numTrials: number; -}; - export type PerseusSorterWidgetOptions = { // Translatable Text; The correct answer (in the correct order). The user will see the cards in a randomized order. correct: ReadonlyArray; diff --git a/packages/perseus/src/widgets/label-image/label-image.tsx b/packages/perseus/src/widgets/label-image/label-image.tsx index ef362d0370..e2e5c0455c 100644 --- a/packages/perseus/src/widgets/label-image/label-image.tsx +++ b/packages/perseus/src/widgets/label-image/label-image.tsx @@ -29,6 +29,7 @@ import Marker from "./marker"; import type {InteractiveMarkerType} from "./types"; import type {DependencyProps} from "../../dependencies"; import type {ChangeableProps} from "../../mixins/changeable"; +import type {PerseusLabelImageWidgetOptions} from "../../perseus-types"; import type {APIOptions, Widget, WidgetExports} from "../../types"; import type { PerseusLabelImageRubric, @@ -67,23 +68,14 @@ type Point = { y: number; }; -// TODO: should this be using WidgetProps / PerseusLabelImageWidgetOptions? type LabelImageProps = ChangeableProps & - DependencyProps & { + DependencyProps & + // TODO: there's some weirdness in our types between + // PerseusLabelImageMarker and InteractiveMarkerType + Omit & { apiOptions: APIOptions; - // The list of possible answer choices. - choices: ReadonlyArray; - // The question image properties. - imageAlt: string; - imageUrl: string; - imageWidth: number; - imageHeight: number; // The list of label markers on the question image. markers: ReadonlyArray; - // Whether multiple answer choices may be selected for markers. - multipleAnswers: boolean; - // Whether to hide answer choices from user instructions. - hideChoicesFromInstructions: boolean; // Whether the question has been answered by the user. questionCompleted: boolean; // preferred placement for popover (preference, not MUST) diff --git a/packages/perseus/src/widgets/measurer/measurer.tsx b/packages/perseus/src/widgets/measurer/measurer.tsx index d41eb8ad13..f5f8645398 100644 --- a/packages/perseus/src/widgets/measurer/measurer.tsx +++ b/packages/perseus/src/widgets/measurer/measurer.tsx @@ -8,7 +8,8 @@ import GraphUtils from "../../util/graph-utils"; import noopValidator from "../__shared__/noop-validator"; import type {Coord} from "../../interactive2/types"; -import type {APIOptions, Widget, WidgetExports} from "../../types"; +import type {PerseusMeasurerWidgetOptions} from "../../perseus-types"; +import type {Widget, WidgetExports, WidgetProps} from "../../types"; import type {Interval} from "../../util/interval"; const defaultImage = { @@ -17,22 +18,14 @@ const defaultImage = { left: 0, } as const; -type Props = { - apiOptions: APIOptions; - box: [number, number]; - image: { - url?: string; - top?: number; - left?: number; - }; - showProtractor: boolean; +type Props = WidgetProps< + PerseusMeasurerWidgetOptions, + PerseusMeasurerWidgetOptions +> & { + // TODO: these don't show up anywhere else in code + // I'm guessing they could just be constants protractorX: number; protractorY: number; - showRuler: boolean; - rulerLabel: string; - rulerTicks: number; - rulerPixels: number; - rulerLength: number; }; type DefaultProps = { @@ -51,7 +44,7 @@ type DefaultProps = { class Measurer extends React.Component implements Widget { static defaultProps: DefaultProps = { box: [480, 480], - image: {}, + image: defaultImage, showProtractor: true, protractorX: 7.5, protractorY: 0.5,