From ecf6ecfcdfa9287eaf253b8360767be7e25c3b4a Mon Sep 17 00:00:00 2001 From: im3dabasia Date: Wed, 15 Jan 2025 12:44:19 +0530 Subject: [PATCH] StoryBook: Add story for observe-typing --- .../observe-typing/stories/index.story.js | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 packages/block-editor/src/components/observe-typing/stories/index.story.js diff --git a/packages/block-editor/src/components/observe-typing/stories/index.story.js b/packages/block-editor/src/components/observe-typing/stories/index.story.js new file mode 100644 index 0000000000000..c1338d7b2c2f6 --- /dev/null +++ b/packages/block-editor/src/components/observe-typing/stories/index.story.js @@ -0,0 +1,59 @@ +/** + * WordPress dependencies + */ +import { useState } from '@wordpress/element'; + +/** + * Internal dependencies + */ +import ObserveTyping from '../index.js'; + +const meta = { + title: 'BlockEditor/ObserveTyping', + component: ObserveTyping, + parameters: { + docs: { + canvas: { sourceState: 'shown' }, + description: { + component: + 'A component that observes typing events and manages the typing flag in the editor.', + }, + }, + }, + argTypes: { + children: { + control: 'text', + description: 'Content wrapped by the ObserveTyping component.', + table: { + type: { summary: 'ReactNode' }, + }, + }, + }, +}; + +export default meta; + +export const Default = { + render: function Template( { children, ...args } ) { + const [ isTyping, setIsTyping ] = useState( false ); + + const onTypingStart = () => setIsTyping( true ); + const onTypingStop = () => setIsTyping( false ); + + return ( + +
+

{ isTyping ? 'Typing...' : 'Not typing' }

+ +
+
+ ); + }, + args: { + children: 'This is the area where typing will be observed.', + }, +};