React calendar component.
There is no good and vacant names, so: calendar → Gregorian calendar → Gregory.
var React = require('react');
var Calendar = require('gregory');
function onDatePicked(date) {
console.log(date);
}
React.render(
<Calendar CLASSNAME="cldr"
UI_HAS_SIX_ROWS={false}
ON_SELECT={onDatePicked} />,
document.getElementById('calendar')
);
In theory: IE9+ now, IE8+ with polyfills (shims alter environment, so that they aren't included).
In practice: tested on modern browsers only.
Gregory is available as an npm package:
npm install gregory
There are three categories of options
CLASSNAME
sets prefix for all elements classnamesON_SELECT
is callback on clicked/selected cell with enabled date
DATE_CURRENT
is default/current date for calendar- All dates above
DATE_MAX
are disabled/unselectable - All dates behind
DATE_MIN
are disabled/unselectable
UI_DAY_CLASSNAME
sets function for adding classNames to day-cellUI_DAY_RENDER
sets middleware function for day-cell renderUI_FORMAT_MONTH
sets format of current month at header (See moment.js documentation)UI_HAS_SIX_ROWS
sets showing of six rows always even for FebruaryUI_HAS_WEEKDAYS
sets visibility of header with weekdays captionsUI_MONTHS_NUMBER
sets number of monthsUI_TEXT_NEXT
sets caption for next-month buttonUI_TEXT_PREV
sets caption for prev-month buttonUI_WEEKDAYS
is array of weekdays captions
npm install
npm start # build examples and start server
QT_QPA_PLATFORM='' npm test # tests and linting
See gulpfile for more usefull tasks.
- 4 spaces for indentation
- No classes or prototypes, just functions
- If function should use this.props, pass it as first argument
- Priority: simplicity > consistency > performance
MIT