Code Monkey home page Code Monkey logo

datepicker-hijri's Introduction

Built With Stencil

Hijridate picker web component, simple and can be integrated easily with any frameworks. (محدد التاريخ الهجري)

Installation

Stand alone:

  • Use CDN
<script src="https://cdn.jsdelivr.net/gh/abublihi/[email protected]/build/datepicker-hijri.js"></script>
  • Download files
  1. Download all files in the build directory
  2. Include the script datepicker-hijri.js file like in the code below
<script src="build/datepicker-hijri.js"></script>

Usage

Attributes:

name required description
reference yes an identifier for the element where the datepicker will appear it must be an id for an html element
placement no the placement of the the datepicker 'bottom', 'top', 'right', 'left' and 'auto' default: bottom, you can use any placement in popper.js
date-format no the date format, it is string, default: iYYYY/iMM/iDD, any format in moment-hijri will work
selected-date no the selected date it is string with the same format of date-format prop
on-date-select-close no if you want the datepicker to disapeare on chosing the date only add on-date-select-close

Example

In the Example below the input with id calender is the reference for the datepicker-hijri web component, so if you click or focus on the input the datepicker will be shown.

<input type="text" id="calender">
<datepicker-hijri reference="calender" placement="bottom" date-format="iYYYY/iMM/iDD" selected-date="1441/02/01"></datepicker-hijri>

Event onchange

in any change on the date, will be firing a change event. so you can listen and respond to the change.

<input type="text" id="calender" onchange="console.log('changed')">
                                <!-- ^^^^^^^^ -->
<datepicker-hijri reference="calender" placement="bottom" date-format="iYYYY/iMM/iDD" selected-date="1441/02/01"></datepicker-hijri>

Demo

Codepen Hijridate picker

Demo Image

how it works

So the datepicker shown and every thing is good, but what is happening, when the user chooses the day, the datepicker will modify the attribute value on the reference with the new value.

Credits

  • @xsoh Thank for the awesome package moment-hijir.
  • @FezVrasta Thank you for the package popper.js.

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.