Giter Site home page Giter Site logo

eddy-hu / avaiability-calendar-react Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dproc96/avaiability-calendar-react

0.0 1.0 0.0 829 KB

This package provides a customizable Calendar component for your React Application to allow users to set availability ranges for certain days.

Home Page: https://www.npmjs.com/package/availability-calendar-react

JavaScript 92.23% HTML 7.77%

avaiability-calendar-react's Introduction

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"
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.