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

datepicker-green-p14

v1.0.2

Published

The `Datepicker` component provides a simple interface for selecting a date from a calendar popup. It allows users to choose a date by clicking on a day within the calendar grid, and the selected date is displayed in an input field. The component includes

Downloads

166

Readme

Datepicker Component

The Datepicker component provides a simple interface for selecting a date from a calendar popup. It allows users to choose a date by clicking on a day within the calendar grid, and the selected date is displayed in an input field. The component includes month and year selection dropdowns, and it supports parent-child communication via the onChange function.

Features

  • Date Selection: Users can select a date from the calendar.
  • Month and Year Picker: Allows for selecting the month and year, with a dropdown to navigate through months and years.
  • Customizable ID: The component accepts an idPrefix to help with unique identification of input elements.
  • Parent Communication: The selected date is passed back to the parent component via the onChange function.

Installation

Ensure that the Datepicker.css file is imported for styling. Import the Datepicker component into your project.

import Datepicker from './src/component/Datepicker'

Usage

import { useState } from 'react'
import Datepicker from './Datepicker'

const MyComponent = () => {
  const [selectedDate, setSelectedDate] = useState('')

  const handleDateChange = (date) => {
    setSelectedDate(date)
  }

  return (
    <div>
      <h1>Selected Date: {selectedDate}</h1>
      <Datepicker idPrefix="date-input" onChange={handleDateChange} />
    </div>
  )
}

Props

  • idPrefix (string): The prefix for the ID of the date input field. This can be used to create unique IDs for multiple instances of the Datepicker component.
  • onChange (function): A callback function that is called when a date is selected. It receives the selected date in DD/MM/YYYY format as an argument.

Component Structure

  • Input Field: An input field is used to display the selected date. The user cannot type in the field but can open the calendar popup by clicking on it.
  • Calendar Popup: When the input field is clicked, a calendar is displayed where the user can select a date. Month and Year Selectors: Dropdowns are provided to allow the user to change the month and year.
  • Date Grid: The calendar grid shows all the days in the selected month, and clicking a day selects the date.

Example

const DatepickerExample = () => {
  const [selectedDate, setSelectedDate] = useState('')

  const handleDateChange = (date) => {
    console.log('Selected date:', date)
    setSelectedDate(date)
  }

  return (
    <div>
      <h2>Choose a date:</h2>
      <Datepicker idPrefix="date-1" onChange={handleDateChange} />
      <p>Selected date: {selectedDate}</p>
    </div>
  )
}

Datepicker Screenshot

Customization

  • Styling: Customize the calendar’s appearance by modifying the styles in Datepicker.css.
  • Date Format: The selected date is returned in DD/MM/YYYY format. You can customize this format if needed by modifying the handleDayClick function.

License

This component is open-source and can be freely used in any project.