Skip to content

Commit 3d12af9

Browse files
authored
Merge pull request #187 from reusejs/datepicker
Datepicker
2 parents c04f88b + 6a81a5b commit 3d12af9

8 files changed

Lines changed: 354 additions & 125 deletions

File tree

.changeset/breezy-garlics-taste.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@reusejs/react": minor
3+
---
4+
5+
Added Date Picker and coresponding Examples in Storybook
Lines changed: 89 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,101 @@
11
import React, { useState } from 'react';
22
import { ComponentStory, ComponentMeta } from '@storybook/react';
3-
import { SingleDatetimePicker, DateInputExample } from '@reusejs/react';
3+
import { DateInput } from '@reusejs/react';
44

55
export default {
6-
title: 'Molecules/Datetime/Single',
7-
component: SingleDatetimePicker,
6+
title: 'Molecules/Datetime',
7+
component: DateInput,
88
argTypes: {},
9-
} as ComponentMeta<typeof SingleDatetimePicker>;
9+
} as ComponentMeta<typeof DateInput>;
1010

11-
const Template: ComponentStory<typeof SingleDatetimePicker> = (args) => (
12-
<SingleDatetimePicker {...args} />
13-
);
11+
const Template: ComponentStory<typeof DateInput> = (args) => {
12+
const [dateVal, setDateVal] = useState(new Date());
1413

15-
const DateInputTemplate: ComponentStory<typeof DateInputExample> = (args) => (
16-
<DateInputExample />
17-
);
14+
return (
15+
<DateInput
16+
{...args}
17+
defaultValue={dateVal}
18+
onChangeCallback={(val: any) => {
19+
setDateVal(val);
20+
}}
21+
/>
22+
);
23+
};
1824

1925
export const Default = Template.bind({});
2026
Default.args = {};
2127

22-
let dateVal = '2022-09-10';
28+
export const FullScreen = Template.bind({});
29+
FullScreen.args = {
30+
screenRelative: true,
31+
inputWidthClass: 'w-11/12',
32+
};
2333

24-
export const DateInputEl = DateInputTemplate.bind({});
25-
DateInputEl.args = {};
34+
export const WithCustomErrorRenderer = Template.bind({});
35+
WithCustomErrorRenderer.args = {
36+
errorText: 'Error Detected!!!',
37+
errorTextRenderer: (text: string) => {
38+
return <div className='font-extrabold text-red-600'>{text}</div>;
39+
},
40+
};
41+
42+
export const HelperText = Template.bind({});
43+
HelperText.args = {
44+
helperText: 'Helper Text goes here',
45+
};
46+
47+
export const MinMaxDate = Template.bind({});
48+
MinMaxDate.args = {
49+
maxDate: new Date('2023-08-31'),
50+
minDate: new Date('2022-07-1'),
51+
};
52+
53+
export const RedColoured = Template.bind({});
54+
RedColoured.args = {
55+
dateInputStyleClasses: {
56+
inputStyles:
57+
'flex w-full items-center rounded bg-red-400 px-3 py-2 text-sm outline-none focus:border-blue-400 focus:ring-blue-400 dark:bg-gray-900',
58+
},
59+
calendarBaseClasses: {
60+
calenderWrapper:
61+
'z-50 block w-full overflow-auto rounded-lg bg-red-500 shadow-xl shadow-gray-200 hover:shadow-xl dark:bg-gray-900 dark:shadow-gray-800',
62+
wrapper: 'rounded-lg bg-red-400 dark:bg-gray-900',
63+
weekDaysWrapperStyles:
64+
'mt-3 grid grid-cols-7 bg-red-400 text-xs leading-6 text-gray-500 dark:bg-gray-900 dark:text-gray-300',
65+
dateButtonsSelectableStyles:
66+
'bg-red-400 hover:bg-blue-100 dark:bg-gray-900 dark:hover:bg-gray-800',
67+
dateButtonsUnSelectableStyles: 'bg-red-500 dark:bg-gray-800',
68+
todayButNotSelectedStyles: 'text-green-300 dark:text-amber-900',
69+
selectedTextStyles: 'text-white dark:text-gray-900',
70+
timeSectionSelectedAndTodayClasses: 'bg-red-900 dark:bg-blue-200',
71+
},
72+
};
73+
74+
const Template2: ComponentStory<typeof DateInput> = (args) => {
75+
const [startDateVal, setStartDateVal] = useState(new Date());
76+
const [endDateVal, setEndDateVal] = useState(new Date());
77+
78+
return (
79+
<div className='flex flex-col md:flex-row md:justify-evenly'>
80+
<DateInput
81+
{...args}
82+
label='Start Date'
83+
defaultValue={startDateVal}
84+
onChangeCallback={(val: any) => {
85+
setStartDateVal(val);
86+
}}
87+
/>
88+
<DateInput
89+
{...args}
90+
label='End Date'
91+
defaultValue={endDateVal}
92+
onChangeCallback={(val: any) => {
93+
setEndDateVal(val);
94+
}}
95+
/>
96+
</div>
97+
);
98+
};
99+
100+
export const TwoPickers = Template2.bind({});
101+
TwoPickers.args = {};

packages/react/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ export { default as TabsBase } from "./molecules/tabs/base";
115115
//Centeralized Slider
116116
export { default as CentralizedSliderBase } from "./molecules/centralizedSlider/base";
117117

118-
export { default as SingleDatetimePicker } from "./molecules/datetime/single";
119118
export { default as DateInput } from "./molecules/datetime/dateInput";
120-
export { default as DateInputExample } from "./molecules/datetime/dateInputExample";
121119
export { default as HorizontalList } from "./molecules/horizontalList/base";
122120
export { default as IconList } from "./molecules/IconList/base";
123121

0 commit comments

Comments
 (0)