4.1.1 • Published 3 months ago

jb-calendar v4.1.1

Weekly downloads
51
License
MIT
Repository
github
Last release
3 months ago

jb-calendar

pure js jalali calendar interface web component sample: https://codepen.io/javadbat/pen/poRKYEY

  • support jalali date as well as gregorian date
  • customizable theme with css variable so you can implement dark mode too
  • support typescript

installation

npm install jb-calendar

usage

    <jb-calendar></jb-calendar>

in frameworks for example React:

import 'jb-calendar'
function myHOC(){
    return(
        <jb-calendar></jb-calendar>   
    )
}

select value

    document.querySelector('jb-calendar').select(year,month,day);
    // for example:
    document.querySelector('jb-calendar').select(1399,8,24);

you can write wrapper for it in any js framework you use and it will compatible with react, vue, angular, ...

dependancy

we use date-fns and date-fns-jalali to manege calendar jalali data

events

//when defualt property are defined best time for impl your config like min and max date
document.querySelector('jb-calendar').addEventListener('init',this.onCalendarElementInitiated);

//when calendar init all property and function and dom created and bind successully
document.querySelector('jb-calendar').addEventListener('load',this.onCalendarElementLoaded);

//when user select a selectable day on calendar
document.querySelector('jb-calendar').addEventListener('select',this.onDaySelected);

Jalali and Gregorian Date input

in jb-calendar you can set date input type to be jalali or gregorian and change it whenever you want by simple set dateInput to JALALI or GREGORIAN.

    document.querySelector('jb-calendar').dateInput = `GREGORIAN`;

set default selected day and month

you can say which date is shown by default in component when loaded like this:

document.querySelector('jb-calendar').defaultCalendarData = {
            gregorian:{
                year: 2022,
                month:1,
            },
            jalali:{
                year:1400,
                month:1,
            }
        };

if you not set this the default will be today year and month

persian number

you can set usePersianNumber so calendar number format change to persian number char for example in year instead of 1400 you will see ۱۴۰۰.

document.querySelector('jb-calendar').usePersianNumber = true;

Change Month List

you may want to change the default month list for both of Jalali and Gregorian calendars base on your country month labels. here how you can do it:

document.querySelector('jb-calendar').setMonthList('JALALI',['حَمَل','ثَور','جَوزا','سَرَطان','اَسَد','سُنبُله','میزان','عَقرَب','قَوس','جَدْی','دَلو','حوت']);
document.querySelector('jb-calendar').setMonthList('GREGORIAN',['1','2','3','4','5','6','7','8','9','10','11','12']);

attribute

set custom style

in some cases in your project you need to change default style of web-component for example you need different color or different border-radius and etc.
if you want to set a custom style to this web-component all you need is to set css variable in parent scope of web-component

css variable namedescription
--jb-calendar-colorgeneral text color of component
--jb-calendar-arrow-button-bgcolorbackground color of next and prev button
--jb-calendar-arrow-button-border-radiusborder rauis of arrow buttons default is 12px
--jb-calendar-day-text-colorday text color
--jb-calendar-day-text-color-disabledday text color when day in not available for select
--jb-calendar-day-text-color-todaytoday day text color
--jb-calendar-day-bgcolor-selectedselected day background color
--jb-calendar-day-bgcolor-selected-hoverselected day background color on hover
--jb-calendar-day-bgcolor-hoverday background color on hover
--jb-calendar-status-point-bgcolor-todaybackgrround color of small cirle under today text
--jb-calendar-status-point-border-colorborder color of status point
--jb-calendar-month-bgcolor-hoverbackground color of month in month list in hover state
--jb-calendar-year-bgcolor-hoverbackground color of year in month list in hover state
--jb-calendar-arrow-fill-colornext and prev arrow icon color
--jb-calendar-day-color-hoverday color hover default color is #312d2d
--jb-calendar-month-color-hoverday color hover default color is #312d2d
--jb-calendar-year-color-hoverday color hover default color is #312d2d
4.1.0

3 months ago

4.1.1

3 months ago

4.0.4

5 months ago

3.4.0

1 year ago

4.0.1

1 year ago

4.0.0

1 year ago

4.0.3

1 year ago

4.0.2

1 year ago

3.3.0

2 years ago

3.2.0

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.0

2 years ago

2.2.0

2 years ago

2.1.0

2 years ago

1.2.4

2 years ago

1.3.0

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.13

2 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.9

3 years ago

1.0.10

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago