Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Add Textarea entry to Storybook (#11635)
Browse files Browse the repository at this point in the history
  • Loading branch information
opr authored Nov 13, 2023
1 parent 0101524 commit 8fc475a
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/components/textarea/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import classnames from 'classnames';
*/
import './style.scss';

interface TextareaProps {
export interface TextareaProps {
className?: string;
disabled: boolean;
onTextChange: ( newText: string ) => void;
Expand Down
77 changes: 77 additions & 0 deletions packages/components/textarea/stories/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* External dependencies
*/
import type { Meta, StoryFn } from '@storybook/react';
import { useArgs } from '@storybook/preview-api';

/**
* Internal dependencies
*/
import Textarea, { type TextareaProps } from '..';
import '../style.scss';

export default {
title: 'Checkout Components/Textarea',
component: Textarea,
argTypes: {
className: {
control: 'text',
table: {
type: {
summary: 'string',
},
},
description: 'Additional class names to add to the textarea.',
},
value: {
control: 'text',
table: {
type: {
summary: 'string',
},
},
description: 'The value in the textarea.',
},
disabled: {
control: 'boolean',
table: {
type: {
summary: 'boolean',
},
},
description: 'Whether the textarea is disabled.',
},
placeholder: {
control: 'text',
table: {
type: {
summary: 'string',
},
},
description:
'The placeholder text to show when no value has been entered.',
},
},
} as Meta< TextareaProps >;

const Template: StoryFn< TextareaProps > = ( args ) => {
const [ { value }, updateArgs ] = useArgs();
return (
<Textarea
{ ...args }
value={ value }
onTextChange={ ( newValue: string ) =>
updateArgs( { value: newValue } )
}
/>
);
};

export const Default = Template.bind( {} );

Default.args = {
className: '',
disabled: false,
placeholder: 'Enter some text here',
value: '',
};

0 comments on commit 8fc475a

Please sign in to comment.