mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Slider: updates story from knobs to control (#33983)
This commit is contained in:
parent
4b0b69292e
commit
0992cedbf4
@ -1,30 +1,47 @@
|
||||
import React from 'react';
|
||||
import { Slider } from '@grafana/ui';
|
||||
import { select, number, boolean } from '@storybook/addon-knobs';
|
||||
import { SliderProps } from './types';
|
||||
import { Story, Meta } from '@storybook/react';
|
||||
|
||||
export default {
|
||||
title: 'Forms/Slider',
|
||||
component: Slider,
|
||||
};
|
||||
parameters: {
|
||||
controls: {
|
||||
exclude: ['step', 'formatTooltipResult', 'onChange', 'onAfterChange', 'value', 'tooltipAlwaysVisible'],
|
||||
},
|
||||
knobs: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
argTypes: {
|
||||
isStep: { name: 'Step' },
|
||||
orientation: { control: { type: 'select', options: ['horizontal', 'vertical'] } },
|
||||
},
|
||||
} as Meta;
|
||||
|
||||
const getKnobs = () => {
|
||||
return {
|
||||
min: number('min', 0),
|
||||
max: number('max', 100),
|
||||
step: boolean('enable step', false),
|
||||
orientation: select('orientation', ['horizontal', 'vertical'], 'horizontal'),
|
||||
reverse: boolean('reverse', false),
|
||||
};
|
||||
};
|
||||
interface StoryProps extends Partial<SliderProps> {
|
||||
isStep: boolean;
|
||||
}
|
||||
|
||||
const SliderWrapper = () => {
|
||||
const { min, max, orientation, reverse, step } = getKnobs();
|
||||
const stepValue = step ? 10 : undefined;
|
||||
export const Basic: Story<StoryProps> = (args) => {
|
||||
return (
|
||||
<div style={{ width: '300px', height: '300px' }}>
|
||||
<Slider min={min} max={max} step={stepValue} orientation={orientation} value={10} reverse={reverse} />
|
||||
<Slider
|
||||
step={args.isStep ? 10 : undefined}
|
||||
value={args.value}
|
||||
min={args.min as number}
|
||||
max={args.max as number}
|
||||
{...args}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const basic = () => <SliderWrapper />;
|
||||
Basic.args = {
|
||||
min: 0,
|
||||
max: 100,
|
||||
value: 10,
|
||||
isStep: false,
|
||||
orientation: 'horizontal',
|
||||
reverse: false,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user