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

@nayojs/react-datetime-picker

v1.1.1

Published

A simple and flexible React component for date and time selection.

Downloads

31

Readme

React DateTime Picker

Overview

npm version Downloads

React DateTime Picker is a robust and highly customizable date-time picker library for React applications. This component offers seamless integration with various UI designs, allowing developers to choose from a wide range of styling options or apply custom styles to match their projects' specific requirements.

datetime-picker

Installation

To install the library, use npm:

npm install @nayojs/react-datetime-picker

Features

  • Date Selection: Easily select dates using the intuitive date picker interface.
  • Time Selection: Includes a time picker for selecting specific hours and minutes.
  • Calendar View: Displays a fully interactive calendar for navigating through months and years.
  • Customizable Styles: Override default styles with ease using CSS classes or a utility function for merging styles.

Components

1. DatePicker

The DatePicker component combines the functionality of a calendar and time picker into a single component. It can be customized with styles and classes that are passed down to the Calendar and TimePicker components.

2. Calendar

The Calendar component provides a visual representation of a calendar where users can select a date. It is fully customizable, allowing developers to define the appearance of various parts of the calendar.

3. TimePicker

The TimePicker component allows users to select a specific time. Like the Calendar, it is highly customizable, with various style options for different elements.

Usage

DatePicker Example

Here’s a basic example of how to use the DatePicker component:

import React from 'react';
import { DatePicker } from '@nayojs/react-datetime-picker';

function App() {
  const selectDateHandler = (date) => {
    console.log('Selected Date:', date);
  };

  const selectTimeHandler = (time) => {
    console.log('Selected Time:', time);
  };

  return (
    <div>
      <Calendar selectDateHandler={selectDateHandler} selectTimeHandler={selectTimeHandler}/>
    </div>
  );
}

export default App;

Calendar Example

To use the Calendar component independently:

import React from 'react';
import { Calendar } from '@nayojs/react-datetime-picker';

function App() {
  const selectDateHandler = (date) => {
    console.log('Selected Date:', date);
  };

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

export default App;

TimePicker Example

To use the TimePicker component independently:

import React from 'react';
import { TimePicker } from '@nayojs/react-datetime-picker';

function App() {
  const selectTimeHandler = (time) => {
    console.log('Selected Time:', time);
  };

  return (
    <div>
      <TimePicker selectTimeHandler={selectTimeHandler} />
    </div>
  );
}

export default App;

Custom Styling

The DatePicker, Calendar, and TimePicker components come with default styles, but you can easily override them by passing custom class names or styles.

Example: Custom Styles for DatePicker

import React from 'react';
import { DatePicker } from '@nayojs/react-datetime-picker';

function App() {
  const selectDateHandler = (date) => {
    console.log('Selected Date:', date);
  };

  return (
    <div>
      <DatePicker
        selectDateHandler={selectDateHandler}
        datePickerStyles={{
          containerStyles: { width: '300px' },
          triggerStyles: { padding: '10px', backgroundColor: '#f0f0f0' },
        }}
        calendarStyles={{
          containerStyles: { backgroundColor: '#fff' },
          dateStyles: { color: '#333' },
          selectedDateStyles: { backgroundColor: '#1A71FF', color: 'white' },
        }}
      />
    </div>
  );
}

export default App;

Style Prop Options

For each component, you can override specific style classes and styles:

  • DatePicker

    • containerClass: Styles the main container of the date picker.
    • triggerClass: Styles the trigger button/input.
    • calendarClasses: Classes passed down to the Calendar component.
    • calendarStyles: Styles passed down to the Calendar component.
  • Calendar

    • containerClass: Styles the main container of the calendar.
    • headerClass: Styles the header of the calendar.
    • dateClass: Styles individual date cells.
    • selectedDateClass: Styles the selected date.
    • navigatorClass: Styles the navigation buttons.
  • TimePicker

    • containerClass: Styles the main container of the time picker.
    • triggerClass: Styles the trigger button/input.
    • timeContainerClass: Styles the time selection container.
    • timeItemClass: Styles each time option.
    • selectedTimeItemClass: Styles the selected time option.

Default Styles

The library provides default styles for all components. If you do not override these styles, the components will use the following defaults:

Advanced Usage

Overriding Default Styles with Helper Function

To ensure that overriding a specific style doesn’t remove other default styles, use the mergeStyles utility function:

import React from 'react';
import { DatePicker, mergeStyles } from '@nayojs/react-datetime-picker';

const customStyles = mergeStyles({
  nayojsDatetimePickerContainer: 'background-color: blue;',
});

function App() {
  const selectDateHandler = (date) => {
    console.log('Selected Date:', date);
  };

  return (
    <div>
      <DatePicker
        selectDateHandler={selectDateHandler}
        datePickerStyles={customStyles}
      />
    </div>
  );
}

export default App;

Contribution

If you'd like to contribute to the project, please follow these guidelines:

  1. Fork the repository.
  2. Create a new branch.
  3. Make your changes and commit them.
  4. Push to your branch and submit a pull request.

Show your support

If you find EduMeet helpful, please give us a star ⭐️ on GitHub! Your support is greatly appreciated and motivates us to keep improving the project.

Author

:bust_in_silhouette: RWUBAKWANAYO

📝 License

React DateTime Picker is licensed under the MIT License. For more information, see the LICENSE file.