mirror of https://github.com/grafana/grafana
ColorPicker: Improvements to story organization (#86539)
parent
9878dfb7d9
commit
aa326423ed
@ -1,36 +0,0 @@ |
||||
import { Meta, Story } from '@storybook/react'; |
||||
import React, { useState } from 'react'; |
||||
|
||||
import mdx from './ColorPicker.mdx'; |
||||
import { NamedColorsPalette, NamedColorsPaletteProps } from './NamedColorsPalette'; |
||||
|
||||
const meta: Meta = { |
||||
title: 'Pickers and Editors/ColorPicker/Palettes/NamedColorsPalette', |
||||
component: NamedColorsPalette, |
||||
parameters: { |
||||
docs: { |
||||
page: mdx, |
||||
}, |
||||
controls: { |
||||
exclude: ['theme', 'color'], |
||||
}, |
||||
}, |
||||
argTypes: { |
||||
selectedColor: { control: { type: 'select', options: ['green', 'red', 'light-blue', 'yellow'] } }, |
||||
}, |
||||
}; |
||||
|
||||
interface StoryProps extends Partial<NamedColorsPaletteProps> { |
||||
selectedColor: string; |
||||
} |
||||
|
||||
export const NamedColors: Story<StoryProps> = ({ selectedColor }) => { |
||||
const [color, setColor] = useState('green'); |
||||
return <NamedColorsPalette color={color} onChange={setColor} />; |
||||
}; |
||||
|
||||
NamedColors.args = { |
||||
color: 'green', |
||||
}; |
||||
|
||||
export default meta; |
@ -0,0 +1,43 @@ |
||||
import { action } from '@storybook/addon-actions'; |
||||
import { useArgs } from '@storybook/client-api'; |
||||
import { Meta, StoryFn } from '@storybook/react'; |
||||
import React, { useState } from 'react'; |
||||
|
||||
import mdx from './ColorPicker.mdx'; |
||||
import { NamedColorsPalette } from './NamedColorsPalette'; |
||||
import SpectrumPalette from './SpectrumPalette'; |
||||
|
||||
const meta: Meta = { |
||||
title: 'Pickers and Editors/ColorPicker/Palettes', |
||||
parameters: { |
||||
docs: { |
||||
page: mdx, |
||||
}, |
||||
controls: { |
||||
exclude: ['theme', 'color'], |
||||
}, |
||||
}, |
||||
args: { |
||||
color: 'green', |
||||
}, |
||||
}; |
||||
|
||||
export const NamedColors: StoryFn<typeof NamedColorsPalette> = ({ color }) => { |
||||
const [colorVal, setColor] = useState(color); |
||||
return <NamedColorsPalette color={colorVal} onChange={setColor} />; |
||||
}; |
||||
|
||||
export const Spectrum: StoryFn<typeof SpectrumPalette> = ({ color }) => { |
||||
const [, updateArgs] = useArgs(); |
||||
return ( |
||||
<SpectrumPalette |
||||
color={color} |
||||
onChange={(color: string) => { |
||||
action('Color changed')(color); |
||||
updateArgs({ color }); |
||||
}} |
||||
/> |
||||
); |
||||
}; |
||||
|
||||
export default meta; |
@ -1,37 +0,0 @@ |
||||
import { action } from '@storybook/addon-actions'; |
||||
import { useArgs } from '@storybook/client-api'; |
||||
import { Meta, StoryFn } from '@storybook/react'; |
||||
|
||||
import { renderComponentWithTheme } from '../../utils/storybook/withTheme'; |
||||
|
||||
import mdx from './ColorPicker.mdx'; |
||||
import SpectrumPalette from './SpectrumPalette'; |
||||
|
||||
const meta: Meta<typeof SpectrumPalette> = { |
||||
title: 'Pickers and Editors/ColorPicker/Palettes/SpectrumPalette', |
||||
component: SpectrumPalette, |
||||
parameters: { |
||||
docs: { |
||||
page: mdx, |
||||
}, |
||||
controls: { |
||||
exclude: ['onChange'], |
||||
}, |
||||
}, |
||||
args: { |
||||
color: 'red', |
||||
}, |
||||
}; |
||||
|
||||
export const Simple: StoryFn<typeof SpectrumPalette> = ({ color }) => { |
||||
const [, updateArgs] = useArgs(); |
||||
return renderComponentWithTheme(SpectrumPalette, { |
||||
color, |
||||
onChange: (color: string) => { |
||||
action('Color changed')(color); |
||||
updateArgs({ color }); |
||||
}, |
||||
}); |
||||
}; |
||||
|
||||
export default meta; |
Loading…
Reference in new issue