0.1.14 • Published 4 years ago

react-date-range-calendar v0.1.14

Weekly downloads
96
License
MIT
Repository
github
Last release
4 years ago

react-date-range-calendar

React Calendar to pick the range between two dates and easily customizable.

Example

Here is the working calendar example.

npm.io

Live Demo

Click to Edit Code ON codesandbox.io

Click to watch working Calendar Demo

Instalation & Configuration

npm install --save react-date-range-calendar


and after installation , Import this package where you want to use the calendar... import Calendar from "react-date-range-calendar";

Use it in this way...

   <Fragment>
       <Calendar />
   </Fragment>

Support :

All major browsers are supported , If you want to run it on IE 9,10,11 . For that you will have to add polyfills for all the things like foreach, closest, es7-object-polyfill and react-app-polyfill

Functional Guide

Property NameDescriptionTypeShort Example
onSelectThis method is called, when user selects the end date, here validDateRange parameter gives the array of available dates and removes the disabled dates from the rangefunction<Calendar onSelect= {(startDate, endDate,validDateRange) => { // do whatever you want to do }} />
onChangeThis method is called, when user selects the start date or end date mean in both casesfunction<Calendar onChange = {(selectedDate) => {console.log('selected date',selectedDate); }} />
selectedRangedate range that will be by default selected, should be of type Array e.g.startDate,endDateArray<Calendar selectedRange= {["2019-03-03","2019-03-07"]} />
disabledDatesdisable the dates those get returned by this method in the array formatfunction<Calendar disabledDates= {() => { return ["2019-03-01","2019-03-02","2019-03-08"] } } />
disablePrevDatesdisable the previous dates, by default it's value is falseboolen<Calendar disabledPrevDates= {true} />

Style Guide

Property NameDescriptionTypeShort Example
leftArrowCssThis sets the css in 'string' format for left calendar Arrow icon, write css just like normal css you write with some extra things like if you want to put Hover Effect you could implement that just by writing this way &:hover{ // your css when you hover over it }string<Calendar leftArrowCss = "background: white; &:hover { background: green; }" />
rightArrowCssThis sets the css in 'string' format for right calendar Arrow icon, write css just like normal css you write usually with hover effect similar to leftArrowCss Propstring<Calendar rightArrowCss = "background: white; &:hover { background: green; }" />
leftMonthYearCssThis sets the css in 'string' format for left calendar's Month and Year text, write normal css with hover effect if needed similar to above string type css propsstring<Calendar leftMonthYearCss = "font-size:14px; }" />
rightMonthYearCssThis sets the css in 'string' format for right calendar's Month and Year text, write normal css with hover effect if needed similar to above string type css propsstring<Calendar rightMonthYearCss = "font-size:14px; }" />
leftCalHeaderCssThis sets the css in 'string' format for left calendar's header, write normal css similar to above string type css propsstring<Calendar leftCalHeaderCss = "background:red; }" />
rightCalHeaderCssThis sets the css in 'string' format for right calendar's header, write normal css similar to above string type css propsstring<Calendar rightCalHeaderCss = "background:red; }" />
thCssThis sets the css in 'string' format for both calendar's day headings, write normal css similar to above string type css propsstring<Calendar thCss = "background:red; }" />
globalCssThis sets the css in 'string' format that could get applied on both of the calendars globally, write normal css similar to above string type css props but with functionality to perform any css operation on any point or element of the calendar. Remember! This global css will not be applied on td elements. For that look at cssObj propsstring<Calendar globalCss = "*{ font-size: 14px } tr{ background: blue; }" />
tdCssObjThis sets the css in 'object' format for both calendar's date tds, write javascript style css , <DOMElement>.style, you can write any of the javascript style property to style the elementobject<Calendar tdCssObj = {{backgroundColor:'white',fontSize: '14px'}} />
onHoverTdCssObjThis sets the css in 'object' format for both calendar's date tds those get hovered, write javascript style css , <DOMElement>.style, you can write any of the javascript style property to style the elementobject<Calendar onHoverTdCssObj = {{backgroundColor:'yellow',fontSize: '14px',color:'brown'}} />
inRangedTdCssObjThis sets the css in 'object' format for both calendar's date tds those comes in range after start date, write javascript style css , <DOMElement>.style, you can write any of the javascript style property to style the elementobject<Calendar inRangedTdCssObj = {{backgroundColor:'green',fontSize: '14px',color:'white'}} />
startDateTdCssObjThis sets the css in 'object' format for both calendar's date td that is the start date, write javascript style css , <DOMElement>.style, you can write any of the javascript style property to style the elementobject<Calendar startDateTdCssObj = {{backgroundColor:'grey',fontSize: '14px',color:'black'}} />
endDateTdCssObjThis sets the css in 'object' format for both calendar's date td that is the end date, write javascript style css , <DOMElement>.style, you can write any of the javascript style property to style the elementobject<Calendar endDateTdCssObj = {{backgroundColor:'grey',fontSize: '14px',color:'black'}} />
disabledDatesTdCssObjThis sets the css in 'object' format for both calendar's date td that is the end date, write javascript style css , <DOMElement>.style, you can write any of the javascript style property to style the elementobject<Calendar disabledDatesTdCssObj = {{backgroundColor:'red',fontSize: '14px',color:'black',opacity:'0.2'}} />

Info :

Disabled dates will not be highlighted even if they get selected , by the selectedRange prop of the component.

Contributing

Pull requests are welcome