1.0.6 • Published 12 months ago

react-windatepicker v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

React WinDatepicker

WinDatepicker gif demo

Description

A react custom date picker with Windows 10 skin and customizable colors

Functionalities

  • Navigate through dates or months
  • Switch from dates to months or months to dates
  • Set up a min and max range for clickable dates/months
  • Multiple language support to translate months and weekdays (english and french for now)

Installation

npm i react-windatepicker

Usage

import "react-windatepicker/style.css";
import { WinDatePicker } from "react-windatepicker";

const App = () => {

  function handleDateChange(date) {
    console.log(date)
  }

  return (
    <WinDatePicker
      inputProps={{
        onDateChange: handleDateChange
      }}
    />
  )
}

Props

PropsDescriptionRequired
inputPropsprops to apply on inputtrue
calendarColorscustom colors to apply on calendarfalse

inputProps

Key nameTypeDescriptionrequired
setTodayByDefaultbooleanSets input value to today, default to falsefalse
onDateChangefunctionDate update callback. The argument will give back an object with the raw retrieved date and the date formatted as a YYYY-MM-DD string formattrue
React input propsanyYou can pass any react input props to completefalse

calendarColors

Key nameTypeDescription
backgroundstringCalendar background color
headerButtonsstringColor of calendar header buttons (up/down arrows and months/dates switch)
headerButtonsHoverstringColor of header buttons on hover
weekDaysstringColor of weekdays
datesButtonsBorderHoverstringColor of date/month buttons border on hover
datesFromChosenMonthButtonsstringColor of date/month buttons from the chosen month/year
datesFromChosenMonthButtonsBackgroundstringBackground color of date/month buttons from the chosen month/year
datesFromChosenMonthButtonsBorderstringBorder color of date/month buttons from the chosen month/year
date/monthsOutsideChosenMonthButtonsstringColor of date/month buttons outside the chosen month/year
selectedDateButtonstringColor of selected date/month button
selectedDateButtonBackgroundstringBackground color of selected date/month button
selectedDateButtonBorderstringBorder color of selected date/month button
todayButtonstringColor of today's date/month button
todayButtonBackgroundstringBackground color of today's date/month button
todayButtonBorderstringBorder color of today's date/month button
todayButtonSecondBorderstringSecond border color of today's date/month button (smaller than the first one)
weekendsButtonsBackgroundstringBackground color of weekend date/month buttons
disabledButtonsstringColor of disabled date/month buttons (dates / month and up/down arrows buttons)
disabledButtonsBackgroundstringBackground color of disabled date/month buttons
clickedButtonstringColor of clicked date/month button

Types

type Color = string

interface CalendarColors {
    background?: Color
    headerButtons?: Color
    headerButtonsHover?: Color
    weekDays?: Color
    datesButtonsBorderHover?: Color
    datesFromChosenMonthButtons?: Color
    datesFromChosenMonthButtonsBackground?: Color
    datesFromChosenMonthButtonsBorder?: Color
    datesOutsideChosenMonthButtons?: Color
    selectedDateButton?: Color
    selectedDateButtonBackground?: Color
    selectedDateButtonBorder?: Color
    todayButton?: Color
    todayButtonBackground?: Color
    todayButtonBorder?: Color
    todayButtonSecondBorder?: Color
    weekendsButtonsBackground?: Color
    disabledButtons?: Color
    disabledButtonsBackground?: Color
    clickedButton?: Color
}

type OnDateChange = {
    /** "YYYY-MM-DD" format */
    formatted: string | ""
    /** Date format */
    raw: Date | null
}

WinDatePickerProps {
  inputProps:
  /** Any react input props */
  ComponentProps<"input"> & {
    /** required date update callback */
    onDateChange: (date: OnDateChange) => any
    /** sets input value to today, default to false */
    setTodayByDefault?: boolean
  }
  calendarColors?: CalendarColors
}

Examples

You can find some examples here : Link

CodeSandbox examples :

Basic (With TypeScript): Link

Colors : Link

Range : Link

TBA

  • More translated langs
  • Accessibility improvement with keyboard navigation
1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago