0.1.6 • Published 4 years ago

itf-react-datepicker v0.1.6

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

ITF React Datepicker

The datepicker developed for the ITF Website, check out the DEMO

Install and usage

Install it

yarn add itf-react-datepicker

Then use it

import React, { useState } from "react";
import DatePickerITF from "./DatePicker";

// add css - up to you how you do this
import '~/node_modules/itf-react-datepicker/dist/main.css';

const DatePickerExample = (props) => {
  const { initialStartDate, initialEndDate } = props;
  const [startDate, setStartDate] = useState<Date | null>(null);
  const [endDate, setEndDate] = useState<Date | null>(null);

  return (
    <DatePickerITF
      startDate={startDate}
      endDate={endDate}
      onDateChange={(startDate, endDate) => {
        setStartDate(startDate);
        setEndDate(endDate);
      }}
    />
  );
};

Props

Yo, this datepicker needs a wrapper that holds the state of the start and end dates. This gives you the flexibility to change the selected dates from your own code e.g. in a reset dates button.

Here are the props:

proptypedescription
startDateDateThe start date
endDateDateThe end date
onDateChange(startDate: Date | null, endDate: Date | null) => voidThe callback when a date is selected in the datepicker
disabled?booleanis it disabled on not, duh
bemModifier?stringa class for the datepicker, if you want it
elementId?stringan id for the datepicker, if you want it

You should hold the state for startDate and endDate in your wrapper component and update it with onDateChange.

Let me know what you think in the issues!

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago