react-attendance-calendar 1.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,18 +1,18 @@
1
- # Attendance Calendar
1
+ # React Attendance Calendar
2
2
 
3
- A highly customizable and developer-friendly React attendance calendar component with TypeScript support. This component provides a clean, modern interface for displaying attendance data with interactive features and full theme customization.
3
+ A highly customizable and developer-friendly React attendance calendar component with TypeScript support. This component provides a clean, modern interface for displaying attendance data with interactive features and complete styling control through Tailwind CSS classes.
4
4
 
5
5
  ## ✨ Features
6
6
 
7
7
  - 📅 **Responsive Design**: Automatically adjusts between 7 and 14 columns based on container width
8
- - 🎨 **Full Theme Customization**: Customize all colors, borders, and styling
8
+ - 🎨 **Complete Styling Control**: Use any Tailwind CSS classes for full customization
9
9
  - 🖱️ **Interactive Dates**: Click on dates to trigger custom actions
10
10
  - 📱 **Mobile Friendly**: Responsive design that works on all screen sizes
11
11
  - 🔧 **TypeScript Support**: Full TypeScript definitions included
12
12
  - ⚡ **Lightweight**: Minimal dependencies, only requires React
13
13
  - 🎯 **Accessible**: Includes proper ARIA labels and semantic HTML
14
- - 🎛️ **Developer Friendly**: Extensive props for customization
15
- - 🎭 **Pure Tailwind CSS**: No external CSS dependencies
14
+ - 🎛️ **Developer Friendly**: Granular className props for every element
15
+ - 🎭 **Pure Tailwind CSS**: No external CSS dependencies, uses `clsx` and `tailwind-merge`
16
16
 
17
17
  ## Installation
18
18
 
@@ -20,6 +20,10 @@ A highly customizable and developer-friendly React attendance calendar component
20
20
  npm install react-attendance-calendar
21
21
  ```
22
22
 
23
+ ### CSS Setup
24
+
25
+ The component uses Tailwind CSS v4. Make sure you have Tailwind CSS configured in your project. No additional CSS imports are needed.
26
+
23
27
  ## Usage
24
28
 
25
29
  ### Basic Usage
@@ -42,7 +46,7 @@ function App() {
42
46
  }
43
47
  ```
44
48
 
45
- ### With Attendance Data & Custom Theme
49
+ ### With Attendance Data & Custom Styling
46
50
 
47
51
  ```tsx
48
52
  import React, { useState } from "react";
@@ -50,7 +54,6 @@ import {
50
54
  AttendanceCalendar,
51
55
  MonthView,
52
56
  AttendanceData,
53
- CalendarTheme,
54
57
  } from "react-attendance-calendar";
55
58
 
56
59
  function App() {
@@ -69,17 +72,6 @@ function App() {
69
72
  absentDays: new Set([4, 11, 18, 25]),
70
73
  };
71
74
 
72
- // Custom theme
73
- const customTheme: CalendarTheme = {
74
- primaryColor: "#10b981", // Green for present
75
- absentColor: "#f59e0b", // Orange for absent
76
- textColor: "#1f2937",
77
- borderColor: "#d1d5db",
78
- mutedTextColor: "#9ca3af",
79
- hoverColor: "#f3f4f6",
80
- backgroundColor: "#ffffff",
81
- };
82
-
83
75
  const handleDateClick = (day: number, month: number, year: number) => {
84
76
  console.log(`Clicked on ${day}/${month + 1}/${year}`);
85
77
  // Your custom logic here
@@ -91,11 +83,16 @@ function App() {
91
83
  view={view}
92
84
  onChangeView={setView}
93
85
  attendanceData={attendanceData}
94
- theme={customTheme}
95
86
  onDateClick={handleDateClick}
96
87
  showNavigation={true}
97
88
  showWeekdayHeaders={true}
98
- className="border border-gray-200 rounded-lg p-4"
89
+ // Custom styling with className props
90
+ cellClassName="rounded-full"
91
+ presentCellClassName="bg-green-500 text-white shadow-lg"
92
+ absentCellClassName="bg-red-500 text-white border-2 border-red-300"
93
+ navigationButtonClassName="bg-blue-500 text-white hover:bg-blue-600"
94
+ monthTitleClassName="text-3xl text-purple-600"
95
+ containerClassName="border border-gray-200 rounded-lg p-4"
99
96
  />
100
97
  </div>
101
98
  );
@@ -106,16 +103,22 @@ function App() {
106
103
 
107
104
  ### AttendanceCalendar
108
105
 
109
- | Prop | Type | Required | Description |
110
- | -------------------- | ---------------------------------------------------- | -------- | ----------------------------------------------- |
111
- | `view` | `MonthView` | ✅ | Current month view with year and month index |
112
- | `onChangeView` | `(view: MonthView) => void` | ✅ | Callback when user navigates to different month |
113
- | `attendanceData` | `AttendanceData` | ❌ | Optional attendance data to display |
114
- | `theme` | `CalendarTheme` | ❌ | Custom theme colors and styling |
115
- | `onDateClick` | `(day: number, month: number, year: number) => void` | ❌ | Callback when a date is clicked |
116
- | `showNavigation` | `boolean` | ❌ | Show/hide month navigation (default: true) |
117
- | `showWeekdayHeaders` | `boolean` | ❌ | Show/hide weekday headers (default: true) |
118
- | `className` | `string` | ❌ | Additional CSS classes |
106
+ | Prop | Type | Required | Description |
107
+ | --------------------------- | ---------------------------------------------------- | -------- | ----------------------------------------------- |
108
+ | `view` | `MonthView` | ✅ | Current month view with year and month index |
109
+ | `onChangeView` | `(view: MonthView) => void` | ✅ | Callback when user navigates to different month |
110
+ | `attendanceData` | `AttendanceData` | ❌ | Optional attendance data to display |
111
+ | `onDateClick` | `(day: number, month: number, year: number) => void` | ❌ | Callback when a date is clicked |
112
+ | `showNavigation` | `boolean` | ❌ | Show/hide month navigation (default: true) |
113
+ | `showWeekdayHeaders` | `boolean` | ❌ | Show/hide weekday headers (default: true) |
114
+ | `className` | `string` | ❌ | Additional CSS classes for main container |
115
+ | `cellClassName` | `string` | ❌ | CSS classes for all calendar cells |
116
+ | `presentCellClassName` | `string` | ❌ | CSS classes for present day cells |
117
+ | `absentCellClassName` | `string` | ❌ | CSS classes for absent day cells |
118
+ | `navigationButtonClassName` | `string` | ❌ | CSS classes for prev/next buttons |
119
+ | `weekdayHeaderClassName` | `string` | ❌ | CSS classes for weekday headers |
120
+ | `monthTitleClassName` | `string` | ❌ | CSS classes for month title |
121
+ | `containerClassName` | `string` | ❌ | CSS classes for main container |
119
122
 
120
123
  ### Types
121
124
 
@@ -131,48 +134,58 @@ type AttendanceData = {
131
134
  presentDays: Set<number>; // Set of day numbers (1-31)
132
135
  absentDays: Set<number>; // Set of day numbers (1-31)
133
136
  };
134
-
135
- type CalendarTheme = {
136
- primaryColor?: string; // Color for present days (default: "#3b82f6")
137
- absentColor?: string; // Color for absent days (default: "#ef4444")
138
- textColor?: string; // Main text color (default: "#1f2937")
139
- borderColor?: string; // Border color (default: "#e5e7eb")
140
- mutedTextColor?: string; // Muted text color (default: "#6b7280")
141
- hoverColor?: string; // Hover background color (default: "#f3f4f6")
142
- backgroundColor?: string; // Background color (default: "#ffffff")
143
- };
144
137
  ```
145
138
 
146
139
  ## Styling
147
140
 
148
- The component uses Tailwind CSS classes. Make sure you have Tailwind CSS installed and configured in your project. The component uses these standard Tailwind classes:
141
+ The component uses Tailwind CSS classes with the `cn` utility function (combining `clsx` and `tailwind-merge`) for optimal class merging. Make sure you have Tailwind CSS installed and configured in your project.
149
142
 
150
- - Layout: `w-full`, `flex`, `grid`, `gap-3`, `gap-4`, `items-center`, `justify-center`
151
- - Sizing: `size-8`, `size-10`, `size-12`, `size-14`
152
- - Colors: `bg-emerald-500`, `bg-amber-500`, `text-slate-900`, `text-slate-600`
153
- - Borders: `border`, `border-slate-200`, `rounded-xl`, `rounded-2xl`
154
- - Spacing: `mb-4`, `mb-6`, `mb-8`, `p-6`, `p-8`
155
- - Typography: `text-xl`, `text-2xl`, `font-semibold`, `font-bold`
143
+ ### Default Styling
156
144
 
157
- ### Custom Styling
145
+ The component comes with modern, clean default styles:
158
146
 
159
- You can customize the appearance using the `theme` prop or by adding custom CSS classes:
147
+ - **Present days**: `bg-emerald-500 text-white`
148
+ - **Absent days**: `bg-amber-500 text-white`
149
+ - **Regular days**: `text-slate-700 border-2 border-slate-200`
150
+ - **Navigation buttons**: `border-2 border-slate-200 text-slate-700`
151
+
152
+ ### Custom Styling with className Props
153
+
154
+ You have complete control over styling using the granular className props:
160
155
 
161
156
  ```tsx
162
- // Example with custom styling
157
+ // Example with complete customization
163
158
  <AttendanceCalendar
164
159
  view={view}
165
160
  onChangeView={setView}
166
161
  attendanceData={attendanceData}
167
- theme={{
168
- primaryColor: "#3b82f6",
169
- absentColor: "#ef4444",
170
- textColor: "#1f2937",
171
- }}
172
- className="my-custom-calendar"
162
+ // Shape customization
163
+ cellClassName="rounded-full"
164
+ presentCellClassName="bg-green-500 text-white shadow-lg"
165
+ absentCellClassName="bg-red-500 text-white border-4 border-red-300"
166
+ // Navigation styling
167
+ navigationButtonClassName="bg-blue-500 text-white hover:bg-blue-600"
168
+ weekdayHeaderClassName="bg-gray-100 rounded-lg"
169
+ monthTitleClassName="text-3xl text-purple-600"
170
+ // Container styling
171
+ containerClassName="border border-gray-200 rounded-lg p-4"
173
172
  />
174
173
  ```
175
174
 
175
+ ### Available Styling Options
176
+
177
+ - **Shapes**: `rounded-full`, `rounded-lg`, `rounded-none`, `rounded-2xl`
178
+ - **Colors**: Any Tailwind color classes (`bg-blue-500`, `text-red-600`, etc.)
179
+ - **Effects**: `shadow-lg`, `hover:scale-105`, `transition-all`
180
+ - **Gradients**: `bg-gradient-to-r from-blue-500 to-purple-500`
181
+ - **Borders**: `border-2`, `border-4`, `border-dashed`
182
+
183
+ ### Pro Tips
184
+
185
+ - Use `cn()` utility for conditional classes: `cn("base-class", condition && "conditional-class")`
186
+ - Combine multiple effects: `"bg-blue-500 hover:bg-blue-600 transition-colors shadow-lg"`
187
+ - Override default colors completely with your own Tailwind classes
188
+
176
189
  ## License
177
190
 
178
191
  MIT
@@ -0,0 +1,30 @@
1
+ import { type ClassValue } from "clsx";
2
+ export declare function cn(...inputs: ClassValue[]): string;
3
+ export type MonthView = {
4
+ year: number;
5
+ monthIndex: number;
6
+ };
7
+ export type AttendanceData = {
8
+ year: number;
9
+ monthIndex: number;
10
+ presentDays: Set<number>;
11
+ absentDays: Set<number>;
12
+ };
13
+ export type CalendarProps = {
14
+ view: MonthView;
15
+ onChangeView: (next: MonthView) => void;
16
+ attendanceData?: AttendanceData;
17
+ onDateClick?: (day: number, month: number, year: number) => void;
18
+ showNavigation?: boolean;
19
+ showWeekdayHeaders?: boolean;
20
+ className?: string;
21
+ cellClassName?: string;
22
+ presentCellClassName?: string;
23
+ absentCellClassName?: string;
24
+ navigationButtonClassName?: string;
25
+ weekdayHeaderClassName?: string;
26
+ monthTitleClassName?: string;
27
+ containerClassName?: string;
28
+ };
29
+ export default function AttendanceCalendar({ view, onChangeView, attendanceData, onDateClick, showNavigation, showWeekdayHeaders, className, cellClassName, presentCellClassName, absentCellClassName, navigationButtonClassName, weekdayHeaderClassName, monthTitleClassName, containerClassName, }: CalendarProps): import("react/jsx-runtime").JSX.Element;
30
+ //# sourceMappingURL=AttendanceCalendar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AttendanceCalendar.d.ts","sourceRoot":"","sources":["../src/AttendanceCalendar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAI7C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,YAAY,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACxC,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAuCF,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,IAAI,EACJ,YAAY,EACZ,cAAc,EACd,WAAW,EACX,cAAqB,EACrB,kBAAyB,EACzB,SAAc,EAEd,aAAkB,EAClB,oBAAyB,EACzB,mBAAwB,EACxB,yBAA8B,EAC9B,sBAA2B,EAC3B,mBAAwB,EACxB,kBAAuB,GACxB,EAAE,aAAa,2CAkNf"}
@@ -0,0 +1,3 @@
1
+ export { default as AttendanceCalendar, cn } from "./AttendanceCalendar";
2
+ export type { MonthView, AttendanceData, CalendarProps, } from "./AttendanceCalendar";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AACzE,YAAY,EACV,SAAS,EACT,cAAc,EACd,aAAa,GACd,MAAM,sBAAsB,CAAC"}