mirror of
https://github.com/grafana/grafana.git
synced 2024-12-28 01:41:24 -06:00
NamedColorsPalette: updates story from knobs to controls (#31443)
This commit is contained in:
parent
59d11ce84f
commit
f3a7cb4709
@ -1,8 +1,9 @@
|
||||
import React from 'react';
|
||||
import { NamedColorsPalette } from './NamedColorsPalette';
|
||||
import { select } from '@storybook/addon-knobs';
|
||||
import { NamedColorsPalette, NamedColorsPaletteProps } from './NamedColorsPalette';
|
||||
import { Story } from '@storybook/react';
|
||||
import { withCenteredStory } from '../../utils/storybook/withCenteredStory';
|
||||
import { renderComponentWithTheme } from '../../utils/storybook/withTheme';
|
||||
import { NOOP_CONTROL } from '../../utils/storybook/noopControl';
|
||||
import { UseState } from '../../utils/storybook/UseState';
|
||||
import mdx from './ColorPicker.mdx';
|
||||
|
||||
@ -14,20 +15,22 @@ export default {
|
||||
docs: {
|
||||
page: mdx,
|
||||
},
|
||||
knobs: {
|
||||
disable: true,
|
||||
},
|
||||
},
|
||||
argTypes: {
|
||||
selectedColor: { control: { type: 'select', options: ['green', 'red', 'light-blue', 'yellow'] } },
|
||||
theme: NOOP_CONTROL,
|
||||
color: NOOP_CONTROL,
|
||||
},
|
||||
};
|
||||
|
||||
export const namedColors = () => {
|
||||
const selectedColor = select(
|
||||
'Selected color',
|
||||
{
|
||||
Green: 'green',
|
||||
Red: 'red',
|
||||
'Light blue': 'light-blue',
|
||||
},
|
||||
'red'
|
||||
);
|
||||
interface StoryProps extends Partial<NamedColorsPaletteProps> {
|
||||
selectedColor: string;
|
||||
}
|
||||
|
||||
export const NamedColors: Story<StoryProps> = ({ selectedColor }) => {
|
||||
return (
|
||||
<UseState initialState={selectedColor}>
|
||||
{(selectedColor, updateSelectedColor) => {
|
||||
@ -39,3 +42,6 @@ export const namedColors = () => {
|
||||
</UseState>
|
||||
);
|
||||
};
|
||||
NamedColors.args = {
|
||||
selectedColor: 'red',
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user