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

eventize-react-calendar

v1.0.0

Published

React calendar

Downloads

2

Readme

EventizeReactCalendar

EventizeReactCalendar is a customizable, responsive React calendar component that allows you to display events by day, week, or month. The calendar supports custom event rendering, navigation between months, weeks, and days, and allows you to fetch and display events dynamically.

Features

  • Multiple Views: Switch between Month, Week, and Day views.
  • Event Fetching: Fetch events dynamically for a specific month and year.
  • Event Click Handling: Trigger actions when clicking on an event.
  • Custom Event Rendering: Customize how events are rendered on the calendar.
  • Navigation: Navigate between different time frames.
  • Responsive Design: Adapts to different screen sizes for optimal viewing.

Installation

Install the package via npm:

npm install eventize-react-calendar

Basic Usage Example

Below is a basic example of how to use the EventizeReactCalendar in your React application, complete with dummy event data:

import React from "react";
import EventizeCalendar from "eventize-react-calendar";

/**
 * Main App component where EventizeCalendar is used.
 */
const Calendar = () => {
  /**
   * Dummy data for calendar events.
   */
  const dummyEvents = [
    {
      id: "1",
      title: "Project Kickoff",
      start: "2024-11-01T09:00:00",
      color: "#ff4500",
      status: "Open",
    },
    {
      id: "2",
      title: "Client Review Meeting",
      start: "2024-11-01T11:00:00",
      color: "#32cd32",
      status: "Open",
    },
    {
      id: "3",
      title: "Code Review Session",
      start: "2024-11-05T10:00:00",
      color: "#1e90ff",
      status: "Closed",
    },
    {
      id: "4",
      title: "Team Lunch",
      start: "2024-11-05T12:00:00",
      color: "#ffd700",
      status: "Open",
    },
    {
      id: "5",
      title: "Monthly Wrap-Up",
      start: "2024-11-30T15:00:00",
      color: "#8a2be2",
      status: "Closed",
    },
  ];

  /**
   * Function to fetch events based on the month and year.
   * @param {number} month - The current month.
   * @param {number} year - The current year.
   * @returns {Promise<Array>} A promise that resolves to an array of event objects.
   */
  const fetchEvents = async (month, year) => {
    // Filter events for the month and year
    return Promise.resolve(
      dummyEvents.filter((event) => {
        const eventDate = new Date(event.start);
        return (
          eventDate.getMonth() + 1 === month && eventDate.getFullYear() === year
        );
      })
    );
  };

  /**
   * Function to render events for a specific date.
   * [Note] - Add your own CSS class name here to customize the design further.
   * @param {string} date - The date in 'YYYY-MM-DD' format.
   * @returns {JSX.Element[]} An array of JSX elements representing events for that date.
   */
  const renderEvent = (date) => {
    return dummyEvents
      .filter((event) => event.start.startsWith(date))
      .map((event) => (
        <div
          key={event.id}
          style={{
            backgroundColor: event.color,
          }}
        >
          <strong>{event.title}</strong>
          <p>{event.description}</p>
        </div>
      ));
  };

  return (
    <EventizeCalendar fetchEvents={fetchEvents} renderEvent={renderEvent} />
  );
};

export default Calendar;

Props

| Prop | Type | Default | Description | | ------------- | ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------- | | fetchEvents | function | None | A function that must return a promise that resolves to an array of events. It accepts month and year as parameters. | | renderEvent | function | None | A function that returns JSX to render for a given date. The function receives a date string in 'YYYY-MM-DD' format as its parameter. | | defaultView | string | "month" | Optional. Determines the initial view of the calendar. Possible values are "month", "week", and "day". |

To-Do

Below are enhancements and features that are planned for future releases of EventizeReactCalendar:

  • [ ] Time Slot Display: Implementing visualization of time slots for events in Day and Week views to enable a detailed hourly schedule.
  • [ ] Drag-and-Drop Functionality: Adding the ability to drag and drop events to quickly reschedule them.

Current Work in Progress:

  • [] Implementing time slots for the Week and Day views: Show events in specific time intervals.