Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
react-contribution-calendar
Advanced tools
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.
$ npm i react-contribution-calendar
Note
Add --save if you are using npm < 5.0.0
import { ContributionCalendar } from 'react-contribution-calendar'
const data = [
{
'2020-04-20': {
level: 2,
}
},
{
'2023-07-08': {
level: 1,
},
},
{
'2023-07-09': {
level: 4,
data: {},
},
},
{
'2023-03-31': {
level: 3,
data: {
myKey: 'my data',
},
},
},
]
<ContributionCalendar
data={data}
start="2020-04-04"
end="2023-05-19"
textColor="#000000"
startsOnSunday={true}
includeBoundary={true}
theme="grass"
cx={10}
cy={10}
cr={2}
onCellClick={(e, data) => console.log(data)}
/>
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 []
.
const data = [
{
'2023-07-08': {
level: 3,
data: {
myKey: 'my data',
},
},
},
{
'2023-07-09': {
level: 1, // `data` attribute could be omitted
},
},
]
start
: Optional. The starting date for the calendar to start, defaults to current year's January 1st(YYYY-MM-DD
format).
end
: Optional. The ending date for the calendar to end, defaults to current year's December 31st(YYYY-MM-DD
format).
textColor
: Optional. The color of indexes. String color code format.
startsOnSunday
: Optional. Whether to start the calendar on Sunday or not, defaults to true
. If set to false, calendar will start on Monday.
includeBoundary
: Optional. Whether to include the boundary cells in the starting or ending date column, defaults to true
.
theme
: Optional. A string that represents a predefined theme name, or an object with custom theme colors. Defaults to grass
.
cx
: Optional. The pixel size of width of each cell, defaults to 10
.
cy
: Optional. The pixel size of height of each cell, defaults to 10
.
cr
: Optional. The pixel size of border radius of each cell, defaults to 2
.
onCellClick
: Optional. An onClick mouse event on each table cell.
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
).
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'} />
grass
pink
halloween
winter
cherry
cherry_blossom
sky
purquoise
blue_pop
mustard
dark_grass
dark_pink
dark_halloween
dark_winter
dark_blue
dark_ocean
dark_vomit
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',
}}
/>
)
}
FAQs
A GitHub-like contribution calendar component for React
The npm package react-contribution-calendar receives a total of 386 weekly downloads. As such, react-contribution-calendar popularity was classified as not popular.
We found that react-contribution-calendar demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.