* ship component stories for storybook

* Refactor RemovableChip for Storybook

* Implement lucio feedback changes

* RemovableChip is part of the Chip story
This commit is contained in:
Alex Florisca 2021-12-08 12:17:49 +00:00 committed by GitHub
parent 30abe6f3bc
commit 311a531826
4 changed files with 74 additions and 45 deletions

View File

@ -10,7 +10,7 @@ import { Icon, noAlt } from '@woocommerce/icons';
*/
import Chip, { ChipProps } from './chip';
interface RemovableChipProps extends ChipProps {
export interface RemovableChipProps extends ChipProps {
/**
* Aria label content.
*/
@ -47,7 +47,7 @@ interface RemovableChipProps extends ChipProps {
* @param {string} props.screenReaderText The screen reader text for the chip.
* @param {Object} props.props Rest of props passed into component.
*/
const RemovableChip: React.FC< RemovableChipProps > = ( {
export const RemovableChip = ( {
ariaLabel = '',
className = '',
disabled = false,
@ -56,7 +56,7 @@ const RemovableChip: React.FC< RemovableChipProps > = ( {
text,
screenReaderText = '',
...props
} ) => {
}: RemovableChipProps ): JSX.Element => {
const RemoveElement = removeOnAnyClick ? 'span' : 'button';
if ( ! ariaLabel ) {

View File

@ -0,0 +1,38 @@
/**
* External dependencies
*/
import { Story, Meta } from '@storybook/react';
/**
* Internal dependencies
*/
import Chip, { ChipProps } from '../chip';
const availableElements = [ 'li', 'div', 'span' ];
const availableRadii = [ 'none', 'small', 'medium', 'large' ];
export default {
title: 'WooCommerce Blocks/@base-components/Chip',
component: Chip,
argTypes: {
element: {
control: 'radio',
options: availableElements,
},
className: {
control: 'text',
},
radius: {
control: 'radio',
options: availableRadii,
},
},
} as Meta< ChipProps >;
const Template: Story< ChipProps > = ( args ) => <Chip { ...args } />;
export const Default = Template.bind( {} );
Default.args = {
element: 'li',
text: 'Take me to the casino!',
screenReaderText: "I'm a chip, me",
};

View File

@ -1,42 +0,0 @@
/**
* External dependencies
*/
import { text, select, boolean } from '@storybook/addon-knobs';
/**
* Internal dependencies
*/
import * as components from '../';
export default {
title: 'WooCommerce Blocks/@base-components/Chip',
component: Chip,
};
const radii = [ 'none', 'small', 'medium', 'large' ];
export const Chip = () => (
<components.Chip
text={ text( 'Text', 'example' ) }
radius={ select( 'Radius', radii ) }
screenReaderText={ text(
'Screen reader text',
'Example screen reader text'
) }
element={ select( 'Element', [ 'li', 'div', 'span' ], 'li' ) }
/>
);
export const RemovableChip = () => (
<components.RemovableChip
text={ text( 'Text', 'example' ) }
radius={ select( 'Radius', radii ) }
screenReaderText={ text(
'Screen reader text',
'Example screen reader text'
) }
disabled={ boolean( 'Disabled', false ) }
removeOnAnyClick={ boolean( 'Remove on any click', false ) }
element={ select( 'Element', [ 'li', 'div', 'span' ], 'li' ) }
/>
);

View File

@ -0,0 +1,33 @@
/**
* External dependencies
*/
import { Story, Meta } from '@storybook/react';
/**
* Internal dependencies
*/
import { RemovableChip, RemovableChipProps } from '../removable-chip';
const availableElements = [ 'li', 'div', 'span' ];
export default {
title: 'WooCommerce Blocks/@base-components/Chip/RemovableChip',
component: RemovableChip,
argTypes: {
element: {
control: 'radio',
options: availableElements,
},
},
} as Meta< RemovableChipProps >;
const Template: Story< RemovableChipProps > = ( args ) => (
<RemovableChip { ...args } />
);
export const Default = Template.bind( {} );
Default.args = {
element: 'li',
text: 'Take me to the casino',
screenReaderText: "I'm a removable chip, me",
};