@storybook/addons#ArgType TypeScript Examples

The following examples show how to use @storybook/addons#ArgType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Icon.stories.ts    From wvui with GNU General Public License v2.0 6 votes vote down vote up
// Utilities

/**
 * ArgType options for an icon dropdown.
 *
 * @example
 *     argTypes: {
 *         icon: {
 *             ...makeIconArgType(),
 *             defaultValue: 'wvuiIconAdd'
 *         }
 *     }
 * @return Object that can be spread into an ArgType object
 */
export function makeIconArgType() : ArgType {
	return {
		control: {
			type: 'select'
		},
		options: Object.keys( icons )
		// TODO use mapping here once https://github.com/storybookjs/storybook/issues/14420 is fixed
	};
}
Example #2
Source File: Icon.stories.ts    From wvui with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Like makeIconArgType(), but with a '(none)' option.
 *
 * @return Object that can be spread into an ArgType object
 */
export function makeOptionalIconArgType() : ArgType {
	return {
		control: {
			type: 'select'
		},
		options: [ '(none)' ].concat( Object.keys( icons ) ),
		defaultValue: '(none)'
		// TODO use mapping here once https://github.com/storybookjs/storybook/issues/14420 is fixed
	};
}