From 53f37218cfab8052de6ea298e5e85e98a6131741 Mon Sep 17 00:00:00 2001 From: Rishit Gupta <74411873+Rishit30G@users.noreply.github.com> Date: Thu, 26 Dec 2024 09:41:56 +0530 Subject: [PATCH 1/2] Add Storybook for typewriter component --- .../typewriter/stories/index.story.js | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 packages/block-editor/src/components/typewriter/stories/index.story.js diff --git a/packages/block-editor/src/components/typewriter/stories/index.story.js b/packages/block-editor/src/components/typewriter/stories/index.story.js new file mode 100644 index 00000000000000..c164eaddaafdd2 --- /dev/null +++ b/packages/block-editor/src/components/typewriter/stories/index.story.js @@ -0,0 +1,43 @@ +/** + * Internal dependencies + */ +import TypewriterOrIEBypass from '../'; + +/** + * WordPress dependencies + */ +import { __ } from '@wordpress/i18n'; + +const meta = { + title: 'BlockEditor/Typewriter', + component: TypewriterOrIEBypass, + parameters: { + docs: { + description: { + component: + 'The `Typewriter` component ensures that the text selection keeps the same vertical distance from the viewport during keyboard events within this component. It provides a typewriter-like behavior for its children.', + }, + canvas: { sourceState: 'shown' }, + }, + }, + argTypes: { + children: { + control: 'text', + description: 'The children of the component.', + table: { + type: { summary: 'string' }, + }, + }, + }, +}; + +export default meta; + +export const Default = { + args: { + children: __( 'Typewriter Text' ), + }, + render( { children } ) { + return { children }; + }, +}; From 4561b708479ff5f8cd011fed2741e1e3f5f3ff03 Mon Sep 17 00:00:00 2001 From: Rishit Gupta <74411873+Rishit30G@users.noreply.github.com> Date: Wed, 1 Jan 2025 09:44:21 +0530 Subject: [PATCH 2/2] Add JS Doc --- .../src/components/typewriter/index.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/block-editor/src/components/typewriter/index.js b/packages/block-editor/src/components/typewriter/index.js index b5e230d314a7e2..a33ffeed9c419e 100644 --- a/packages/block-editor/src/components/typewriter/index.js +++ b/packages/block-editor/src/components/typewriter/index.js @@ -260,6 +260,25 @@ export function useTypewriter() { ); } +/** + * Typewriter component displays its children with a typewriter effect. + * + * @example + * ```jsx + * function Example(){ + * return ( + * + * Hello World + * + * ); + * } + * ``` + * + * @param {Object} props + * @param {JSX.Element | string} props.children The children to display with a typewriter effect. + * + * @return {JSX.Element} The rendered Typewriter component. + */ function Typewriter( { children } ) { return (