react-datepicker-ui
Version:
Datepicker Component for React
34 lines (29 loc) • 716 B
JavaScript
import React from "react";
const Month = ({
month,
monthIndex,
rowIndex,
currentYear,
currentDate,
onMonthChangeHandler,
}) => {
const selectedMonth = rowIndex * 3 + monthIndex;
const tempSelectedDate = new Date(currentDate);
let className = "month-picker-month-cell";
if (
selectedMonth === tempSelectedDate.getMonth() &&
currentYear === tempSelectedDate.getFullYear()
) {
className += " selectedMonth";
}
const handleOnClickOverMonth = () => {
const selectedMonth = rowIndex * 3 + monthIndex;
onMonthChangeHandler(selectedMonth);
};
return (
<td className={className} onClick={handleOnClickOverMonth}>
{month}
</td>
);
};
export default Month;