Skip to content

Commit

Permalink
feat: adds time picker
Browse files Browse the repository at this point in the history
  • Loading branch information
AssisrMatheus committed Apr 11, 2023
1 parent e6e4178 commit 4a31721
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added examples for time picker on `DatePickerInput`

### Fixed

## [9.4.0] 2023-04-11
Expand Down
62 changes: 62 additions & 0 deletions src/components/DatePickerInput/DatePickerInput.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// also exported from '@storybook/react' if you can deal with breaking changes in 6.1
import { Meta, Story } from '@storybook/react/types-6-0';
import { now, getLocalTimeZone } from '@internationalized/date';
import React from 'react';
import classnames from 'classnames';
import { DatePickerInput, DatePickerProps } from '.';
Expand Down Expand Up @@ -81,3 +82,64 @@ export const WithError = Template.bind({});
WithError.args = {
error: 'Input is required'
};

export const Time = Template.bind({});
Time.args = {
granularity: 'minute'
};

export const Time24Hours = Template.bind({});
Time24Hours.args = {
granularity: 'minute',
hourCycle: 24
};

/**
* A story that displays a DatePickerInput example
*
* @param props the story props
* @param props.color the color property set on controls
* @param props.className The input className
*/
const LocalTimezoneTemplate: Story<DatePickerProps & { color?: string }> = ({ color, className, ...props }) => {
return (
<DatePickerInput
{...props}
className={classnames(
{
[puiColorClassnameMap[color || 'transparent']]: color !== 'pui-primary'
},
className
)}
granularity="minute"
placeholderValue={now(getLocalTimeZone())}
/>
);
};

export const LocalTimezone = LocalTimezoneTemplate.bind({});

/**
* A story that displays a DatePickerInput example
*
* @param props the story props
* @param props.color the color property set on controls
* @param props.className The input className
*/
const OtherTimezoneTemplate: Story<DatePickerProps & { color?: string }> = ({ color, className, ...props }) => {
return (
<DatePickerInput
{...props}
className={classnames(
{
[puiColorClassnameMap[color || 'transparent']]: color !== 'pui-primary'
},
className
)}
granularity="minute"
placeholderValue={now('Europe/Paris')}
/>
);
};

export const OtherTimezone = OtherTimezoneTemplate.bind({});

0 comments on commit 4a31721

Please sign in to comment.