diff --git a/packages/components/src/base-control/stories/index.js b/packages/components/src/base-control/stories/index.js index 4055b7babe1e98..53b09aba82507d 100644 --- a/packages/components/src/base-control/stories/index.js +++ b/packages/components/src/base-control/stories/index.js @@ -1,38 +1,81 @@ -/** - * External dependencies - */ -import { boolean, text } from '@storybook/addon-knobs'; - /** * Internal dependencies */ import BaseControl from '../'; +import Button from '../../button'; +import { Spacer } from '../../spacer'; import TextareaControl from '../../textarea-control'; export default { title: 'Components/BaseControl', component: BaseControl, - parameters: { - knobs: { disable: false }, - }, + subcomponents: { BaseControl: BaseControl.VisualLabel }, }; -export const _default = () => { - const id = text( 'Id', 'textarea-1' ); - const label = text( 'Label', 'Label text' ); - const hideLabelFromVision = boolean( 'Hide label from vision', false ); - const help = text( 'Help', 'Help text' ); - const className = text( 'ClassName', '' ); - +const BaseControlWithTextarea = ( { id, ...props } ) => { return ( - + ); }; + +export const Default = BaseControlWithTextarea.bind( {} ); +Default.args = { + id: 'textarea-1', + label: '', + hideLabelFromVision: false, + help: '', +}; + +export const WithLabel = BaseControlWithTextarea.bind( {} ); +WithLabel.args = { + ...Default.args, + label: 'Label text', +}; + +export const WithHelpText = BaseControlWithTextarea.bind( {} ); +WithHelpText.args = { + ...WithLabel.args, + help: 'Help text adds more explanation.', +}; + +export const WithVisualLabel = ( { visualLabelChildren, ...props } ) => { + return ( + <> + +
+ + { visualLabelChildren } + +
+ +
+ +

+ BaseControl.VisualLabel is used to render a + purely visual label inside a BaseControl{ ' ' } + component. +

+

+ It should only be used in cases where the + children being rendered inside BaseControl are already + accessibly labeled, e.g., a button, but we want an + additional visual label for that section equivalent to the + labels BaseControl would otherwise use if the{ ' ' } + label prop was passed. +

+
+ + ); +}; +WithVisualLabel.args = { + ...Default.args, + help: 'This button is already accessibly labeled.', + visualLabelChildren: 'Author', +}; +WithVisualLabel.argTypes = { + visualLabelChildren: { + name: 'VisualLabel children', + }, +};