From 08a129dd347cd3c6f5570fee7f631b158f2d5c95 Mon Sep 17 00:00:00 2001 From: Rishit Gupta <74411873+Rishit30G@users.noreply.github.com> Date: Tue, 14 Jan 2025 09:14:26 +0530 Subject: [PATCH] Storybook: Add Image Editor Component --- .../image-editor/stories/index.story.js | 142 ++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 packages/block-editor/src/components/image-editor/stories/index.story.js diff --git a/packages/block-editor/src/components/image-editor/stories/index.story.js b/packages/block-editor/src/components/image-editor/stories/index.story.js new file mode 100644 index 00000000000000..4c1c2c57131f9d --- /dev/null +++ b/packages/block-editor/src/components/image-editor/stories/index.story.js @@ -0,0 +1,142 @@ +/** + * Internal dependencies + */ +import ImageEditor from '..'; + +const meta = { + title: 'BlockEditor/ImageEditor', + component: ImageEditor, + parameters: { + docs: { + canvas: { sourceState: 'shown' }, + description: { + component: + 'The `ImageEditor` component is used to edit images in the block editor', + }, + }, + }, + argTypes: { + id: { + control: { + type: 'text', + }, + description: 'The id of the image being edited', + table: { + type: { + summary: 'string', + }, + }, + }, + url: { + control: { + type: 'text', + }, + description: 'The url of the image being edited', + table: { + type: { + summary: 'string', + }, + }, + }, + width: { + control: { + type: 'number', + }, + description: 'The width of the image being edited', + table: { + type: { + summary: 'number', + }, + }, + }, + height: { + control: { + type: 'number', + }, + description: 'The height of the image being edited', + table: { + type: { + summary: 'number', + }, + }, + }, + naturalHeight: { + control: { + type: 'number', + }, + description: 'The natural height of the image being edited', + table: { + type: { + summary: 'number', + }, + }, + }, + naturalWidth: { + control: { + type: 'number', + }, + description: 'The natural width of the image being edited', + table: { + type: { + summary: 'number', + }, + }, + }, + onSaveImage: { + control: { + type: 'function', + }, + description: 'Function to call when the image is saved', + table: { + type: { + summary: 'function', + }, + }, + }, + onFinishEditing: { + control: { + type: 'function', + }, + description: 'Function to call when editing is finished', + table: { + type: { + summary: 'function', + }, + }, + }, + borderProps: { + control: { + type: 'object', + }, + description: 'Border properties of the image being edited', + table: { + type: { + summary: 'object', + }, + }, + }, + }, +}; + +export default meta; + +export const Default = { + args: { + id: 'image-id', + url: 'https://cdn-icons-png.flaticon.com/512/174/174881.png', + width: 300, + height: 200, + naturalHeight: 600, + naturalWidth: 800, + onSaveImage: () => {}, + onFinishEditing: () => {}, + borderProps: { + borderRadius: 5, + borderWidth: 1, + borderColor: 'green', + }, + }, + render: function Template( args ) { + return ; + }, +};