-
Notifications
You must be signed in to change notification settings - Fork 365
Expand file tree
/
Copy pathlocked-ellipse-settings.stories.tsx
More file actions
78 lines (64 loc) · 2.08 KB
/
locked-ellipse-settings.stories.tsx
File metadata and controls
78 lines (64 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import {getDefaultFigureForType} from "@khanacademy/perseus-core";
import * as React from "react";
import LockedEllipseSettings from "../../widgets/interactive-graph-editor/locked-figures/locked-ellipse-settings";
import type {Meta, StoryObj} from "@storybook/react-vite";
export default {
title: "Editors/Components/Locked Ellipse Settings",
component: LockedEllipseSettings,
} as Meta<typeof LockedEllipseSettings>;
export const Default = (args): React.ReactElement => {
return <LockedEllipseSettings {...args} />;
};
const defaultProps = {
...getDefaultFigureForType("ellipse"),
onChangeProps: () => {},
onMove: () => {},
onRemove: () => {},
};
type StoryComponentType = StoryObj<typeof LockedEllipseSettings>;
// Set the default values in the control panel.
Default.args = defaultProps;
export const Controlled: StoryComponentType = {
render: function Render() {
const [props, setProps] = React.useState(defaultProps);
const handlePropsUpdate = (newProps) => {
setProps({
...props,
...newProps,
});
};
return (
<LockedEllipseSettings
{...props}
onChangeProps={handlePropsUpdate}
/>
);
},
};
Controlled.parameters = {
chromatic: {
// Disabling because this is testing behavior, not visuals.
disableSnapshot: true,
},
};
// Fully expanded view of the locked ellipse settings to allow snapshot testing.
export const Expanded: StoryComponentType = {
render: function Render() {
const [expanded, setExpanded] = React.useState(true);
const [props, setProps] = React.useState(defaultProps);
const handlePropsUpdate = (newProps) => {
setProps({
...props,
...newProps,
});
};
return (
<LockedEllipseSettings
{...props}
expanded={expanded}
onToggle={setExpanded}
onChangeProps={handlePropsUpdate}
/>
);
},
};