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

@lls/react-light-calendar

v2.2.0

Published

๐Ÿ—“ A lightweight calendar for React (~3 kb)

Downloads

717

Readme

@lls/react-light-calendar

๐Ÿ—“ A lightweight calendar for React (~3 kb)

Bundlephobia npm version


@lls/react-light-calendar is a tiny calendar component which does NOT depend on any date lib. @lls/react-light-calendar use timestamp format date which allows it to be coupled with any date lib.

Navigation ๐Ÿ—บ๏ธ :

Why ๐Ÿค”

Because most calendar components depend on heavy date library. This make the bundle become very big and forces you to use it's date library dependence. This can be a huge problem on big projects that already have had a lot of dependencies, especially for projects that use another date library.

The purpose of @lls/react-light-calendar is to propose a minimalistic and powerful component to be able to be used on any project.

How to use โœ๏ธ

Install @lls/react-light-calendar via npm :

npm install --save @lls/react-light-calendar

Or via yarn :

yarn add @lls/react-light-calendar

Use it :

import Calendar from '@lls/react-light-calendar'
import '@lls/react-light-calendar/dist/index.css' // Default Style

<Calendar startDate={startDate} onChange={this.onChange} />

โ—๏ธNotice the style import. If you want to use a custom style, just remove this line and use your own style. โ—๏ธMost important elements of react-light-calendar have a class, so you can use them to override the current style.

Demo ๐Ÿ‘€

Compatibility โœ…

react / react-dom

@lls/react-light-calendar has react and react-dom as peer dependencies.

| @lls/react-light-calendar | react / react-dom | |:------------------------- |:------------------| | 2.x | >= 16.3.0 | | 1.x | >= 16.3.0 |


Browsers ๐ŸŒ

  • ๐ŸŒChrome 42+
  • ๐ŸฆŠFirefox 37+
  • ๐Ÿงญ Safari 8+
  • ๐ŸŒInternet Explorer 10+
  • ๐ŸŒMicrosoft Edge

According to BrowseEmAll.


Changelog ๐Ÿ—’๏ธ

  • 2.0.6 : Fix month/year navigation (https://github.com/lelivrescolaire/react-light-calendar/issues/6)

Examples ๐Ÿ“‹

Basic example

import ReactLightCalendar from '@lls/react-light-calendar'
import '@lls/react-light-calendar/dist/index.css'

const DAY_LABELS = ['Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche']
const MONTH_LABELS = ['Janvier', 'Fevrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Aรปot', 'Septembre', 'Octobre', 'Novembre', 'Dรฉcembre']

class Calendar extends Component {
  constructor(props) {
    super(props)
    const date = new Date()
    const startDate = date.getTime()
    this.state = {
      startDate, // Today
      endDate: new Date(startDate).setDate(date.getDate() + 6) // Today + 6 days
    }
  }

  onChange = (startDate, endDate) => this.setState({ startDate, endDate })

  render = () => {
    const { startDate, endDate } = this.state

    return (
        <ReactLightCalendar startDate={startDate} endDate={endDate} onChange={this.onChange} range displayTime />
    )
  }
}

Good practice example

The best way to avoid massive code and code duplication is to create a Calendar composant based on react-light-component and use it where you want.

A fully example is available here.


Input example

react-light-component is delivered with only one component : a calendar. If you want to use it like a datetime input, you can follow this examples.


API ๐Ÿ“–

The following list represent all available @lls/react-light-calendar's props.

startDate

  • Type : Int (timestamp)
  • Default value : null
  • Required : false
  • Available since : v1.0.0

Default date (timestamp) selected or first date selected if endDate is defined.


endDate

  • Type : Int (timestamp)
  • Default value : null
  • Required : false
  • Available since : v1.0.0

Last date selected.


onChange

  • Type : Function(startDate [Int], endDate [Int])
  • Default value : empty function
  • Required : false
  • Available since : v1.0.0

This function is called every time a day is selected/updated.


disableDates

  • Type : Function(date [Int])
  • Default value : empty function
  • Required : false
  • Available since : v1.0.0

This function describe wich days must be disabled (when disabled, a day can't be selected).

Example, disabled all passed day :

<Calendar disableDates={date => date < new Date().getTime()} />

displayTime

  • Type : Boolean
  • Default value : false
  • Required : false
  • Available since : v1.0.0

If time input must be displayed.


dayLabels

  • Type : Array[String]
  • Default value : ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
  • Required : false
  • Available since : v1.0.0

Days name, starting with Monday.


monthLabels

  • Type : Array[String]
  • Default value : ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
  • Required : false
  • Available since : v1.0.0

Months name, starting with January.


timezone

  • Type : String
  • Default value : UTC
  • Required : false
  • Available since : v1.0.0

Calendar timezone.


markedDays

  • Type : Function(date [Int]) or Array[Number]
  • Default value : empty function
  • Required : false
  • Available since : v2.1.0

This prop marks the date with the dot below. It can be a function like in disableDates. This is useful when you want to mark the days with the events.

Example, mark all passed day :

<Calendar markedDays={date => date < new Date().getTime()} />

mark today and tomorrow :

const today = new Date().getTime()
const tmr = today + (24*60*60*1000)

...

<Calendar markedDays={[today, tmr]} />

Development ๐Ÿ’ป

// Clone the project
git clone [email protected]:lelivrescolaire/react-light-calendar.git

// โฌ‡๏ธ Install node modules
npm install

// ๐Ÿš€ Start the project
npm run start

// โœ… Run tests
npm run test

// ๐Ÿ—๏ธ Build the project
npm run build

// ๐Ÿ‘€ Keep an eye on the bundle size
npm run size

License ๐Ÿ–‹

MIT