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

react-easy-datetime

v1.0.18

Published

A simple and easy-to-use date and time picker component for React

Downloads

419

Readme

Custom Date and Time Picker Components

I created this small library as part of my studies. I apologize for any bugs you may encounter.

I am constantly learning and welcome your feedback to improve this project. Thank you for your understanding !

DateTimePicker

A customizable React component for selecting dates and times.

This library provides a DateTimePicker component that can be easily integrated and customized in your React applications.

Automatic Language Detection

The DateTimePicker component automatically detects and adjusts its language based on the language of the website. It uses the lang attribute of the HTML <html> element to determine the appropriate locale. If no language is specified, it defaults to us.

Here’s a simplified version of how the language detection works:

useEffect(() => {
  const htmlLang = document.documentElement.lang || "us";
  setLang(htmlLang);
}, []);

Supported Languages

Currently, the component only supports English (us) and French (fr).

If the detected language is not supported, the component will default to English.

How It Works:

The component looks for the lang attribute on the element.

If the attribute is set to "fr", the component will use French. Otherwise, it defaults to English ("us").

More languages may be added in future updates.

Screens

To use the DateTimePicker with hour and minute selection, set showTimeSelect to true.

To use it without hour and minute selection, set showTimeSelect to false.

showTimeSelect to false

showTimeSelect to true

Installation

To install the package, use npm or yarn:

yarn add react-easy-datetime
# or
npm install react-easy-datetime

Basic Usage

To use the DateTimePicker component, import it and include it in your JSX:

import React, { useState } from 'react';
import DateTimePicker from 'react-easy-datetime';

const MyComponent: React.FC = () => {
  const [date, setDate] = useState(new Date());

  const handleChange = (newDate: Date) => {
    setDate(newDate);
  };

  return (
    <DateTimePicker
      label={true}
      name="nameInput"
      value={date}
      onChange={handleChange}
      showTimeSelect={true}
      customization={{
        input: ['input_c'],
        calendar: {
          container: ['container_c'],
          button: ['button_c'],
          selected: ['selected_c'],
          hover: ['hover_c'],
          time: {
            button: ['button_c'],
            dropdown: ['dropdown_c']
          },
          date: {
            button: ['button_c'],
            dropdown: ['dropdown_c']
          }
        },
      }}
    />
  );
};

export default MyComponent;

Props

The DateTimePicker component accepts the following props:

label (boolean): Whether to show labels.
name (string): The name attribute for the input element.
value (Date): The current selected date.
onChange (function): Callback function to handle date change.
showTimeSelect (boolean): Whether to show time selection.
customization (object): Custom styles for the component.

Customization

You can customize the appearance of the DateTimePicker by providing a customization object with your own CSS class names.

Customization Props Types

interface CustomizationProps {
  input?: string[];
  calendar?: {
    container?: string[];
    button?: string[];
    selected?: string[];
    hover?: string[];
    time?: {
      button?: string[];
      dropdown?: string[];
    };
    date?: {
      button?: string[];
      dropdown?: string[];
    };
  };
}

Dependencies

This project relies on the following dependencies:

| Package | Version | |------------|-----------| | Node.js | 20.16.0 | | classnames | ^2.5.1 | | prettier | ^3.3.3 |

Recommended IDE

This project is best developed using WebStorm, version [2024.2.2].

IDE Setup

To ensure the best development experience, it's recommended to use WebStorm with the following configurations:

  • WebStorm version: 2024.2.2
  • Node.js version: 20.16.0
  • Enable ESLint for code linting
  • Enable Prettier for code formatting

License

This project is licensed under the MIT License.