• Stars
    star
    168
  • Rank 225,507 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 6 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ“… React DatePicker Library (Flexible, Reusable)

drawing

React DatePicker

License: MIT npm version Build Status codecov Maintainability code style: prettier dependencies Status devDependencies Status Storybook NPM Download Join the chat at https://gitter.im/react-datepicker/community

Flexible, Reusable, Mobile friendly DatePicker Component

๐ŸŽฌ Intro

DatePicker

datepicker

RangeDatePicker

rangedatepicker

Demo in Storybook

Edit React Datepicker

โœจ Major Component

  • RangeDatePicker
  • DatePicker
  • Standalone Calendar

The components that you can use are as follows: If you want to configure the DatePicker yourself, you can configure it any way you want through the Default Calendar component.

๐Ÿ”ง Built With

  • TypeScript
  • Sass
  • React

๐Ÿ“ฆ Dependency

  • Moment.js

In previous versions, moment.js were used. but now it is changed to Day.js to because of bundle size issue (#14)

Day.js is a javascript library for Parse, validate, manipulate, and display dates and times. this component use Day.js library to globalize and control date. You can check the locale list through this link.

๐Ÿ“ฒ Installation

yarn add @y0c/react-datepicker
# or 
npm install --save @y0c/react-datepicker

๐Ÿ’ก Examples

Simple DatePicker

// import Calendar Component 
import React, { Component } from 'react';
import { DatePicker } from '@y0c/react-datepicker';
// import calendar style 
// You can customize style by copying asset folder.
import '@y0c/react-datepicker/assets/styles/calendar.scss';

class DatePickerExample extends Component {

  onChange = (date) => {
    // Day.js object
    console.log(date);

    // to normal Date object
    console.log(date.toDate());
  }
  
  render() {
    return (
      <DatePicker onChange={this.onChange}/>
    )
  }
}

You can find more Exmaples and Demo in story book link

๐ŸŒŽ i18n

Features for i18n are provided by Day.js by default.

see locale list https://github.com/iamkun/dayjs/tree/dev/src/

and you can customize the locale object

// use day.js locale
import 'dayjs/locale/ko'

// delivery prop locale string  
<DatePicker locale="ko" />

// or define customize locale object 
const locale = {
  name: 'ko',
  weekdays: '์ผ์š”์ผ_์›”์š”์ผ_ํ™”์š”์ผ_์ˆ˜์š”์ผ_๋ชฉ์š”์ผ_๊ธˆ์š”์ผ_ํ† ์š”์ผ'.split('_'),
  weekdaysShort: '์ผ_์›”_ํ™”_์ˆ˜_๋ชฉ_๊ธˆ_ํ† '.split('_'),
  months: '1์›”_2์›”_3์›”_4์›”_5์›”_6์›”_7์›”_8์›”_9์›”_10์›”_11์›”_12์›”'.split('_'),
};

// delivery propr locale object
<DatePicker locale={locale} />

Defaults locale en

๐ŸŽจ Themeing

  1. Copy this project asset folder under scss file
  2. Override scss variable you want(_variable.scss) ( red theme examples )
// red_theme.scss
$base-font-size: 12px;
$title-font-size: 1.3em;

// override scss variable
$primary-color-dark: #e64a19;
$primary-color: #ff5722;
$primary-color-light: #ffccbc;
$primary-color-text: #ffffff;
$accent-color: #ff5252;
$primary-text-color: #212121;
$secondary-text-color: #757575;
$divider-color: #e4e4e4;
$today-bg-color: #fff9c4;

// import mixin 
@import "../node_modules/@y0c/react-datepicker/assets/styles/_mixin.scss";
// import app scss
// if you want other style customize 
// app.scss copy & rewrite !
@import "../node_modules/@y0c/react-datepicker/assets/styles/app.scss";

if you want custom css rewrite app.scss file

Try this example!

Edit 1rw1lp8w7j

โš™๏ธ Local Development

This component is managed by a storybook which is combined with develop environment and documentation. If you want develop in local environment, clone project and develop through a storybook

# clone this project
git clone https://github.com/y0c/react-datepicker.git
# install dependency
yarn
# start storybook 
yarn run storybook

Open your browser and connect http://localhost:6006

๐Ÿ’ผ Get Support

Please fork and use https://codesandbox.io/s/pw6n17pk57 to reproduce your problem.

  • Open a new issue(Bug or Feature) on Github
  • Join the Gitter room to chat with other developers.

๐Ÿ‘จโ€๐Ÿ‘ฆโ€๐Ÿ‘ฆ Contribution

Issue and Pull Request are always welcome!

๐Ÿ“ License

MIT