-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* datepicker addition * datepicker addition * datepicker added
- Loading branch information
Ajinkya Deshmukh
authored
Apr 25, 2022
1 parent
9b2cf2f
commit 4c413ac
Showing
10 changed files
with
284 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import React from "react"; | ||
import DatePicker from "react-datepicker"; | ||
import { getMonth, getYear } from "date-fns"; | ||
import { CaretCircleLeft, CaretCircleRight } from "phosphor-react"; | ||
|
||
import "react-datepicker/dist/react-datepicker.css"; | ||
|
||
const CustomDatePicker = ({ handleChange }) => { | ||
const range = (start, end) => { | ||
const ans = []; | ||
for (let i = start; i <= end; i++) { | ||
ans.push(i); | ||
} | ||
return ans; | ||
}; | ||
|
||
const years = range(1990, getYear(new Date()) + 1); | ||
const months = [ | ||
"Jan", | ||
"Febr", | ||
"Mar", | ||
"Apr", | ||
"May", | ||
"Jun", | ||
"Jul", | ||
"Aug", | ||
"Sep", | ||
"Oct", | ||
"Nov", | ||
"Dec" | ||
]; | ||
return ( | ||
<DatePicker | ||
wrapperClassName="datePicker absolute" | ||
inline | ||
calendarClassName="miru-calendar" | ||
renderCustomHeader={({ | ||
date, | ||
changeYear, | ||
changeMonth, | ||
decreaseMonth, | ||
increaseMonth, | ||
prevMonthButtonDisabled, | ||
nextMonthButtonDisabled | ||
}) => ( | ||
<div | ||
className="headerWrapper" | ||
> | ||
<button onClick={decreaseMonth} disabled={prevMonthButtonDisabled}> | ||
<CaretCircleLeft color="#5b34ea" size={16} /> | ||
</button> | ||
<div> | ||
<select | ||
value={months[getMonth(date)]} | ||
onChange={({ target: { value } }) => | ||
changeMonth(months.indexOf(value)) | ||
} | ||
> | ||
{months.map((option) => ( | ||
<option key={option} value={option}> | ||
{option} | ||
</option> | ||
))} | ||
</select> | ||
|
||
<select | ||
value={getYear(date)} | ||
onChange={({ target: { value } }) => changeYear(value)} | ||
> | ||
{years.map((option) => ( | ||
<option key={option} value={option}> | ||
{option} | ||
</option> | ||
))} | ||
</select> | ||
</div> | ||
<button onClick={increaseMonth} disabled={nextMonthButtonDisabled}> | ||
<CaretCircleRight color="#5b34ea" size={16} /> | ||
</button> | ||
</div> | ||
)} | ||
onChange={(date) => handleChange(date)} | ||
/> | ||
); | ||
}; | ||
|
||
export default CustomDatePicker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
.miru-calendar { | ||
padding: 28px; | ||
position: absolute !important; | ||
z-index: 15; | ||
border: none !important; | ||
box-shadow: 0px 0px 40px rgba(0, 0, 0, 0.1); | ||
border-radius: 8px; | ||
.headerWrapper { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 0 14px; | ||
margin-bottom: 12px; | ||
select { | ||
color: #5b34ea; | ||
font-style: normal; | ||
font-weight: 500; | ||
font-size: 14px; | ||
line-height: 19px; | ||
outline: none; | ||
margin-right: 5px; | ||
} | ||
} | ||
.react-datepicker__day-name { | ||
color: #A5A3AD; | ||
font-weight: 700; | ||
} | ||
.react-datepicker__day--keyboard-selected { | ||
color: #5B34EA; | ||
background-color: transparent; | ||
} | ||
.react-datepicker__day { | ||
font-size: 12px; | ||
line-height: 16px; | ||
letter-spacing: 2px; | ||
padding: 8px; | ||
font-weight: 700; | ||
&:hover { | ||
color: #5B34EA; | ||
background-color: #F5F7F9; | ||
border-radius: 4px; | ||
} | ||
} | ||
.react-datepicker__day--today { | ||
color: #5B34EA; | ||
background-color: transparent; | ||
&:hover { | ||
background-color: #F5F7F9; | ||
border-radius: 4px; | ||
} | ||
} | ||
.react-datepicker__current-month--hasMonthDropdown { | ||
display: none; | ||
} | ||
.react-datepicker__navigation--previous { | ||
top: 35px; | ||
left: 27px; | ||
} | ||
.react-datepicker__navigation--next { | ||
top: 35px; | ||
right: 27px; | ||
} | ||
.react-datepicker__header { | ||
background-color: transparent; | ||
border-bottom: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.