diff --git a/packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.story.tsx b/packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.story.tsx index 8513d8403eb..91509ca263c 100644 --- a/packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.story.tsx +++ b/packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.story.tsx @@ -1,8 +1,8 @@ import { action } from '@storybook/addon-actions'; -import { ComponentMeta } from '@storybook/react'; +import { useArgs } from '@storybook/client-api'; +import { ComponentMeta, ComponentStory } from '@storybook/react'; import React from 'react'; -import { UseState } from '../../../utils/storybook/UseState'; import { withCenteredStory } from '../../../utils/storybook/withCenteredStory'; import { RelativeTimeRangePicker } from './RelativeTimeRangePicker'; @@ -12,30 +12,28 @@ const meta: ComponentMeta = { component: RelativeTimeRangePicker, decorators: [withCenteredStory], parameters: { - docs: {}, + controls: { + exclude: ['onChange'], + }, + }, + args: { + timeRange: { + from: 900, + to: 0, + }, }, }; -export const basic = () => { +export const Basic: ComponentStory = (args) => { + const [, updateArgs] = useArgs(); return ( - { + action('onChange')(value); + updateArgs({ timeRange: value }); }} - > - {(value, updateValue) => { - return ( - { - action('on selected')(newValue); - updateValue(newValue); - }} - timeRange={value} - /> - ); - }} - + /> ); }; diff --git a/packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.tsx b/packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.tsx index 13aa85ffbed..37bfb64fbcf 100644 --- a/packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.tsx +++ b/packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.tsx @@ -1,5 +1,5 @@ import { css, cx } from '@emotion/css'; -import React, { FormEvent, ReactElement, useCallback, useState } from 'react'; +import React, { FormEvent, useCallback, useState } from 'react'; import { RelativeTimeRange, GrafanaTheme2, TimeOption } from '@grafana/data'; @@ -41,7 +41,7 @@ const validOptions = quickOptions.filter((o) => isRelativeFormat(o.from)); /** * @internal */ -export function RelativeTimeRangePicker(props: RelativeTimeRangePickerProps): ReactElement | null { +export function RelativeTimeRangePicker(props: RelativeTimeRangePickerProps) { const { timeRange, onChange } = props; const [isOpen, setIsOpen] = useState(false); const onClose = useCallback(() => setIsOpen(false), []);