FeatInsetInputProps.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import React from 'react';
  2. import { DatePicker, Space, Button } from '../../../index';
  3. import { DatePickerProps } from '../../index';
  4. /**
  5. * Test with Chromatic
  6. */
  7. export default function App() {
  8. const spacing = [200, 400];
  9. const [density, setDensity] = React.useState(false);
  10. // const defaultValue = '2022-01-15';
  11. // const defaultRangeValue = ['2022-12-10', '2022-01-15'];
  12. const props: DatePickerProps = {
  13. defaultOpen: true,
  14. motion: false,
  15. density: density ? 'compact' : 'default',
  16. defaultPickerValue: '2022-01-15',
  17. insetInput: {
  18. placeholder: {
  19. dateStart: '开始日期',
  20. dateEnd: '开始日期',
  21. timeStart: '开始时间',
  22. timeEnd: '结束时间',
  23. },
  24. }
  25. };
  26. const handleToggleDensity = () => {
  27. setDensity(!density);
  28. };
  29. return (
  30. <div style={{ height: '200vh' }}>
  31. <div style={{ marginBottom: 12 }}>
  32. <Space>
  33. <Button onClick={handleToggleDensity}>
  34. {`小尺寸=${density}`}
  35. </Button>
  36. </Space>
  37. </div>
  38. <Space wrap spacing={spacing}>
  39. <DatePicker placeholder='选择单个日期' {...props} />
  40. <DatePicker placeholder='选择月' {...props} type='month' />
  41. <DatePicker placeholder='选择日期时间' {...props} type='dateTime' />
  42. <DatePicker placeholder='选择日期范围' {...props} type='dateRange' />
  43. <DatePicker placeholder='选择日期时间范围' {...props} type='dateTimeRange' />
  44. </Space>
  45. </div>
  46. );
  47. }
  48. App.parameters = {
  49. chromatic: {
  50. disableSnapshot: false,
  51. delay: 3000,
  52. viewports: [1800]
  53. },
  54. };
  55. App.storyName = 'insetInputProps';