1.4.0 • Published 4 years ago

react-styled-component-calendar v1.4.0

Weekly downloads
58
License
MIT
Repository
-
Last release
4 years ago

React Styled Component Calendar

Installation

yarn add react-styled-component-calendar

or

npm install --save react-styled-component-calendar

Usage

import Calendar from 'react-styled-component-calendar'

const events = [{
    "title": "Two Volcano Sprint",
    "startDate": "2020-10-18T05:30+01:00",
    "endDate": "2020-10-24T00:00+00:00"
  }, {
    "title": "Silk Road Mountain Race",
    "startDate": "2020-08-14T00:00+00:00",
    "endDate": "2020-08-21T00:00+00:00"
  }, {
    "title": "Transcontinental No.8",
    "startDate": "2020-07-25T00:00+00:00",
    "endDate": "2020-08-01T00:00+00:00"
  }, {
    "title": "TransIbérica",
    "startDate": "2020-07-12T22:00+01:00",
    "endDate": "2020-07-26T22:00+01:00"
  }, {
    "title": "Transpyrenees",
    "startDate": "2020-06-27T21:00+01:00",
		"endDate": "2020-07-03T21:00+01:00"
	}, {
    "title": "GBDURO20",
    "startDate": "2020-06-27T08:00+00:00",
    "endDate": "2020-07-04T00:00+00:00"
  }, {
    "title": "Tour Divide",
    "startDate": "2020-06-12T08:00-07:00",
    "endDate": "2020-07-10T00:00+00:00"
  }, {
    "title": "Trans America Bike Race",
    "startDate": "2020-06-07T06:00-08:00",
		"endDate": "2020-06-20T18:00-05:00"
	}
}]

<Calendar events={events}>

Props

proptyperequireddescription
eventsarray*array of events to pass to the calendar, so below for format of event
dateInViewstringthe current date to be displayed. JavaScript new Date() object. n.b month index starts at 0
navMonthFormatstringmoment js month format
navYearsBeforeNownumbernumber of years to show before current year
navYearsAfterNownumbernumber of years to show before current year
outOfMonthCalendarDayHighlightstringcell hightlight for days outside of visible month
todayColorHightightstringcell highlight for today
onPrevMonthClickfunction(month: number) => {} A function that is fired after month change containing the new month
onNextMonthClickfunction(month: number) => {} A function that is fired after month change containing the new month
CalendarCellRendererfunction({ index: number, events:Event[] }): React.FC<{}> => null; Full override function that returns a Calendar Cell Component. All other Cell props will be ignored
MonthNavRendererfunction(): React.FC<{}> => {} Function that returns the month nav component
WeekHeaderRendererfunction({ days: string[] }}): React.FC<{}> => {} Function that returns the week nav component

Event

attributerequiredtypedescription
title*stringTitle to render for given range
startDate*DateTimestart date
endDate*DateTime
...propsanyany other values you would like to use in a custom calender cell