0.1.6 • Published 7 years ago

react-calendar-mobile v0.1.6

Weekly downloads
22
License
MIT
Repository
github
Last release
7 years ago

React Calendar Mobile

React Calendar Mobile is a component very easy to use with no extra effort. It can be used in any project with great performance! Different from other calendar/date picker components, this component uses touches and scrolls to move to different months or weeks like native calendar on mobile device. It supports both monthly and weekly view.

点此阅读简体中文文档

How to install

npm install react-calendar-mobile --save

How to use

ES6

import Calendar from 'react-calendar-mobile';

CommonJS

var Calendar = require('react-calendar-mobile');

Locale / International

React Calendar Component supports locale format as Javascript Date API provides. Users can pass value to i18n, weekdayFormat, monthFormat, yearFormat to localize the calendar. More details displays in the Properties table.

Properties

NameTypeDefaultDescription
selectedDateString/Datenew Date()The date selected on calendar. Default to today's date.
startDateAtString/Datenew Date()The date of calendar displaying starts at. e.g., startDateAt is 2017-02-01 if the calendar displays February 2017.
startOnMondayBooleanfalseIf false, week starts from Sunday, otherwise, from Monday.
decorateobject{}It indicates if there is any event on specific day. A key/value object that maps decorates to calendar. Key format is "YYYY-MM-DD", value can be any value, e.g. {"2017-02-15": true} will add an origin dot under the date of 2017-02-15 on calendar which indicates that there is/are events on that day.
viewString"month"Value will be "month"/"week". If set to "month", then a monthly calendar will be displayed, otherwise, it displays a week.
classNameString""Customized class for the Calendar.
i18nString"en-US"Optional. A string with a BCP 47 language tag, or an array of such strings.
weekdayFormatString"narrow"The representation of the weekday. Possible values are "narrow", "short", "long".
monthFormatString"long"The representation of the month. Possible values are "numeric", "2-digit", "narrow", "short", "long".
yearFormatString"numeric"The representation of the year. Possible values are "numeric", "2-digit".
onSelectDateFunctionCallback function when a date is selected. Output of the selected value is a Date object and is passed in as the first argument of this function.
onChangeFunctionCallback function when calendar scrolls to a different month or week. Output is a Date object and value is the start date of the month or week displaying. Passed in as the first argument of this function.

Style

Class NameDescription
.react-calendarroot div of calendar.
.react-calendar__headerheader div of calendar, where year and month display
.react-calendar__yearyear div of calendar.
.react-calendar__monthmonth div of calendar.
.react-calendar__mainmain body div of calendar.
.react-calendar__weekdaysweekdays title div of calendar.
.react-calendar__weekdayeach weekday title div of calendar.
.react-calendar__daysdays root div of calendar.
.react-calendar__dayeach day div of calendar. use .react-calendar__day span for date text style.
.react-calendar__day--todaytoday's date div.
.react-calendar__day--othermonthdates of other months div.
.react-calendar__day--selectedselected date div.
.react-calendar__day--decoratedate with decorates on. To modify decorate's style, use .react-calendar__day--decorate:after

Getting Started

To play it yourself, you can clone this repo and run the example in your local space.

Or you can play with the picker Online here

git clone https://github.com/jessemao/react-calendar-mobile.git
cd react-calendar-mobile && cd example
npm install
npm start

License

MIT