# react-dategrid

> A minimal calendar component based on render props

Latest version **0.0.3** (published 2018-04-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-dategrid
pnpm add react-dategrid
yarn add react-dategrid
bun add react-dategrid
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2018-04-18 |
| First published | 2018-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Anton Niklasson |
| Maintainers | antonniklasson |
| Keywords | react, calendar |

## Links

- npm: https://www.npmjs.com/package/react-dategrid
- Homepage: https://github.com/AntonNiklasson/react-dategrid
- npm.io page: https://npm.io/package/react-dategrid

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2018-04-18
- 0.0.3-6 (next) — 2018-04-18
- 0.0.3-5 — 2018-04-16
- 0.0.3-4 — 2018-04-16
- 0.0.3-3 — 2018-04-16
- 0.0.3-2 — 2018-04-16
- 0.0.3-1 — 2018-04-16
- 0.0.3-0 — 2018-04-16
- 0.0.2 — 2018-04-14
- 0.0.2-4 — 2018-04-13
- 0.0.2-3 — 2018-04-13
- 0.0.2-2 — 2018-04-13
- 0.0.2-1 — 2018-04-13
- 0.0.2-0 — 2018-04-13
- 0.0.1 — 2018-04-11

## README

# React Dategrid 📅

A calendar component based on [render props](https://reactjs.org/docs/render-props.html).

The approach is to _make as few decisions as possible_. The only markup it renders is the structure for the underlying table, everything else is up to the consumer. It has no knowledge of something like a _selected date_ or how do style past dates. Implement that kind of behaviour in `renderDay`. The only thing it really needs is a moment instance to base its view on.

## Install

```
npm install --save react-dategrid
yarn add react-dategrid
```

## Usage

Each `day` is a moment instance. The `view` is what is currently shown by the component, also represented by a moment instance.

```javascript
import Dategrid from 'react-dategrid';

class Datepicker extends React.Component {
  state = {
    view: moment()
  }

  renderTitle = (view) => {
    return <strong>{view.format('MMMM YYYY')}</strong>;
  }

  renderWeekday = (index) => {
    const weekday = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'][index];

    return <div className={index < 5 ? 'workday' : 'weekend'}>{weekday}</div> }

  renderDay = (day, view) => {
    if (moment().isSame(day, "day")) {
      return (
        <div className="day day--today">{day.date()}</div>
      );
    }

    return <div className="day">{day.date()}</div>;
  }

  render() {
    return (
      <Dategrid
        view={this.state.view}
        renderTitle={this.renderTitle}
        renderWeekday={this.renderWeekday}
        renderDay={this.renderDay}
      />
    );
  }
}
```

## Props

### view

The current view to render.

### onViewChange(updatedView)

Called as the view updates.

### renderTitle(view)

Receives the current view instance. This will be placed between the navigations with a colspan fixed to 5.

### renderPreviousNavigation(props)

Receives props to be spread on the interactive navigation element.

### renderNextNavigation(props)

Receives props to be spread on the interactive navigation element.

### renderDay(day, view)

Receives a specific day as a moment instance together with the current view. This will be rendered into a `<td />`.

---
_Source: https://npm.io/package/react-dategrid · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
