Giter Site home page Giter Site logo

natscale / react-calendar Goto Github PK

View Code? Open in Web Editor NEW
80.0 3.0 13.0 9.15 MB

A no dependencies, lightweight and feature-rich ⚡ calendar component for react.

Home Page: https://natscale.github.io/react-calendar/

License: MIT License

JavaScript 1.72% TypeScript 86.78% CSS 11.50%
calendar calendar-component calendar-widget calendar-view datepicker datepicker-component daterangepicker react date-picker calendarview

react-calendar's Introduction

@natscale/react-calendar language liscence version download

A no dependency, lightweight and feature-rich ⚡ calendar component for react.

Note - The library is still under active development so the API might change before the first stable release. We do not recommend to use it in production yet.

See Online Demo

The link above is a test page to be able to share the development progress with other people while it's in the beta phase. We are working on an official website for it.

📚 Table of Contents

⚡ Features

  • 🗓 Date Range
  • 🗓 Fixed Date Range
  • 🗓 Multiple Dates
  • 🗓 Highlight Custom Dates
  • 🗓 Disable Custom Dates
  • 🗓🗓 Dual Calendar
  • 🗓 Add Your Own Shorcuts
  • 🦄 Easy to Theme
  • No Dependencies
  • 💻 SSR Compatible
  • 🔩 Lots of Easy Customizations
  • 🕊 Lightweight - less than 20kb

📦 Installation

The calendar component uses react hooks so it requires the react version to be at least 16.8.0. Make sure you have a react version that is equal to or greater than that.

With yarn

yarn add @natscale/react-calendar

With NPM

npm install @natscale/react-calendar

🚀 Usage

To add the default stylesheet. You can import it from the node_modules folder.

import '@natscale/react-calendar/dist/main.css';

With Typescript

import React, { useState, useCallback } from 'react';
import { Calendar } from '@natscale/react-calendar';

function App() {
  const [value, setValue] = useState();

  const onChange = useCallback(
    (value) => {
      setValue(value);
    },
    [setValue],
  );

  return (
    <div>
      <Calendar value={value} onChange={onChange} />
    </div>
  );
}

With Javascript

import React, { useState, useCallback } from 'react';
import { Calendar } from '@natscale/react-calendar';

function App() {
  const [value, setValue] = useState();

  const onChange = useCallback(
    (value) => {
      setValue(value);
    },
    [setValue],
  );

  return (
    <div>
      <Calendar value={value} onChange={onChange} />
    </div>
  );
}

📝 Motivation

The idea of creating a calendar component was a result of trying to find something online which could handle my requirements without needing me to hack away at the component's internals and possibly breaking it;

ergo, this react calendar which aims to be a one stop shop for every potential use case a web developer could think of when it comes to calendars and dates. All the featues I included are ones I thought would be most required from a calendar component. Any suggestions or updates are always welcome to make it more robust.

🛠️ Support

Please open an issue for support.

📜 License

MIT © Tushar Sharma

react-calendar's People

Contributors

tusharf5 avatar zutshiy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-calendar's Issues

Unable to install package

When runing the npm install command :

npm ERR! Could not resolve dependency: npm ERR! peer react@"^16.8.0 || ^17.0.0" from @natscale/[email protected] npm ERR! node_modules/@natscale/react-calendar npm ERR! @natscale/react-calendar@"*" from the root project

I think the dependencies need to be updated with [email protected]

Callback for each multi select date

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Focus after programmatically changing date range

Using calendar with isRangeSelector to true, displayed month is not changed when date range is updated.

For example, if initial date range is 2023-01-01 to 2023-01-10, initial "focus" will be January 2023. If I programmatically change it to 2023-03-01 to 2023-03-10, the focus will still be on January 2023 instead of March 2023.

Is there a way to specify what should be the current focus or default focus after an update (start date, end date, ...) ?

Thanks

onTabChange or onFocusChange

I need events to scroll through the month/year.
For example, I need to load data for all days of the month, and then determine for each day whether it is active or not.

For example, when changing a focused day.

auto submitted in <form> when changing date

When I use this Calendar component in <form> and select a date, it is auto submitted.
I looked at the html and found the date is <button> and no type speicified.
The default behavior of <button> is submit in HTML5, so it seems to happen.
Please put the type in <button> tag.
This should be good enough for this issue.
<button type="button">

Do not cache today's date

There is an edge case if a user transitions from 11:59 to 12:01 midnight using the calendar. The calendar will not function right.

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.