1.0.3 • Published 4 years ago

react-range-calendar v1.0.3

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

react-range-calendar :calendar:

A responsive and accessible date range picker component with bunch of options built with React :fire:

NPM JavaScript Style Guide

Demo & Features (click here)

rangefree-rangesingle
npm.ionpm.ionpm.io

Install

npm install --save react-range-calendar

OR

yarn add react-range-calendar

Usage

import React, { Component } from "react";
import Calendar from "react-range-calendar";

export default class App extends Component {
  state = {
    visible: true,
    dateRange: [new Date("11/10/2019"), new Date("11/18/2019")]
  };

  render() {
    const { visible, dateRange } = this.state;
    const steps = 7;
    const startWithDay = "Wed";

    return (
      <Calendar
        visible={visible}
        steps={steps}
        startWithDay={startWithDay}
        dateRange={dateRange}
        onDateClick={(minDate, maxDate) => {
          this.setState({ dateRange: [minDate, maxDate] });
        }}
        type="range"
      />
    );
  }
}

Common Props

Asterisk (*) props are Required.

Prop nameDescriptionDefault ValueExample values
type*Types of calendar ["free-range", "single", "range"]"range""free-range"
visible*Visibility of calendarfalsetrue
dateRange*Array of starting and ending dates[][new Date("11/10/2019"), new Date("11/18/2019")]
onDateClick*On clicking any date(minDate, maxDate)=>{}
baseColorBase color#007bffredfontColorFont Color | white
hoverBackgroundColorHover background color#007bffredhoverFontColorHover Font Color | white
disabledColorDisabled color#add8e6#b9b9b9weekDaysColorWeek Days Color | #ff7b7b
weekendsDaysColorWeekends colorgrey#ffbaba

Types

  1. range

    On user date selection, it will find nearest provided day (startWithDay) and add provided steps from that day

    Example

    <Calendar
      visible={visible}
      steps={steps}
      startWithDay={startWithDay}
      dateRange={dateRange}
      onDateClick={(minDate, maxDate) => {
        this.setState({ dateRange: [minDate, maxDate] });
      }}
      type="range"
    />

    Demo

    npm.io

    Props

    Prop nameDescriptionDefault ValueExample values
    steps*Steps from start date77
    startWithDay*Starting day of nearest selected dateWedWed
  2. free-range

    Users can select date freely

    Example

    <Calendar
      visible={visible}
      dateRange={dateRange}
      onDateClick={(minDate, maxDate) => {
        this.setState({ dateRange: [minDate, maxDate] });
      }}
      type="free-range"
    />

    Demo

    npm.io

  3. single

    For single date select

    Example

    <Calendar
      visible={visible}
      dateRange={dateRange}
      onDateClick={date => {
        this.setState({ dateRange: [date] });
      }}
      type="single"
    />

    Demo

    npm.io

Contributors ✨

Thanks goes to these wonderful people

Pull Requests

Feel free to make Pull Request for your feature/fix.

License

MIT © Expertizo