Commit a4e49e4a by Jack Westbrook Committed by GitHub

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

parent 9e4b055b
import React from 'react';
import { boolean, text, select } from '@storybook/addon-knobs';
import { Badge, BadgeColor } from '@grafana/ui';
import { Story } from '@storybook/react';
import { Badge, BadgeProps } from '@grafana/ui';
import { iconOptions } from '../../utils/storybook/knobs';
export default {
title: 'Data Display/Badge',
......@@ -8,28 +9,22 @@ export default {
decorators: [],
parameters: {
docs: {},
knobs: {
disabled: true,
},
},
argTypes: {
icon: { control: { type: 'select', options: iconOptions } },
color: { control: 'select' },
},
};
export const basic = () => {
const badgeColor = select<BadgeColor>(
'Badge color',
{
Red: 'red',
Green: 'green',
Blue: 'blue',
Orange: 'orange',
},
'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}
/>
);
const Template: Story<BadgeProps> = args => <Badge {...args} />;
export const Basic = Template.bind({});
Basic.args = {
text: 'Badge label',
color: 'blue',
icon: 'rocket',
};
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