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

@osiris70cl/simple-react-date-picker

v1.4.0

Published

[![npm version](https://badge.fury.io/js/angular2-expandable-list.svg)](https://badge.fury.io/js/angular2-expandable-list) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier

Downloads

106

Readme

npm version code style: prettier

Simple React date picker

Simple react date picker is a simple package that allows you to display a calendar and select a date. Currently this package offers 2 different calendars. A single month display calendar and a double month display calendar. The double month display calendar is still a work in progress and should be viable in the coming weeks.

Prerequisites

A node version of 20 or more is required to make this package work.

Importing the different calendars

Prerequisite

As of today, the package is still in it's early days and more over in it's 1+ version; importing the style at the root of your project is necessary.

For exemple in a nextjs 14 app, you can import it in your general layout where you would manipulate the <head>.

import "@osiris70cl/simple-react-date-picker/dist/index.css";

Simple calendar

You can import the compotent in any pages of your app, making sure that they are client side pages. (For nextjs users, that would mean having a component with the "use client").

The <SingleDatePicker/> can be given multiple props.

Please note that all the props are optionnals. Meaning if you want to just display the calendar you can just call the component and not pass it any props.

Please also note that all the exemples in this documentation are being shown for a Nextjs 14 app.

Basic fucntion with just retrieving the selected date

With this method, you just need to call the component and pass it a function that will retrieve the data from the package. Please note that this will send a date type like :

"2024-07-13T14:22:14.428Z"

I higly recommend you to use the dayjs package to transform this date in your wanted format.

"use client";
import { SingleDatePicker } from "@osiris70cl/simple-react-date-picker";

export default function Page = () => {
  const [selectedDate, setSelectedDate] = useState();

  const handleSelectedDate = (date: any) => {
    setSelectedDate(date)
  }

  return (
    <div>
      <SingleDatePicker handleSelectedDate={handleSelectedDate} />
    </div>
  );
};

Retrieving a selected date and selected time period

This calendar also allows you to pass a time period and retrieve that data.

For this you will need to also pass a function to the component. In this exemple I kept the previous function as it made more sense to use both of them.

the data of the time will be returned for exmple as : 00:00 23:59

Please note that the hourSelection set to true is required to be able to display the time inputs.

"use client";
import { SingleDatePicker } from "@osiris70cl/simple-react-date-picker";

export default function Page = () => {
  const [selectedDate, setSelectedDate] = useState();
  const [startHour, setStartHour] = useState<any>();
  const [endHour, setEndHour] = useState<any>();

  const handleSelectedDate = (date: any) => {
    setSelectedDate(date)
  };

  const handleSlectedHours = (startHour: string, endHour: string) => {
    setStartHour(startHour);
    setEndHour(endHour);
   };

  return (
    <div>
      <SingleDatePicker
      handleSelectedDate={handleSelectedDate}
      handleSlectedHours={handleSlectedHours}
      hourSelection={true} />
    </div>
  );
};

Personnalizing the component

One of the core ideas of this package is to allow the user to personnalize the calendar.

That is why no font family, background color is applied to the calendar. The style you see is the default styling but you can modify it if you wish and this is how.

By passing this object, you can personnalize the background colors the buttons, current day and hovers. More freedom in the style will be coming in the futur if you wish.

const initalData = {
  arrow_background: "#1E90FF",
  arrow_color: "#A9A9A9",
  arrow_hover_background: "#B0C4DE",
  current_day_background: "#ff0000",
  day_hover_background: "#0000ff",
  initial_date: "2024-07-01",
  initial_start_hour: "00:00",
  initial_end_hour: "23:59",
  dayjsLocale: "fr", // fr, es, en, de are supported
};
"use client";
import { SingleDatePicker } from "@osiris70cl/simple-react-date-picker";

export default function Page = () => {
  const [selectedDate, setSelectedDate] = useState();
  const [startHour, setStartHour] = useState<any>();
  const [endHour, setEndHour] = useState<any>();


  const handleSelectedDate = (date: any) => {
    setSelectedDate(date)
  };

  const handleSlectedHours = (startHour: string, endHour: string) => {
    setStartHour(startHour);
    setEndHour(endHour);
   };

  return (
    <div>
      <SingleDatePicker
      handleSelectedDate={handleSelectedDate}
      handleSlectedHours={handleSlectedHours}
      hourSelection={true}
      initialData={initalData}
      />
    </div>
  );
};

Multiple dates picker calendar is coming in the next big patch, hand tight ! :)

Contributing

@Osiris7Ocl, Uxer

Credits

Merci à Manu pour les maquettes

Built With

  • Vitejs
  • React

Authors

  • Osiris70cl - Initial work -