5252
5353## 🚀 Features
5454
55- - Zero dependencies
56- - Add events to calendar with ** individual event colors**
57- - ** Configurable event bullet modes** - show multiple bullets or single bullet
58- - Perform some action on calendar date change
59- - Month and year picker built-in
60- - Themes available
61- - Fully customizable using CSS variables, passing options parameters while creating calendar, or overriding CSS.
55+ - 🏎️ ** Zero Dependencies** : Lightweight and fast
56+ - 🎉 ** Event Support** : Add events to calendar with individual event colors
57+ - 🔵 ** Configurable Event Bullet Modes** : Show multiple bullets or single bullet per day
58+ - 📅 ** Month and Year Picker** : Built-in navigation controls
59+ - 🎨 ** Multiple Themes** : Choose from various color schemes and design styles
60+ - 🛠️ ** Fully Customizable** : Using CSS variables, options parameters, or CSS overrides
61+ - 📱 ** Responsive Design** : Works seamlessly across desktop and mobile devices
62+ - ♿ ** Accessibility** : Built with WCAG guidelines in mind
6263- [ Request more features] ( #feature-request ) ...
6364
6465<a id =" getting-started " ></a >
6566
6667## 📦 Getting Started
6768
69+ ### NPM
70+
71+ > _ You might need to use a module bundler such as webpack, rollup, parcel, etc._
72+
73+ #### Installation
74+
75+ ``` bash
76+ npm i color-calendar
77+ ```
78+
79+ #### Import
80+
81+ ``` javascript
82+ import Calendar from " color-calendar" ;
83+ ```
84+
85+ #### CSS
86+
87+ ``` javascript
88+ import " color-calendar/dist/css/theme-<THEME-NAME>.css" ;
89+ ```
90+
6891### CDN
6992
7093#### JavaScript
@@ -104,30 +127,6 @@ Get fonts from [Google Fonts](https://fonts.google.com/)
104127
105128Check what fonts the [theme](#themes) needs or pass your own fonts in [options](#options-fonts).
106129
107- ### NPM
108-
109- > _You might need to use a module bundler such as webpack, rollup, parcel, etc._
110-
111- #### Installation
112-
113- ` ` ` bash
114- npm i color- calendar
115- ` ` `
116-
117- #### Import
118-
119- ` ` ` javascript
120- import Calendar from " color-calendar" ;
121- ` ` `
122-
123- #### CSS
124-
125- ` ` ` javascript
126- import " color-calendar/dist/css/theme-<THEME-NAME>.css" ;
127- ` ` `
128-
129- Then add fonts.
130-
131130<a id="usage"></a>
132131
133132## 🔨 Usage
@@ -146,8 +145,9 @@ _Or_ you can pass in **options**.
146145
147146` ` ` javascript
148147new Calendar ({
149- id: " #color-calendar" ,
150- calendarSize: " small"
148+ container: " #color-calendar" ,
149+ calendarSize: " small" ,
150+ initialSelectedDate: new Date (2024 , 5 , 15 ) // June 15, 2024
151151});
152152` ` `
153153
@@ -164,31 +164,30 @@ new Calendar({
164164` ` ` javascript
165165// Using a function that returns an HTMLElement
166166new Calendar ({
167- id : () => document .getElementById (" my-calendar" ),
168- calendarSize: " large"
167+ container : () => document .getElementById (" my-calendar" )
169168});
170169
171170// Dynamic element creation
172171new Calendar ({
173- id : () => {
174- let container = document .getElementById (" calendar-container" );
175- if (! container) {
176- container = document .createElement (" div" );
177- container .id = " calendar-container" ;
178- container .style .padding = " 20px" ;
179- document .body .appendChild (container);
180- }
172+ container : () => {
173+ const container = document .createElement (" div" );
174+ document .body .appendChild (container);
181175 return container;
182- },
183- calendarSize: " large"
176+ }
177+ });
178+
179+ // Using HTMLElement directly
180+ const myElement = document .getElementById (" my-calendar" );
181+ new Calendar ({
182+ container: myElement
184183});
185184` ` `
186185
187186#### Event Colors and Bullet Modes
188187
189188` ` ` javascript
190189new Calendar ({
191- id : " #calendar" ,
190+ container : " #calendar" ,
192191 eventBulletMode: " multiple" , // or "single"
193192 eventsData: [
194193 {
@@ -216,7 +215,6 @@ new Calendar({
216215**Key Features:**
217216- **Individual Event Colors**: Each event can have its own color
218217- **Cross-Month Support**: Events spanning multiple months display correctly
219- - **White Bullets on Selection**: Selected dates show white bullets for better contrast
220218- **Configurable Bullet Modes**: Choose between multiple bullets or single bullet per day
221219
222220<a id="usage-react"></a>
@@ -235,26 +233,28 @@ new Calendar({
235233
236234## ⚙️ Options
237235
238- ### ` id `
236+ ### ` container `
239237
240- Type: ` String | Function `
238+ Type: ` String | HTMLElement | Function `
241239Default: ` #color- calendar`
242240
243241Selector referencing HTMLElement where the calendar instance will bind to.
244242
245243**String**: CSS selector string (e.g., ` " #my-calendar" ` , ` " .calendar-container" ` )
246244
245+ **HTMLElement**: Direct reference to an HTMLElement
246+
247247**Function**: Function that returns an HTMLElement or null
248248` ` ` javascript
249- // Function-based id example
249+ // Function-based container example
250250const calendar = new ColorCalendar ({
251- id : () => document .getElementById (" my-calendar" ),
251+ container : () => document .getElementById (" my-calendar" ),
252252 // ... other options
253253});
254254
255255// Dynamic element creation
256256const calendar = new ColorCalendar ({
257- id : () => {
257+ container : () => {
258258 let container = document .getElementById (" calendar-container" );
259259 if (! container) {
260260 container = document .createElement (" div" );
@@ -265,6 +265,27 @@ const calendar = new ColorCalendar({
265265 },
266266 // ... other options
267267});
268+
269+ // Using HTMLElement directly
270+ const myElement = document .getElementById (" my-calendar" );
271+ const calendar = new ColorCalendar ({
272+ container: myElement,
273+ // ... other options
274+ });
275+ ` ` `
276+
277+ ### ` initialSelectedDate`
278+
279+ Type: ` Date `
280+ Default: ` undefined ` (uses current date)
281+
282+ Sets the initial selected date when the calendar is first rendered. The calendar will open with this date selected and the view will be set to the month containing this date.
283+
284+ ` ` ` javascript
285+ new Calendar ({
286+ container: " #calendar" ,
287+ initialSelectedDate: new Date (2024 , 5 , 15 ) // June 15, 2024
288+ });
268289` ` `
269290
270291### ` calendarSize`
@@ -293,7 +314,8 @@ Default: `[]`
293314 {
294315 start: ' 2020-08-17T06:00:00' ,
295316 end: ' 2020-08-18T20:30:00' ,
296- name: ' Blockchain 101'
317+ name: ' Blockchain 101' ,
318+ color: ' #ff0000'
297319 ...
298320 },
299321 ...
@@ -465,7 +487,7 @@ Controls how event bullets are displayed when multiple events exist on the same
465487
466488` ` ` javascript
467489new Calendar ({
468- id : " #calendar" ,
490+ container : " #calendar" ,
469491 eventBulletMode: " single" , // or "multiple"
470492 eventsData: [
471493 {
@@ -488,7 +510,7 @@ new Calendar({
488510
489511## 🖱 Events
490512
491- ### ` dateChanged `
513+ ### ` onSelectedDateChange `
492514
493515Type: ` Function `
494516Props:
@@ -503,7 +525,7 @@ Props:
503525` ` ` typescript
504526const options = {
505527 ...
506- dateChanged : (currentDate ?: Date , filteredDateEvents ?: EventData []) => {
528+ onSelectedDateChange : (currentDate ?: Date , filteredDateEvents ?: EventData []) => {
507529 // do something
508530 };
509531 ...
@@ -512,7 +534,7 @@ const options = {
512534
513535Emitted when the selected date is changed.
514536
515- ### ` selectedDateClicked `
537+ ### ` onSelectedDateClick `
516538
517539Type: ` Function `
518540Props:
@@ -526,7 +548,7 @@ Props:
526548
527549Emitted when the selected date is clicked.
528550
529- ### ` monthChanged `
551+ ### ` onMonthChange `
530552
531553Type: ` Function `
532554Props:
@@ -554,7 +576,7 @@ let myCal = new Calendar();
554576myCal .reset ();
555577` ` `
556578
557- ### ` setDate ()`
579+ ### ` setSelectedDate ()`
558580
559581Props:
560582| Props | Type | Required | Description |
@@ -565,7 +587,7 @@ Set new selected date.
565587
566588` ` ` javascript
567589// Example
568- myCal .setDate (new Date ());
590+ myCal .setSelectedDate (new Date ());
569591` ` `
570592
571593### ` getSelectedDate ()`
0 commit comments