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

react-contribution-calendar

Package Overview
Dependencies
Maintainers
2
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-contribution-calendar

A GitHub-like contribution calendar component for React

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
434
decreased by-7.07%
Maintainers
2
Weekly downloads
 
Created
Source

react-contribution-calendar

A GitHub-like contribution calendar component for React, built with Vite and TypeScript. This provides a visual representation of contribution activity, similar to the contribution graph seen on a GitHub profile.


Installation

$ npm i react-contribution-calendar

Note
Add --save if you are using npm < 5.0.0


Usage

import { ContributionCalendar } from 'react-contribution-calendar'

const data = [
  {
    '2023-07-08': {
      level: 1,
    },
  },
  {
    '2023-07-09': {
      level: 4,
      data: {},
    },
  },
  {
    '2023-12-31': {
      level: 3,
      data: {
        myKey: 'my data',
      },
    },
  },
]

<ContributionCalendar data={data} />

APIs

ContributionCalendar

ContributionCalendar is the main component of this library. It takes a data property, which is an array of objects representing the contribution data, and a theme property to customize its appearance.

  • data: An array of objects, where each object has a date string(YYYY-MM-DD format) as key, and an InputDataProps object as value. Defaults to [].

    • An example data is as follows:
      const data = [
        {
          '2023-07-08': {
            level: 3,
            data: {
              myKey: 'my data',
            },
          },
        },
        {
          '2023-07-09': {
            level: 1,
          },
        },
      ]
      
  • theme: Optional. A string that represents a predefined theme name, or an object with custom theme colors. Defaults to grass.


createTheme

createTheme is a helper function to create custom themes. It takes a string representing a predefined theme name or an object containing custom theme colors. This returns a theme object(ThemeProps).


Themes

You can customize the appearance of the <ContributionCalendar /> with the theme property. We provide several built-in themes.

// Replace `theme` attribute with belows 
<ContributionCalendar data={[]} theme={'grass'} />

Light Themes

grass
grass
cherry
cherry
cherry_blossom
cherry_blossom
pink
pink
sky
sky
halloween
halloween
winter
winter
purquoise
purquoise
blue_pop
blue_pop
mustard
mustard

Dark Themes

dark_vomit
dark_vomit
dark_pink
dark_pink
dark_blue
dark_blue
dark_ocean
dark_ocean
dark_grass
dark_grass
dark_halloween
dark_halloween
dark_winter
dark_winter

Custom Theme

import { ContributionCalendar, createTheme } from 'react-contribution-calendar'

function App() {

  /* Define your custom theme */
  const customTheme = createTheme({
    level0: "#ebedf0",
    level1: "#9be9a8",
    level2: "#40c463",
    level3: "#30a14e",
    level4: "#216e39",
  })

  return (
    <ContributionCalendar
      data={[]}
      theme={customTheme}
    />
  )
}

Or you can set theme properties directly,

import { ContributionCalendar } from 'react-contribution-calendar'

function App() {
  return (
    <ContributionCalendar
      data={[]}
      theme={{
        // Assign theme properties directly
        level0: "#ebedf0",
        level1: "#9be9a8",
        level2: "#40c463",
        level3: "#30a14e",
        level4: "#216e39",
      }}
    />
  )
}

Keywords

FAQs

Package last updated on 06 Aug 2023

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