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

Storybook: Add story for Typewriter component #68305

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/block-editor/src/components/typewriter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,25 @@ export function useTypewriter() {
);
}

/**
* Typewriter component displays its children with a typewriter effect.
*
* @example
* ```jsx
* function Example(){
* return (
* <Typewriter>
* Hello World
* </Typewriter>
* );
* }
* ```
*
* @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 (
<div ref={ useTypewriter() } className="block-editor__typewriter">
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <TypewriterOrIEBypass>{ children }</TypewriterOrIEBypass>;
},
};
Loading