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

@dmnchzl/datepicker

v1.0.0

Published

DatePicker Built With React And Other Cool Stuff

Downloads

7

Readme

npm minified size beerware

DatePicker

@dmnchzl/datepicker is an accessible and customizable <DatePicker /> component built with React and other cool stuff (like styled-components or polished)

Props

Below, the list of all available props:

color / bgColor

Colorize the text / the background of the component

By default, the component colors are respectively purple (#673ab8) and white (#fff) for the background

import { DatePicker } from '@dmnchzl/awesome-hooks';

export default function App() {
  return (
    <div>
      <DatePicker color="#ffc107" bgColor="#171717">
        {props => (
          <input
            ref={props.ref}
            type="date"
            onClick={e => {
              e.preventDefault();
              props.onOpen();
            }}
          />
        )}
      </DatePicker>
    </div>
  );
}

dayOfTheWeek

Change the start day of the week

Sunday (0) is the default week start day, but French people prefer to start the week on Monday (1)

import { DatePicker } from '@dmnchzl/awesome-hooks';

export default function App() {
  return (
    <div>
      <DatePicker dayOfTheWeek={1}>
        {props => (
          <input
            ref={props.ref}
            type="date"
            onClick={e => {
              e.preventDefault();
              props.onOpen();
            }}
          />
        )}
      </DatePicker>
    </div>
  );
}

forceLocale

Force the locale / the language

By default, the component is based on the navigator's language, but you can force the locale to have several different <DatePicker /> on the same view

NB: Currently, the component supports the following locales: de / en / es / fr / it / ja ; for further, take a look at the customMessages prop below...

import { DatePicker } from '@dmnchzl/awesome-hooks';

export default function App() {
  return (
    <div>
      <DatePicker forceLocale="ja">
        {props => (
          <input
            ref={props.ref}
            type="date"
            onClick={e => {
              e.preventDefault();
              props.onOpen();
            }}
          />
        )}
      </DatePicker>
    </div>
  );
}

hideFooter

Hide component footer (and its buttons)

When the footer is hidden, the calendar disappears when a date is selected / or when the escape button is pressed

import { DatePicker } from '@dmnchzl/awesome-hooks';

export default function App() {
  return (
    <div>
      <DatePicker hideFooter>
        {props => (
          <input
            ref={props.ref}
            type="date"
            onClick={e => {
              e.preventDefault();
              props.onOpen();
            }}
          />
        )}
      </DatePicker>
    </div>
  );
}

customMessages

(Re)translate all or part of the component

import { DatePicker } from '@dmnchzl/awesome-hooks';

export default function App() {
  return (
    <div>
      <DatePicker customMessages={{ 'Footer.Cancel': 'Nope', 'Footer.Ok': 'Okay' }}>
        {props => (
          <input
            ref={props.ref}
            type="date"
            onClick={e => {
              e.preventDefault();
              props.onOpen();
            }}
          />
        )}
      </DatePicker>
    </div>
  );
}

| Month Keys | Days Key | Footer Keys | | ----------------- | --------------- | --------------- | | Month.January | Day.Sunday | Footer.Today | | Month.February | Day.Monday | Footer.Cancel | | Month.March | Day.Tuesday | Footer.Ok | | Month.April | Day.Wednesday | | | Month.March | Day.Thursday | | | Month.May | Day.Friday | | | Month.June | Day.Saturday | | | Month.July | | | | Month.August | | | | Month.September | | | | Month.October | | | | Month.November | | | | Month.December | | |

Preview

https://raw.githubusercontent.com/DmnChzl/DatePicker/main

Purple White Pink Shrine Green Basil Amber Dark

Project Structure

/
├── src/
│   ├── components/
│   │   ├── __tests__/
│   │   │   └── DatePicker.test.tsx
│   │   ├── icons/
│   │   │   ├── ChevronLeft.tsx
│   │   │   ├── ChevronRight.tsx
│   │   │   ├── DoubleChevronLeft.tsx
│   │   │   ├── DoubleChevronRight.tsx
│   │   │   └── index.ts
│   │   ├── DatePicker.tsx
│   │   └── styled.ts
│   ├── constants/
│   │   └── index.ts
│   └── utils/
│       ├── __tests__/
│       │   ├── arrUtils.test.ts
│       │   └── dateUtils.test.ts
│       ├── arrUtils.ts
│       └── dateUtils.ts
├── package.json
└── vite.config.ts

Miscellaneous

If you want more,

You can clone the project:

git clone https://github.com/dmnchzl/datepicker.git

Install dependencies:

yarn install

Develop locally:

yarn dev

Run all unit tests:

yarn test

If you want, format the code:

yarn format

And finally compile the project:

yarn build

Enjoy 👍

License

"THE BEER-WARE LICENSE" (Revision 42):
<[email protected]> wrote this file. As long as you retain this notice you
can do whatever you want with this stuff. If we meet some day, and you think
this stuff is worth it, you can buy me a beer in return. Damien Chazoule