npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hammaadhrasheedh/react-event-calendar

v0.1.31

Published

A small & customizable react calendar component to show your daily events for a given month.

Downloads

443

Readme

React Event Calendar

A small & customizable react calendar component to show your daily events for a given month.

Features

  • Dotted and filled days for events
  • Customize day rendering
  • Customize event rendering
  • Show Holidays
  • Click a day to get the data to showcase on another component

Demo

Demo

Installation

Install react-event-calendar with npm

  npm install @hammaadhrasheedh/react-event-calendar

Styles

Get styles for the calendar

  import '@hammaadhrasheedh/react-event-calendar/dist/themes/default.css'

Other out of the box styling options

  import '@hammaadhrasheedh/react-event-calendar/dist/themes/circular.css'
  import '@hammaadhrasheedh/react-event-calendar/dist/themes/clean.css'
  import '@hammaadhrasheedh/react-event-calendar/dist/themes/neumorphic.css'
  import '@hammaadhrasheedh/react-event-calendar/dist/themes/dark.css'

Simple Example

import { Calendar } from '@hammaadhrasheedh/react-event-calendar'

var events = [
    {
        date: "2022-05-02",
        color: "red",
    },
    {
        date: new Date('2022-05-23'),
        color: "pink",
    },
    {
        date: "2022-05-02",
        color: "#c3c3c3",
    },
];

<Calendar
    eventType="Fill"
    date={'2022-05-09'}
    events={events}
/>

Props

| Prop | Type | Description | Example | | :-------- | :------- | :------- | :------------------------- | | defaultSelected | Moment\|Date\|string | Selects a day by deafult when calendar renders | '2022-12-22' | | holidays | Array<Moment\|Date\|string> | Highlight holidays in unified style | ['2022-12-22', new Date(), moment()]| | events | Array<Object> | Events to mark on the calendar | [{date: "2022-05-02", color: "red", extraData:any}] | | eventType | 'Dots' \| 'Fill' | Determines how the events will be dispalyed in calendar. Default: 'Dots'| | | prefixID | string | Prefixes to the unique id to each date block | | | defaultDayFormater | string | Format how days are displayed in calednder. Default: 'DD' | moment docs | | date | Moment\|Date\|string | Determines which month to be shown in calendar, Default: today | '2022-12-22' \| new Date() \| moment() | | displayWeek | Boolean | Show or hide week section of calendar | | | dateFormat | string | Format how calendar date is displayed in header of calednder. Default: 'MMM YYYY' | moment docs | | headerType | 'EvenSpread' \| 'ActionSeparate' | Formats the layout of the header ( date and action buttons) | |

Methods

| Prop | Params | Description | Example | | :-------- | :------- | :------- | :------------------------- | | renderDay | {isToday, defaultFormatedDay, day, isSelectedDay, isSameMonth, isHoliday, events, index} | Function to customize the render of the full day block | Render Day | | renderDayContent | {isToday, defaultFormatedDay, day, isSelectedDay, isSameMonth, isHoliday, events, index} | Function to customize the content the day | | | renderEvent | event, index | Function to customize the UI of the events | | | prevBtn | | Function to customize the icon/content of previous button | | | nextBtn | | Function to customize the icon/content of next button | | | onClickDay | day | Calls the function when a day is clicked | |

Examples

Render Day

const renderDay = ({
    isToday,
    defaultFormatedDay,
    day,
    isSelectedDay,
    isSameMonth,
    isHoliday,
    events,
    index,
  }) => {

    //   hide days from other months
    if(!isSameMonth){
      return null
    }

    return (
      <div>
        <div
          className={`day-block cursor-pointer\
           ${isToday ? "current-day" : ""}\
           ${isSelectedDay ? "selected-day" : ""}\
           ${!isSameMonth ? "another-month-day" : ""}\
           ${isHoliday ? "holiday" : ""} 
       `}
        >
          {defaultFormatedDay}
        </div>
      </div>
    );
  };

Render Event


  const eventsStyles =  `.events-container{
    top:0;
    right:0;
  }
  .has-events .day{
    color:white
  }
  `

  const renderEvent = (event:any, index:any) => {
    return (
      <div style={{backgroundImage: event.extraData.gradient, width:'100%', height:'100%', zIndex:-1}}>
      </div>
    )

  }
  return (
    <div>
      <style> {eventsStyles} </style>
      <Calendar
        date={"2022-05-09"}
        renderEvent={renderEvent}
        events={[
          {
            date: "2022-05-21",
            color: "#c3c3c3",
            extraData:{gradient:'linear-gradient(to top, #f77062 0%, #fe5196 100%)'}
          },
        ]}
      />
    </div>
  );