Coder Social home page Coder Social logo

shankytiwari / react-month-picker-dropdown Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 2.39 MB

๐Ÿ“… This is a slim library for month picker as dropdown menu for React Project

Home Page: https://stackblitz.com/edit/react-n3swqy

License: MIT License

HTML 6.43% JavaScript 6.00% CSS 18.86% TypeScript 68.70%
react-month-picker-dropdown react-month-picker month-picker-dropdown react-month-picker-select month-picker-select month-picker-select-menu react-month-picker-select-menu

react-month-picker-dropdown's Introduction

react-month-picker-dropdown

Month picker as dropdown menu for React Projects

Why react-month-picker-dropdown?

The main goal of this package is to deliver a slim and Skinny Month picker as dropdown menu for React Projects, that can fit into any kind of projects with no muss, no fuss. This menu is completely customizable, in fact, you write your own theme as you like.

Demo

Check the Month picker in action, click here.

Install

You can use either the npm or yarn command-line tool to install packages. Use whichever is appropriate for your project in the examples below.

NPM

npm install --save react-month-picker-dropdown

YARN

yarn add --save react-month-picker-dropdown

Usage

import React from 'react'

import {
  MonthPickerDropdown
} from 'react-month-picker-dropdown'
import 'react-month-picker-dropdown/dist/index.css'

import './green-theme.scss';

const App = () => {

  const handleAMonthChange = (event) => {
    console.log(event)
  }

  const getMarkUpForOkButton = () => {
    return (
      <button className='button'> Select Me</button>
    )
  }

  const getMarkUpForCancelButton = () => {
    return (
      <button className='button'> Cancel Me</button>
    )
  }

  return (
    <div className="dropdown-demo">
      <MonthPickerDropdown
        CTabIndex={3}
        label="Select Months"
        searchTextLabel="Filter the months by typing here"
        startYear={2018}
        startMonth={1}
        endYear={2020}
        endMonth={5}
        displayShortMonthName={true}
        displayShortYearName={false}
        hideCheckBox={true}
        displayOkAndCancelButton={true}
        markUpForOkButton={getMarkUpForOkButton}
        markUpForCancelButton={getMarkUpForCancelButton}
        onChange={handleAMonthChange}
      />
    </div>
  );
}

export default App

Props

Prop Type Default Description
CTabIndex number 1 To give the tab index
label string Select Months This will is display the Month Picker label as Select Months.
startYear number Current Year Here you can specify the Start year, from where Month dropdown will start.
startMonth number January Here you can specify the Start Month.
endYear number Current Year Here you can specify the End year, from where Month dropdown will end.
endMonth number December Here you can specify the End Month.
displayShortMonthName boolean false This option will allow you to set how Months should be display on screen for example, Jan or January.
displayShortYearName boolean false This option will allow you to set how Years should be display on screen for example, 20 or 2020.
hideCheckBox boolean false With the help of this option you hide the checkboxes shown in the list.
displayOkAndCancelButton boolean false With this You can show the Submit and Cancel button in the end of the list of months.
markUpForOkButton, markUpForCancelButton function func These two props will expect the function which should return the JSX. This is useful if you want to display custom Submit or Cancel button.
onChange function func Callback function will invoked on select event. Params are startYear, startMonth, endYear & endMonth.

Creating your own theme

.month-picker-dropdown .select-months {
    border: solid 0.5px #022424;
    background-color: #00a699;
    color: #fff;
}

.month-picker-dropdown .select-picker {
    border-bottom: solid 0.5px #022424;
    border-left: solid 0.5px #022424;
    border-right: solid 0.5px #022424;
}

.month-picker-dropdown .select-picker .select-picker-options .options .option-title {
    text-align: center;
}

.month-picker-dropdown .select-picker .select-picker-options .selected-month-background-color {
    background: #00a699;
    color: #fff;
}

.month-picker-dropdown .select-picker .select-picker-options .hovered-month-background-color {
    background-color: #66e2da;
    color: #fff;
}

Thanks

This Project is build using create-react-library.

License

MIT ยฉ ShankyTiwari

react-month-picker-dropdown's People

Contributors

shankytiwari avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.