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

jot-datepicker

v0.1.1

Published

[Youtube](https://www.youtube.com/c/JackofTraits) | [Github](https://github.com/jackoftraits) The jot-datepicker is a react js datepicker component that lets you customize the look of your calendar.

Downloads

9

Readme

JOT-DATEPICKER by Jack of Traits

Youtube | Github The jot-datepicker is a react js datepicker component that lets you customize the look of your calendar.

Reasons to use jot-datepicker

  • Easy to use.
  • No-brainer configurations are easily passed through the props.

Installation

The jot-datepicker requires Node.js v10+ and moment-js.

$ cd react-js-app
$ npm install jot-datepicker moment

Basic Usage

import Datepicker from "jot-datepicker";
import moment from "moment";

export defaults function App() {
    return (
        <Datepicker
            showCalendar={true}
            value={new Date()}
            width="400px" // Just css width i.e. 300px, 50%
            dateFormat="MMMM DD, Y" // Any moment-js format
            closeTimeOut={200} // Closes the calendar after 200ms
            onDatechange={(value) => {
                // value returns native javascript date object
                console.log(moment(value).format("YYYY-MM-DD"));
            }}
        />
    );
}

Adding custom styles to Weekdays

In this example, I am using Tailwind CSS. However you can use any CSS frameworks that you are comfortable with.

import Datepicker from "jot-datepicker";
import moment from "moment";

export defaults function App() {
    return (
        <Datepicker
            showCalendar={true}
            value={new Date()}
            width="400px" // Just css width i.e. 300px, 50%
            dateFormat="MMMM DD, Y" // any moment-js format
            closeTimeOut={200}
            weekDays={
                <div>
                    <div className="font-semibold">Sun</div>
                    <div className="font-semibold">Mon</div>
                    <div className="font-semibold">Tue</div>
                    <div className="font-semibold">Wed</div>
                    <div className="font-semibold">Thur</div>
                    <div className="font-semibold">Fri</div>
                    <div className="font-semibold">Sat</div>
                <div/>
            }
            onDatechange={(value) => {
                // value returns native javascript date object
                console.log(moment(value).format("YYYY-MM-DD"));
            }}
        />
    );
}

Overriding previous and next month buttons

import Datepicker from "jot-datepicker";
import moment from "moment";

export defaults function App() {
    return (
        <Datepicker
            showCalendar={true}
            value={new Date()}
            width="400px" // Just css width i.e. 300px, 50%
            dateFormat="MMMM DD, Y" // any moment-js format
            closeTimeOut={200}
            customPreviousMonthButton={(previousMonthAction) => {
                return (
                    <button
                        className="text-sm cursor-pointer"
                        onClick={previousMonthAction}
                    >
                        &#8592;
                    </button>
                );
            }}
            customNextMonthButton={(nextMonthAction) => {
                return (
                    <button
                        className="text-sm cursor-pointer"
                        onClick={nextMonthAction}
                    >
                        &#8594;
                    </button>
                );
            }}
            onDatechange={(value) => {
                // value returns native javascript date object
                console.log(moment(value).format("YYYY-MM-DD"));
            }}
        />
    );
}

Overriding the appearance of your calendar

The "view" props accepts two objects, the container and element.

  • The container has ** [calendar, closeButton, inputField] ** properties.

  • The element has ** [calendarTitle, inputField, dateBox, dateBoxSelected] ** properties.

  • The container and element are just CSS properties. You can try experimenting the appearance by changing the CSS properties.

    import Datepicker from "jot-datepicker";
    import moment from "moment";
    
    export defaults function App() {
        return (
            <Datepicker
            showCalendar={true}
            value={new Date()}
            width="400px" // Just css width i.e. 300px, 50%
            dateFormat="MMMM DD, Y" // any moment-js format
            closeTimeOut={200}
            view={{
                container: {
                    calendar: {
                        border: "2px solid #4481cc",
                    },
                    closeButton: {
                        border: "1px solid green",
                        backgroundColor: "#4481cc",
                        color: "yellow",
                    },
                    inputField: {
                        border: "2px dashed #4481cc",
                    },
                },
                element: {
                    calendarTitle: {
                        backgroundColor: "#4481cc",
                        color: "#fff",
                    },
                    inputField: {
                        padding: "4px",
                        border: "1px solid black",
                    },
                    dateBox: {
                        backgroundColor: "#e6dcff",
                    },
                    dateBoxSelected: {
                        backgroundColor: "#15C39A",
                        border: "1px solid green",
                        color: "#fff",
                    },
                },
            }}
            onDatechange={(value) => {
                // value returns native javascript date object
                console.log(moment(value).format("YYYY-MM-DD"));
            }}
        />
    );

    }

Full Configuration with Tailwind

If have installed tailwind in your react project. You can also do the ones as shown in the example below. You can also use other css frameworks such as bootstrap.

import Datepicker from "jot-datepicker";
import moment from "moment";

export defaults function App() {
    return (
        <Datepicker
            showCalendar={false}
            value={new Date()}
            width="400px"
            dateFormat="MMMM DD, Y"
            closeTimeOut={200}
            customPreviousMonthButton={(previousMonthAction) => {
                return (
                    <button
                        className="text-sm cursor-pointer focus:outline-none hover:bg-gray-100 btn px-2 py-1"
                        onClick={previousMonthAction}
                    >
                        &#8592;
                    </button>
                );
            }}
            customNextMonthButton={(nextMonthAction) => {
                return (
                    <button
                        className="text-sm cursor-pointer focus:outline-none hover:bg-gray-100 btn px-2 py-1"
                        onClick={nextMonthAction}
                    >
                        &#8594;
                    </button>
                );
            }}
            weekDays={
                <>
                    <div className="font-semibold bg-green-200">
                        Sun
                    </div>
                    <div className="font-semibold bg-blue-200">Mon</div>
                    <div className="font-semibold bg-blue-200">Tue</div>
                    <div className="font-semibold bg-blue-200">Wed</div>
                    <div className="font-semibold bg-blue-200">
                        Thur
                    </div>
                    <div className="font-semibold bg-blue-200">Fri</div>
                    <div className="font-semibold bg-green-200">
                        Sat
                    </div>
                </>
            }
            customCalendarTitle={(
                currentMonth,
                currentYear,
                monthArray
            ) => {
                return (
                    <div className="font-semibold">
                        {monthArray[currentMonth] + " " + currentYear}
                    </div>
                );
            }}
            view={{
                container: {
                    calendar: {
                        border: "2px solid #4481cc",
                    },
                    closeButton: {
                        border: "1px solid green",
                        backgroundColor: "#4481cc",
                        color: "yellow",
                    },
                    inputField: {
                        border: "2px dashed #4481cc",
                    },
                },
                element: {
                    calendarTitle: {
                        backgroundColor: "#4481cc",
                        color: "#fff",
                    },
                    inputField: {
                        padding: "4px",
                        border: "1px solid black",
                    },
                    dateBox: {
                        backgroundColor: "#e6dcff",
                    },
                    dateBoxSelected: {
                        backgroundColor: "#15C39A",
                        border: "1px solid green",
                        color: "#fff",
                    },
                },
            }}
            onDatechange={(value) => {
                // value returns native javascript date object
                console.log(moment(value).format("YYYY-MM-DD"));
            }}
        />
    );
}

License

MIT

Copyright (c) 2021 jackoftraits

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.