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

availability-calendar-react

v1.0.10

Published

This package provides a customizable Calendar component for your React Application to allow users to set availability ranges for certain days. The component uses a state object passed from its parent to store the data. It also allows the user to hover ove

Downloads

57

Readme

Availability Calendar React

This package provides a customizable Calendar component for your React Application to allow users to set availability ranges for certain days. The component uses a state object passed from its parent to store the data. It also allows the user to hover over a given day to see the availability times they have indicated for that day.

This component is built using Material UI and contains a Material UI ThemeProvider.

Basic Setup

After installing this package, you can import the CalendarTemplate function. You must then create an instance of useState for availability and pass it to the CalendarTemplate as such:

import React, { useState } from 'react';
import CalendarTemplate from 'availability-calendar-react';

function App() {
  const [availability, setAvailability] = useState([])
  const Calendar = CalendarTemplate({
    availability,
    setAvailability
  })
  return (
    <div>
      <Calendar />
    </div>
  );
}

export default App;

Screenshot

Saving Availability

When the user hits "Save Availability" the availability that you passed to the calendar will be updated. It is stored in the following format:

[
  {
    start: Date,
    end: Date
  },
  {
    start: Date,
    end: Date
  }
]

If you want to perform an additional action (like an API call) when that happens, you can alter the setAvailability that's passed to the Calendar as such:

const Calendar = CalendarTemplate({
    availability,
    setAvailability: update => {
      performAdditionalAction(update)
      setAvailability(update)
    },
});

User Experience

As a first time user I will see the blank calendar showing the current month with any days before today disabled. When I click on a day, the color of the day will change to the calendar's primary color and I can start adding times.

When I click on a time, the color will also change to the primary color to indicate availability.

After adding times to a given day, if I click another day that becomes the selected day. Any days where I have indicated availability will appear in the calendar's secondary color. If I hover my cursor over the day it will show the ranges I've indicated.

When I have selected some times, I can click "Add Selected Times to Multiple Days" and until I hit "Done" whenever I click a day it will add the given times to that day automatically (example, I can quickly add 9:00 to 5:00 for every day of the week).

Customizing the Calendar

Currently, you are able to customize the primary color, secondary color, font color, font size, font family, start time and end time:

const Calendar = CalendarTemplate({
    availability,
    setAvailability,
    primaryColor: "#CCCCCC",
    secondaryColor: "#EEEEEE",
    primaryFontColor: "#444444",
    fontFamily: "Roboto",
    fontSize: 14,
    startTime: "5:00",
    endTime: "22:00"
});