Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tt-react-calendar

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tt-react-calendar

A React calendar component with as few frills as humanly possible

  • 1.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24
increased by50%
Maintainers
2
Weekly downloads
 
Created
Source

TT React Calendar

NPM Version Downloads Stats

Description

A no-frills calendar widget that lets you bring your own styling. This component takes a start date, an end date, and a renderDay function, and then gets out of the way.

Installation

npm install --save tt-react-calendar

Usage

import Calendar from 'tt-react-calendar';

function renderDay(day) {
  return <div className="day">{day.format('dd')}</div>
}

function renderMonthHeader(firstDay, format) {
  // Don't render month headers for 2016, for some reason.
  if (firstDay.year() === 2017) {
    return firstDay.format(format);
  }
}

function MyComponent() {
  return (
    <Calendar
      className="calendar-container"
      dayAbbrevs={['Su', 'M', 'T', 'W', 'Th', 'F', 'Sa']}
      dayHeaderClassName="calendar-day-header"
      dayHeaderStyle={Calendar.DayHeaderStyles.InFirstMonth}
      firstRenderedDay="2016-12-25"
      lastRenderedDay="2017-02-12"
      monthClassName="calendar-month"
      monthHeaderFormat="MMMM YYYY"
      monthHeaderClassName="calendar-month-header"
      renderDay={renderDay}
      renderMonthHeader={renderMonthHeader}
      weekClassName="calendar-week"
    />
  );
}

And somewhere in your stylesheet build process...

@import 'tt-react-calendar/dist/styles.css';

Properties

NameTypeDescriptionSince Version
classNamestringClass name for the calendar's container element1.0.0
compactMonthsboolA flag that combines all of the months into one continuous block of days, with the month header split out and positioned along the left edge of the container. This sets position: absolute, right: 100%, and margin: 0 on the month header class, so override those properties in your CSS if you think you have better ideas.1.3.0
dayAbbrevsArray.<string>Array of day names, starting with Sunday. Defaults to ['Su', 'M', 'T', 'W', 'Th', 'F', 'Sa'].1.0.0
dayHeaderClassNamestringClass name for the day header container element1.2.0
dayHeaderStyleEnumDetermines where the day column headers are rendered. Can be one of Calendar.DayHeaderStyles.InFirstMonth (the default), Calendar.DayHeaderStyles.AboveFirstMonth, or Calendar.DayHeaderStyles.InEveryMonth1.0.0
firstRenderedDayvariedThe first date that will be rendered as part of the calendar. Can be any type that moment's constructor supports.1.0.0
lastRenderedDayvariedThe last date that will be rendered as part of the calendar. Can be any type that moment's constructor supports.1.0.0
monthClassNamestringClass name to add to each month element1.0.0
monthHeaderFormatstringFormat of the month header text. See moment.format for the available options. Defaults to 'MMMM YYYY'.1.0.0
monthHeaderClassNamestringClass name to add to each month header h3 element1.0.0
renderDayfunctionA function that takes a moment object of a single day as a parameter and returns a React element. Defaults to (day) => <div>{day.format('YYYY-MM-DD')}</div>1.0.0
renderMonthHeaderfunctionA function that takes a moment object and the value of the monthHeaderFormat prop, and returns a React element. Defaults to (firstDay, format) => firstDay.format(format)1.4.0
weekClassNamestringClass name for the week element1.1.0

Browser Support

This is still a very young project, so it hasn't been actively tested in cross browser environments. That being said, given the technologies being used, it should work in any browser that supports some form of flexbox.

Google ChromeMozilla FirefoxMicrosoft Internet ExplorerMicrosoft EdgeSafari
YesYes10+YesYes

See caniuse.com for more details

Development

Issues/PRs welcome! Linting/automated tests coming soon.

Meta

Distributed under the MIT License. See LICENSE for more information.

Developers:

Jeremy Tice @jetpacmonkey

Keywords

FAQs

Package last updated on 04 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc