From c9c5e55c153923c3d693afdb7ce61af7fbed13ff Mon Sep 17 00:00:00 2001 From: Uchechukwu Obasi Date: Wed, 24 Mar 2021 18:12:54 +0100 Subject: [PATCH] Graph: updates story from knobs to controls (#32264) * Graph: updates story from knobs to controls * added type to story --- .../src/components/Graph/Graph.story.tsx | 96 +++++++++---------- 1 file changed, 44 insertions(+), 52 deletions(-) diff --git a/packages/grafana-ui/src/components/Graph/Graph.story.tsx b/packages/grafana-ui/src/components/Graph/Graph.story.tsx index f16412265b8..b953a2f21dd 100644 --- a/packages/grafana-ui/src/components/Graph/Graph.story.tsx +++ b/packages/grafana-ui/src/components/Graph/Graph.story.tsx @@ -2,29 +2,12 @@ import React from 'react'; import { Graph } from '@grafana/ui'; import Chart from '../Chart'; import { dateTime, ArrayVector, FieldType, GraphSeriesXY, FieldColorModeId } from '@grafana/data'; -import { select } from '@storybook/addon-knobs'; +import { Story } from '@storybook/react'; import { withCenteredStory } from '../../utils/storybook/withCenteredStory'; -import { TooltipContentProps } from '../Chart/Tooltip'; +import { TooltipContentProps, TooltipMode } from '../Chart/Tooltip'; import { JSONFormatter } from '../JSONFormatter/JSONFormatter'; - -export default { - title: 'Visualizations/Graph', - component: Graph, - decorators: [withCenteredStory], -}; - -const getKnobs = () => { - return { - tooltipMode: select( - 'Tooltip mode', - { - multi: 'multi', - single: 'single', - }, - 'single' - ), - }; -}; +import { NOOP_CONTROL } from '../../utils/storybook/noopControl'; +import { GraphProps } from './Graph'; const series: GraphSeriesXY[] = [ { @@ -95,23 +78,46 @@ const series: GraphSeriesXY[] = [ }, ]; -export const withTooltip = () => { - const { tooltipMode } = getKnobs(); - return ( - + }, + }, + timeZone: 'browser', + tooltipMode: 'single', + }, + argTypes: { + tooltipMode: { control: { type: 'radio', options: ['multi', 'single'] } }, + timeZone: { control: { type: 'radio', options: ['browser', 'utc'] } }, + width: { control: { type: 'range', min: 200, max: 800 } }, + height: { control: { type: 'range', min: 200, max: 800 } }, + lineWidth: { control: { type: 'range', min: 1, max: 10 } }, + className: NOOP_CONTROL, + series: NOOP_CONTROL, + timeRange: NOOP_CONTROL, + ariaLabel: NOOP_CONTROL, + }, +}; + +export const WithTooltip: Story = ({ tooltipMode, ...args }) => { + return ( + ); @@ -126,23 +132,9 @@ const CustomGraphTooltip = ({ activeDimensions }: TooltipContentProps) => { ); }; -export const withCustomTooltip = () => { - const { tooltipMode } = getKnobs(); +export const WithCustomTooltip: Story = ({ tooltipMode, ...args }) => { return ( - + );