Giter VIP home page Giter VIP logo

jessemao / react-calendar-mobile Goto Github PK

View Code? Open in Web Editor NEW
22.0 1.0 11.0 1.72 MB

React Calendar Mobile is a component very easy to use with scroll event enabled.

Home Page: https://jessemao.github.io/react-calendar-mobile/

License: MIT License

HTML 3.82% CSS 8.97% JavaScript 87.21%
calendar calendar-component calendar-events react react-calendar calendar-mobile mobile scrollable calendar-scrollable react-mobile

react-calendar-mobile's Introduction

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

Name Type Default Description
selectedDate String/Date new Date() The date selected on calendar. Default to today's date.
startDateAt String/Date new Date() The date of calendar displaying starts at. e.g., startDateAt is 2017-02-01 if the calendar displays February 2017.
startOnMonday Boolean false If false, week starts from Sunday, otherwise, from Monday.
decorate object {} 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.
view String "month" Value will be "month"/"week". If set to "month", then a monthly calendar will be displayed, otherwise, it displays a week.
className String "" Customized class for the Calendar.
i18n String "en-US" Optional. A string with a BCP 47 language tag, or an array of such strings.
weekdayFormat String "narrow" The representation of the weekday. Possible values are "narrow", "short", "long".
monthFormat String "long" The representation of the month. Possible values are "numeric", "2-digit", "narrow", "short", "long".
yearFormat String "numeric" The representation of the year. Possible values are "numeric", "2-digit".
onSelectDate Function Callback 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.
onChange Function Callback 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 Name Description
.react-calendar root div of calendar.
.react-calendar__header header div of calendar, where year and month display
.react-calendar__year year div of calendar.
.react-calendar__month month div of calendar.
.react-calendar__main main body div of calendar.
.react-calendar__weekdays weekdays title div of calendar.
.react-calendar__weekday each weekday title div of calendar.
.react-calendar__days days root div of calendar.
.react-calendar__day each day div of calendar. use .react-calendar__day span for date text style.
.react-calendar__day--today today's date div.
.react-calendar__day--othermonth dates of other months div.
.react-calendar__day--selected selected date div.
.react-calendar__day--decorate date 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

react-calendar-mobile's People

Contributors

jessemao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

react-calendar-mobile's Issues

/util/constant.js中item_height

请问/util/constant.js中item_height是什么意思? month是怎样 week又是怎样在移动到手机需要处理兼容性问题,不知道这两个参数的意思

Not able to select date on android 9

There are multiple issue.

  1. Not able select date in android 9
  2. Event onSelectDate always call when screen render.
  3. Current week and date not focused.

Update component on change startDateAt

Hi,

I'm trying make a custom navigation between months, but I am barred, because the component not update the render when update de startDateAt prop.

Ex:

// ...

this.state = {
    startAt: moment().toDate()
}

// ...

goToNextMonth() {
    this.setState({
        startAt: moment(this.state.startDateAt).add(1, 'months').toDate()
    })
}

// ...

<Calendar
    startDateAt={this.state.startAt}
    decorate={this.decorates}
    i18n={locale}
    onSelectDate={(date) => this.handleSelect(date)}
/>

<button className='agenda-btn next' onClick={this.goToNextMonth}>{monthName} >></button>

In the console is showing the correct data, but just is not updating the component.

window is not defined

I'm using nextjs, and because I import react-calendar-mobile. It says window is not defined.
but on desktop refreshing would rum with no problem. on iPhone it just says window is not defined.

Missing an easy way to move to next month

Hi,

In render I'm missing a easy way to move to next and previous month.
I think it could be done using startDateAt... But I have to implement it, create the arrows < > to move the months, etc...

I good idea is to have that out of box.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.