mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 02:10:45 -06:00
Add controls for Date Picker story (#54806)
Signed-off-by: gefgu <gefgu@hotmail.com> Signed-off-by: gefgu <gefgu@hotmail.com>
This commit is contained in:
parent
8e577ce9fa
commit
c56907b879
@ -4,28 +4,46 @@ import React, { useState } from 'react';
|
||||
import { withCenteredStory } from '../../../utils/storybook/withCenteredStory';
|
||||
import { Button } from '../../Button/Button';
|
||||
|
||||
import { DatePicker } from './DatePicker';
|
||||
import { DatePicker, DatePickerProps } from './DatePicker';
|
||||
import mdx from './DatePicker.mdx';
|
||||
|
||||
const meta: ComponentMeta<typeof DatePicker> = {
|
||||
title: 'Pickers and Editors/TimePickers/Pickers And Editors/DatePicker',
|
||||
component: DatePicker,
|
||||
decorators: [withCenteredStory],
|
||||
argTypes: {
|
||||
minDate: { control: 'date' },
|
||||
},
|
||||
parameters: {
|
||||
docs: {
|
||||
page: mdx,
|
||||
},
|
||||
controls: {
|
||||
exclude: ['onChange', 'onClose', 'value', 'isOpen'],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const Basic = () => {
|
||||
export const Basic = (args: DatePickerProps) => {
|
||||
const [date, setDate] = useState<Date>(new Date());
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
if (args?.minDate !== undefined) {
|
||||
args.minDate = new Date(args.minDate);
|
||||
}
|
||||
|
||||
args = {
|
||||
...args,
|
||||
isOpen: open,
|
||||
value: date,
|
||||
onChange: (newDate) => setDate(newDate),
|
||||
onClose: () => setOpen(false),
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button onClick={() => setOpen(true)}>Show Calendar</Button>
|
||||
<DatePicker isOpen={open} value={date} onChange={(newDate) => setDate(newDate)} onClose={() => setOpen(false)} />
|
||||
<DatePicker {...args} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user