Release 0.0.2 #17

Open
ksv741 wants to merge 33 commits from krylov into development
4 changed files with 16 additions and 10 deletions
Showing only changes of commit 46e1cd5d4a - Show all commits

View File

@ -9,12 +9,7 @@ const CalendarPage = () => (
</h1>
<div className={classes.calendarWrapper}>
<CalendarWidget
locale="en"
maxDate={new Date(2027, 2, 15)}
minDate={new Date(1996, 9, 15)}
value={new Date(2023, 9, 15)}
/>
<CalendarWidget />
</div>
</div>
);

View File

@ -11,6 +11,8 @@ export type CalendarWidgetProps = {
minDate?: Date;
value?: Date;
locale?: 'en' | 'ru';
highlightToday?: boolean;
highlightValue?: boolean;
};
const CalendarWidget: FC<CalendarWidgetProps> = (props) => (
<CalendarWidgetProvider {...props}>

View File

@ -21,6 +21,8 @@ export const CalendarWidgetProvider: FC<CalendarWidgetProviderProps> = (props) =
minDate = new Date(1990, 0, 1),
locale = 'ru',
value = new Date(),
highlightToday = false,
highlightValue = false,
...restProps
} = props;
@ -35,8 +37,10 @@ export const CalendarWidgetProvider: FC<CalendarWidgetProviderProps> = (props) =
maxDate,
locale,
value,
highlightToday,
highlightValue,
...restProps,
}), [maxDate, minDate, targetDate, locale, restProps, value]);
}), [highlightValue, targetDate, minDate, maxDate, locale, value, highlightToday, restProps]);
return (
<CalendarWidgetContext.Provider value={contextValue}>

View File

@ -16,7 +16,12 @@ const DateCell: FC<DateCellProps> = (props) => {
} = props;
const format = 'en-En';
const { targetMonthIndex, value } = useContext(CalendarWidgetContext);
const {
targetMonthIndex,
value,
highlightToday,
highlightValue,
} = useContext(CalendarWidgetContext);
const todayDate = new Date();
const dataDate = new Intl.DateTimeFormat(format).format(date);
@ -34,9 +39,9 @@ const DateCell: FC<DateCellProps> = (props) => {
<span
className={classnames(
{
[classes.today as string]: dataDate === dataToday,
[classes.today as string]: highlightToday && dataDate === dataToday,
[classes.outMothRange as string]: isOutMonthRange,
[classes.valueDate as string]: dataDate === dataValue,
[classes.valueDate as string]: highlightValue && dataDate === dataValue,
},
)}
>