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

Add storybook story for the TextAreaControl component #20472

Merged
merged 1 commit into from
Feb 27, 2020
Merged
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
45 changes: 45 additions & 0 deletions packages/components/src/textarea-control/stories/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* External dependencies
*/
import { boolean, number, text } from '@storybook/addon-knobs';

/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';

/**
* Internal dependencies
*/
import TextareaControl from '../';

export default {
title: 'Components/TextareaControl',
component: TextareaControl,
};

const TextareaControlWithState = ( props ) => {
const [ value, setValue ] = useState();

return (
<TextareaControl { ...props } value={ value } onChange={ setValue } />
);
};

export const _default = () => {
const label = text( 'Label', 'Label Text' );
const hideLabelFromVision = boolean( 'Hide Label From Vision', false );
const help = text( 'Help Text', 'Help text to explain the textarea.' );
const rows = number( 'Rows', 4 );
const className = text( 'Class Name', '' );

return (
<TextareaControlWithState
label={ label }
hideLabelFromVision={ hideLabelFromVision }
help={ help }
rows={ rows }
className={ className }
/>
);
};
30 changes: 30 additions & 0 deletions storybook/test/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7993,6 +7993,36 @@ Array [
]
`;

exports[`Storyshots Components/TextareaControl Default 1`] = `
<div
className="components-base-control"
>
<div
className="components-base-control__field"
>
<label
className="components-base-control__label"
htmlFor="inspector-textarea-control-0"
>
Label Text
</label>
<textarea
aria-describedby="inspector-textarea-control-0__help"
className="components-textarea-control__input"
id="inspector-textarea-control-0"
onChange={[Function]}
rows={4}
/>
</div>
<p
className="components-base-control__help"
id="inspector-textarea-control-0__help"
>
Help text to explain the textarea.
</p>
</div>
`;

exports[`Storyshots Components/Tip Default 1`] = `
<div
className="components-tip"
Expand Down