mirror of
https://github.com/grafana/grafana.git
synced 2024-11-22 08:56:43 -06:00
docs(badge): migrate story to use controls (#30180)
This commit is contained in:
parent
9e4b055b91
commit
a4e49e4a9b
@ -1,6 +1,7 @@
|
||||
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',
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user