Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Interactive Graph Editor] Add/Edit/Delete Locked Function #1493

Merged
merged 14 commits into from
Aug 8, 2024
Merged
6 changes: 6 additions & 0 deletions .changeset/chilly-apples-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@khanacademy/perseus-editor": minor
"@khanacademy/perseus": patch
---

Add/Edit/Delete Locked Function in Interactive Graph Editor
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import * as React from "react";

import LockedFunctionSettings from "../graph-locked-figures/locked-function-settings";
import {getDefaultFigureForType} from "../util";

import type {Meta, StoryObj} from "@storybook/react";

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

export const Default = (args): React.ReactElement => {
return <LockedFunctionSettings {...args} />;
};

const defaultProps = {
...getDefaultFigureForType("function"),
onChangeProps: () => {},
onMove: () => {},
onRemove: () => {},
};

type StoryComponentType = StoryObj<typeof LockedFunctionSettings>;

// Set the default values in the control panel.
Default.args = defaultProps;

export const Expanded: StoryComponentType = {
render: function Render() {
const [props, setProps] = React.useState(defaultProps);

const handlePropsUpdate = (newProps) => {
setProps({
...props,
...newProps,
});
};

return (
<LockedFunctionSettings
{...props}
expanded={true}
onChangeProps={handlePropsUpdate}
/>
);
},
};
Loading