Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/old-fishes-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus-editor": patch
---

Adding improved type safeguards to components folder in perseus-editor.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {action} from "storybook/actions";
import BlurInput from "../blur-input";

export default {
title: "PerseusEditor/Components/Blur Input",
title: "Editors/Components/Blur Input",
};

export const Default = (): React.ReactElement => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {LockedFigureColor} from "@khanacademy/perseus-core";
import type {Meta} from "@storybook/react-vite";

export default {
title: "PerseusEditor/Components/Color Select",
title: "Editors/Components/Color Select",
component: ColorSelect,
} as Meta<typeof ColorSelect>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ColorSwatch from "../../widgets/interactive-graph-editor/locked-figures/c
import type {Meta} from "@storybook/react-vite";

export default {
title: "PerseusEditor/Components/Color Swatch",
title: "Editors/Components/Color Swatch",
component: ColorSwatch,
} as Meta<typeof ColorSwatch>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {Meta, StoryObj} from "@storybook/react-vite";

const meta: Meta<typeof DeviceFramer> = {
component: DeviceFramer,
title: "PerseusEditor/Components/Device Framer",
title: "Editors/Components/Device Framer",
};

export default meta;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import GraphSettings from "../graph-settings";
import GraphSettingsArgTypes from "./graph-settings.argtypes";

export default {
title: "PerseusEditor/Components/Graph Settings",
title: "Editors/Components/Graph Settings",
component: GraphSettings,
argTypes: GraphSettingsArgTypes,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import InteractiveGraphSettingsArgTypes from "./interactive-graph-settings.argty
import type {StoryObj} from "@storybook/react-vite";

export default {
title: "PerseusEditor/Components/Interactive Graph Settings",
title: "Editors/Components/Interactive Graph Settings",
component: InteractiveGraphSettings,
argTypes: InteractiveGraphSettingsArgTypes,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import LockedEllipseSettings from "../../widgets/interactive-graph-editor/locked
import type {Meta, StoryObj} from "@storybook/react-vite";

export default {
title: "PerseusEditor/Components/Locked Ellipse Settings",
title: "Editors/Components/Locked Ellipse Settings",
component: LockedEllipseSettings,
} as Meta<typeof LockedEllipseSettings>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import LockedFiguresSection from "../../widgets/interactive-graph-editor/locked-
import type {Meta, StoryObj} from "@storybook/react-vite";

export default {
title: "PerseusEditor/Components/Locked Figures Section",
title: "Editors/Components/Locked Figures Section",
component: LockedFiguresSection,
} as Meta<typeof LockedFiguresSection>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import LockedFunctionSettings from "../../widgets/interactive-graph-editor/locke
import type {Meta, StoryObj} from "@storybook/react-vite";

export default {
title: "PerseusEditor/Components/Locked Function Settings",
title: "Editors/Components/Locked Function Settings",
component: LockedFunctionSettings,
} as Meta<typeof LockedFunctionSettings>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import LockedLabelSettings from "../../widgets/interactive-graph-editor/locked-f
import type {Meta, StoryObj} from "@storybook/react-vite";

export default {
title: "PerseusEditor/Components/Locked Label Settings",
title: "Editors/Components/Locked Label Settings",
component: LockedLabelSettings,
} as Meta<typeof LockedLabelSettings>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import LockedLineSettings from "../../widgets/interactive-graph-editor/locked-fi
import type {Meta, StoryObj} from "@storybook/react-vite";

export default {
title: "PerseusEditor/Components/Locked Line Settings",
title: "Editors/Components/Locked Line Settings",
component: LockedLineSettings,
} as Meta<typeof LockedLineSettings>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import LockedPointSettings from "../../widgets/interactive-graph-editor/locked-f
import type {Meta, StoryObj} from "@storybook/react-vite";

export default {
title: "PerseusEditor/Components/Locked Point Settings",
title: "Editors/Components/Locked Point Settings",
component: LockedPointSettings,
} as Meta<typeof LockedPointSettings>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import LockedPolygonSettings from "../../widgets/interactive-graph-editor/locked
import type {Meta, StoryObj} from "@storybook/react-vite";

export default {
title: "PerseusEditor/Components/Locked Polygon Settings",
title: "Editors/Components/Locked Polygon Settings",
component: LockedPolygonSettings,
} as Meta<typeof LockedPolygonSettings>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import LockedVectorSettings from "../../widgets/interactive-graph-editor/locked-
import type {Meta, StoryObj} from "@storybook/react-vite";

export default {
title: "PerseusEditor/Components/Locked Vector Settings",
title: "Editors/Components/Locked Vector Settings",
component: LockedVectorSettings,
} as Meta<typeof LockedVectorSettings>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ScrolllessNumberTextField from "../scrollless-number-text-field";
import type {StoryObj, Meta} from "@storybook/react-vite";

export default {
title: "PerseusEditor/Components/Scrollless Number Text Field",
title: "Editors/Components/Scrollless Number Text Field",
component: ScrolllessNumberTextField,
} as Meta<typeof ScrolllessNumberTextField>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import * as React from "react";

import SectionControlButton from "../section-control-button";

type StoryArgs = Record<any, any>;
type StoryArgs = Record<string, unknown>;

type Story = {
title: string;
};

export default {
title: "PerseusEditor/Components/Section Control Button",
title: "Editors/Components/Section Control Button",
} as Story;

export const ButtonForEditingSectionsOfContentWithInArticleEditor = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {StoryObj, Meta} from "@storybook/react-vite";
type Story = StoryObj<typeof ToggleableCaret>;

export default {
title: "PerseusEditor/Components/Toggleable Caret",
title: "Editors/Components/Toggleable Caret",
component: ToggleableCaret,
} satisfies Meta;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {Meta, StoryFn} from "@storybook/react-vite";

const meta: Meta<typeof ViewportResizer> = {
component: ViewportResizer,
title: "PerseusEditor/Components/Viewport Resizer",
title: "Editors/Components/Viewport Resizer",
};

export default meta;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ describe("GraphSettings", () => {
// Assert
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({markings: "grid"}),
undefined,
);
});

Expand All @@ -192,7 +191,6 @@ describe("GraphSettings", () => {
// Assert
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({rulerLabel: "cm"}),
undefined,
);
});

Expand All @@ -214,7 +212,6 @@ describe("GraphSettings", () => {
// Assert
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({rulerTicks: 4}),
undefined,
);
});

Expand Down Expand Up @@ -245,7 +242,6 @@ describe("GraphSettings", () => {
url: "https://example.com/image.png",
}),
}),
undefined,
),
);
});
Expand Down Expand Up @@ -276,7 +272,6 @@ describe("GraphSettings", () => {
expect.objectContaining({
valid: "Image must be smaller than 450px x 450px.",
}),
undefined,
),
);
});
Expand Down Expand Up @@ -306,7 +301,6 @@ describe("GraphSettings", () => {
url: null,
}),
}),
undefined,
),
);
});
Expand Down Expand Up @@ -353,7 +347,6 @@ describe("GraphSettings", () => {
// Assert
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({showProtractor: false}),
undefined,
);
});

Expand Down Expand Up @@ -381,7 +374,6 @@ describe("GraphSettings", () => {
],
valid: true,
}),
undefined,
),
);
});
Expand Down Expand Up @@ -410,7 +402,6 @@ describe("GraphSettings", () => {
],
valid: true,
}),
undefined,
),
);
});
Expand All @@ -433,13 +424,8 @@ describe("GraphSettings", () => {
await waitFor(() =>
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
range: [
[-10, 10],
[-10, 10],
],
valid: "Range must have a higher number on the right",
}),
undefined,
),
);
});
Expand All @@ -465,7 +451,6 @@ describe("GraphSettings", () => {
step: [2, 1],
valid: true,
}),
undefined,
),
);
});
Expand All @@ -488,10 +473,8 @@ describe("GraphSettings", () => {
await waitFor(() =>
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
step: [1, 1],
valid: "Step is too large, there must be at least 3 ticks.",
}),
undefined,
),
);
});
Expand Down Expand Up @@ -521,10 +504,8 @@ describe("GraphSettings", () => {
await waitFor(() =>
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
step: [1, 1],
valid: "Step is too small, there can be at most 20 ticks.",
}),
undefined,
),
);
});
Expand Down Expand Up @@ -554,7 +535,6 @@ describe("GraphSettings", () => {
snapStep: [2, 1],
valid: true,
}),
undefined,
),
);
});
Expand All @@ -581,10 +561,8 @@ describe("GraphSettings", () => {
await waitFor(() =>
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
snapStep: [1, 1],
valid: "Snap step is too large, there must be at least 5 ticks.",
}),
undefined,
),
);
});
Expand All @@ -611,7 +589,6 @@ describe("GraphSettings", () => {
gridStep: [2, 1],
valid: true,
}),
undefined,
),
);
});
Expand All @@ -635,10 +612,8 @@ describe("GraphSettings", () => {
await waitFor(() =>
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
gridStep: [1, 1],
valid: "Grid step is too large, there must be at least 3 ticks.",
}),
undefined,
),
);
});
Expand All @@ -664,7 +639,6 @@ describe("GraphSettings", () => {
expect.objectContaining({
labels: ["time", "y"],
}),
undefined,
),
);
});
Expand All @@ -690,7 +664,6 @@ describe("GraphSettings", () => {
expect.objectContaining({
labels: ["x", "count"],
}),
undefined,
),
);
});
Expand Down Expand Up @@ -719,7 +692,6 @@ describe("GraphSettings", () => {
expect.objectContaining({
box: [300, 288],
}),
undefined,
),
);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/perseus-editor/src/components/blur-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ class BlurInput extends React.Component<Props, State> {
this.setState({value: nextProps.value});
}

handleChange: (e: any) => void = (e) => {
handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
this.setState({value: e.target.value});
};

handleBlur: (e: any) => void = (e) => {
handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
this.props.onChange(e.target.value);
};

Expand Down
Loading
Loading