Release 0.0.2 #17
@ -9,12 +9,7 @@ const CalendarPage = () => (
|
|||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<div className={classes.calendarWrapper}>
|
<div className={classes.calendarWrapper}>
|
||||||
<CalendarWidget
|
<CalendarWidget />
|
||||||
locale="en"
|
|
||||||
maxDate={new Date(2027, 2, 15)}
|
|
||||||
minDate={new Date(1996, 9, 15)}
|
|
||||||
value={new Date(2023, 9, 15)}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -11,6 +11,8 @@ export type CalendarWidgetProps = {
|
|||||||
minDate?: Date;
|
minDate?: Date;
|
||||||
value?: Date;
|
value?: Date;
|
||||||
locale?: 'en' | 'ru';
|
locale?: 'en' | 'ru';
|
||||||
|
highlightToday?: boolean;
|
||||||
|
highlightValue?: boolean;
|
||||||
};
|
};
|
||||||
const CalendarWidget: FC<CalendarWidgetProps> = (props) => (
|
const CalendarWidget: FC<CalendarWidgetProps> = (props) => (
|
||||||
<CalendarWidgetProvider {...props}>
|
<CalendarWidgetProvider {...props}>
|
||||||
|
|||||||
@ -21,6 +21,8 @@ export const CalendarWidgetProvider: FC<CalendarWidgetProviderProps> = (props) =
|
|||||||
minDate = new Date(1990, 0, 1),
|
minDate = new Date(1990, 0, 1),
|
||||||
locale = 'ru',
|
locale = 'ru',
|
||||||
value = new Date(),
|
value = new Date(),
|
||||||
|
highlightToday = false,
|
||||||
|
highlightValue = false,
|
||||||
...restProps
|
...restProps
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
@ -35,8 +37,10 @@ export const CalendarWidgetProvider: FC<CalendarWidgetProviderProps> = (props) =
|
|||||||
maxDate,
|
maxDate,
|
||||||
locale,
|
locale,
|
||||||
value,
|
value,
|
||||||
|
highlightToday,
|
||||||
|
highlightValue,
|
||||||
...restProps,
|
...restProps,
|
||||||
}), [maxDate, minDate, targetDate, locale, restProps, value]);
|
}), [highlightValue, targetDate, minDate, maxDate, locale, value, highlightToday, restProps]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CalendarWidgetContext.Provider value={contextValue}>
|
<CalendarWidgetContext.Provider value={contextValue}>
|
||||||
|
|||||||
@ -16,7 +16,12 @@ const DateCell: FC<DateCellProps> = (props) => {
|
|||||||
} = props;
|
} = props;
|
||||||
const format = 'en-En';
|
const format = 'en-En';
|
||||||
|
|
||||||
const { targetMonthIndex, value } = useContext(CalendarWidgetContext);
|
const {
|
||||||
|
targetMonthIndex,
|
||||||
|
value,
|
||||||
|
highlightToday,
|
||||||
|
highlightValue,
|
||||||
|
} = useContext(CalendarWidgetContext);
|
||||||
|
|
||||||
const todayDate = new Date();
|
const todayDate = new Date();
|
||||||
const dataDate = new Intl.DateTimeFormat(format).format(date);
|
const dataDate = new Intl.DateTimeFormat(format).format(date);
|
||||||
@ -34,9 +39,9 @@ const DateCell: FC<DateCellProps> = (props) => {
|
|||||||
<span
|
<span
|
||||||
className={classnames(
|
className={classnames(
|
||||||
{
|
{
|
||||||
[classes.today as string]: dataDate === dataToday,
|
[classes.today as string]: highlightToday && dataDate === dataToday,
|
||||||
[classes.outMothRange as string]: isOutMonthRange,
|
[classes.outMothRange as string]: isOutMonthRange,
|
||||||
[classes.valueDate as string]: dataDate === dataValue,
|
[classes.valueDate as string]: highlightValue && dataDate === dataValue,
|
||||||
},
|
},
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user