Commit a4e49e4a by Jack Westbrook Committed by GitHub

docs(badge): migrate story to use controls (#30180)

parent 9e4b055b
import React from 'react'; import React from 'react';
import { boolean, text, select } from '@storybook/addon-knobs'; import { Story } from '@storybook/react';
import { Badge, BadgeColor } from '@grafana/ui'; import { Badge, BadgeProps } from '@grafana/ui';
import { iconOptions } from '../../utils/storybook/knobs';
export default { export default {
title: 'Data Display/Badge', title: 'Data Display/Badge',
...@@ -8,28 +9,22 @@ export default { ...@@ -8,28 +9,22 @@ export default {
decorators: [], decorators: [],
parameters: { parameters: {
docs: {}, docs: {},
knobs: {
disabled: true,
},
},
argTypes: {
icon: { control: { type: 'select', options: iconOptions } },
color: { control: 'select' },
}, },
}; };
export const basic = () => { const Template: Story<BadgeProps> = args => <Badge {...args} />;
const badgeColor = select<BadgeColor>(
'Badge color', export const Basic = Template.bind({});
{
Red: 'red', Basic.args = {
Green: 'green', text: 'Badge label',
Blue: 'blue', color: 'blue',
Orange: 'orange', icon: 'rocket',
},
'blue'
);
const withIcon = boolean('With icon', true);
const tooltipText = text('Tooltip text', '');
return (
<Badge
text={'Badge label'}
color={badgeColor}
icon={withIcon ? 'rocket' : undefined}
tooltip={tooltipText.trim() === '' ? undefined : tooltipText}
/>
);
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment