@campxdev/react-blueprint 2.2.2 → 2.2.4

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.
Files changed (27) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/cjs/types/src/components/Navigation/Calendar/Calendar.d.ts +3 -0
  3. package/dist/cjs/types/src/components/Navigation/Calendar/index.d.ts +3 -0
  4. package/dist/cjs/types/src/components/Navigation/Calendar/styles.d.ts +9 -0
  5. package/dist/cjs/types/src/components/Navigation/Calendar/types.d.ts +90 -0
  6. package/dist/cjs/types/src/components/Navigation/Calendar/utils.d.ts +55 -0
  7. package/dist/cjs/types/src/components/Navigation/export.d.ts +2 -0
  8. package/dist/cjs/types/src/stories/Navigation/Calendar.stories.d.ts +10 -0
  9. package/dist/esm/index.js +2 -2
  10. package/dist/esm/types/src/components/Navigation/Calendar/Calendar.d.ts +3 -0
  11. package/dist/esm/types/src/components/Navigation/Calendar/index.d.ts +3 -0
  12. package/dist/esm/types/src/components/Navigation/Calendar/styles.d.ts +9 -0
  13. package/dist/esm/types/src/components/Navigation/Calendar/types.d.ts +90 -0
  14. package/dist/esm/types/src/components/Navigation/Calendar/utils.d.ts +55 -0
  15. package/dist/esm/types/src/components/Navigation/export.d.ts +2 -0
  16. package/dist/esm/types/src/stories/Navigation/Calendar.stories.d.ts +10 -0
  17. package/dist/index.d.ts +151 -4
  18. package/package.json +6 -1
  19. package/src/components/Navigation/Calendar/Calendar.tsx +243 -0
  20. package/src/components/Navigation/Calendar/README.md +308 -0
  21. package/src/components/Navigation/Calendar/index.ts +3 -0
  22. package/src/components/Navigation/Calendar/styles.tsx +222 -0
  23. package/src/components/Navigation/Calendar/types.ts +120 -0
  24. package/src/components/Navigation/Calendar/utils.ts +265 -0
  25. package/src/components/Navigation/TabsContainer/TabsContainer.tsx +4 -4
  26. package/src/components/Navigation/export.ts +2 -0
  27. package/src/stories/Navigation/Calendar.stories.tsx +475 -0
@@ -0,0 +1,475 @@
1
+ import {
2
+ Box,
3
+ Button,
4
+ Dialog,
5
+ DialogActions,
6
+ DialogContent,
7
+ DialogTitle,
8
+ Link,
9
+ Typography,
10
+ } from '@mui/material';
11
+ import { Meta, StoryObj } from '@storybook/react/*';
12
+ import { addDays, format, startOfWeek } from 'date-fns';
13
+ import { useState } from 'react';
14
+ import { Calendar } from '../../components/Navigation/Calendar/Calendar';
15
+ import {
16
+ CalendarEvent,
17
+ CalendarEventClickInfo,
18
+ } from '../../components/Navigation/Calendar/types';
19
+
20
+ // Generate sample events
21
+ const generateSampleEvents = (): CalendarEvent[] => {
22
+ const today = new Date();
23
+
24
+ return [
25
+ {
26
+ id: '1',
27
+ title: 'Team Meeting',
28
+ start: format(addDays(today, 1), "yyyy-MM-dd'T'09:00:00"),
29
+ end: format(addDays(today, 1), "yyyy-MM-dd'T'10:00:00"),
30
+ backgroundColor: '#1976d2',
31
+ },
32
+ {
33
+ id: '2',
34
+ title: 'Project Presentation',
35
+ start: format(addDays(today, 3), "yyyy-MM-dd'T'14:00:00"),
36
+ end: format(addDays(today, 3), "yyyy-MM-dd'T'16:00:00"),
37
+ backgroundColor: '#d32f2f',
38
+ },
39
+ {
40
+ id: '3',
41
+ title: 'Code Review',
42
+ start: format(addDays(today, 5), "yyyy-MM-dd'T'11:00:00"),
43
+ end: format(addDays(today, 5), "yyyy-MM-dd'T'12:00:00"),
44
+ backgroundColor: '#388e3c',
45
+ },
46
+ {
47
+ id: '4',
48
+ title: 'All Day Event',
49
+ start: format(addDays(today, 7), 'yyyy-MM-dd'),
50
+ allDay: true,
51
+ backgroundColor: '#f57c00',
52
+ },
53
+ ];
54
+ };
55
+
56
+ // Generate university class schedule
57
+ const generateUniversitySchedule = (): CalendarEvent[] => {
58
+ const today = new Date();
59
+ const weekStart = startOfWeek(today, { weekStartsOn: 1 }); // Start on Monday
60
+
61
+ const classes = [
62
+ // Monday
63
+ {
64
+ id: 'cs101-mon',
65
+ title: 'Computer Science 101',
66
+ start: format(weekStart, "yyyy-MM-dd'T'09:00:00"),
67
+ end: format(weekStart, "yyyy-MM-dd'T'10:30:00"),
68
+ backgroundColor: '#1976d2',
69
+ extendedProps: {
70
+ instructor: 'Dr. Sarah Johnson',
71
+ room: 'Room 204, Computer Lab',
72
+ meetingLink: 'https://teams.microsoft.com/l/meetup-join/cs101-lecture',
73
+ courseCode: 'CS 101',
74
+ type: 'Lecture',
75
+ description: 'Introduction to Programming Concepts',
76
+ },
77
+ },
78
+ {
79
+ id: 'math201-mon',
80
+ title: 'Calculus II',
81
+ start: format(weekStart, "yyyy-MM-dd'T'11:00:00"),
82
+ end: format(weekStart, "yyyy-MM-dd'T'12:30:00"),
83
+ backgroundColor: '#388e3c',
84
+ extendedProps: {
85
+ instructor: 'Prof. Michael Chen',
86
+ room: 'Mathematics Building, Room 301',
87
+ meetingLink: 'https://zoom.us/j/123456789?pwd=calculus2',
88
+ courseCode: 'MATH 201',
89
+ type: 'Lecture',
90
+ description: 'Advanced Calculus and Integration Techniques',
91
+ },
92
+ },
93
+ {
94
+ id: 'eng102-mon',
95
+ title: 'English Literature',
96
+ start: format(weekStart, "yyyy-MM-dd'T'14:00:00"),
97
+ end: format(weekStart, "yyyy-MM-dd'T'15:30:00"),
98
+ backgroundColor: '#7b1fa2',
99
+ extendedProps: {
100
+ instructor: 'Dr. Emily Watson',
101
+ room: 'Humanities Building, Room 105',
102
+ meetingLink:
103
+ 'https://teams.microsoft.com/l/meetup-join/eng102-discussion',
104
+ courseCode: 'ENG 102',
105
+ type: 'Seminar',
106
+ description: 'Modern American Literature Analysis',
107
+ },
108
+ },
109
+
110
+ // Tuesday
111
+ {
112
+ id: 'cs101-lab-tue',
113
+ title: 'CS 101 Lab',
114
+ start: format(addDays(weekStart, 1), "yyyy-MM-dd'T'10:00:00"),
115
+ end: format(addDays(weekStart, 1), "yyyy-MM-dd'T'12:00:00"),
116
+ backgroundColor: '#1565c0',
117
+ extendedProps: {
118
+ instructor: 'TA: Alex Rodriguez',
119
+ room: 'Computer Lab B, Room 210',
120
+ meetingLink:
121
+ 'https://teams.microsoft.com/l/meetup-join/cs101-lab-session',
122
+ courseCode: 'CS 101',
123
+ type: 'Lab',
124
+ description: 'Hands-on Programming Practice',
125
+ },
126
+ },
127
+ {
128
+ id: 'phys151-tue',
129
+ title: 'Physics I',
130
+ start: format(addDays(weekStart, 1), "yyyy-MM-dd'T'13:00:00"),
131
+ end: format(addDays(weekStart, 1), "yyyy-MM-dd'T'14:30:00"),
132
+ backgroundColor: '#f57c00',
133
+ extendedProps: {
134
+ instructor: 'Dr. Robert Kim',
135
+ room: 'Science Building, Room 401',
136
+ meetingLink: 'https://zoom.us/j/987654321?pwd=physics1',
137
+ courseCode: 'PHYS 151',
138
+ type: 'Lecture',
139
+ description: 'Classical Mechanics and Thermodynamics',
140
+ },
141
+ },
142
+
143
+ // Wednesday
144
+ {
145
+ id: 'cs101-wed',
146
+ title: 'Computer Science 101',
147
+ start: format(addDays(weekStart, 2), "yyyy-MM-dd'T'09:00:00"),
148
+ end: format(addDays(weekStart, 2), "yyyy-MM-dd'T'10:30:00"),
149
+ backgroundColor: '#1976d2',
150
+ extendedProps: {
151
+ instructor: 'Dr. Sarah Johnson',
152
+ room: 'Room 204, Computer Lab',
153
+ meetingLink: 'https://teams.microsoft.com/l/meetup-join/cs101-lecture',
154
+ courseCode: 'CS 101',
155
+ type: 'Lecture',
156
+ description: 'Data Structures and Algorithms',
157
+ },
158
+ },
159
+ {
160
+ id: 'math201-wed',
161
+ title: 'Calculus II',
162
+ start: format(addDays(weekStart, 2), "yyyy-MM-dd'T'11:00:00"),
163
+ end: format(addDays(weekStart, 2), "yyyy-MM-dd'T'12:30:00"),
164
+ backgroundColor: '#388e3c',
165
+ extendedProps: {
166
+ instructor: 'Prof. Michael Chen',
167
+ room: 'Mathematics Building, Room 301',
168
+ meetingLink: 'https://zoom.us/j/123456789?pwd=calculus2',
169
+ courseCode: 'MATH 201',
170
+ type: 'Lecture',
171
+ description: 'Differential Equations',
172
+ },
173
+ },
174
+
175
+ // Thursday
176
+ {
177
+ id: 'phys151-lab-thu',
178
+ title: 'Physics I Lab',
179
+ start: format(addDays(weekStart, 3), "yyyy-MM-dd'T'14:00:00"),
180
+ end: format(addDays(weekStart, 3), "yyyy-MM-dd'T'17:00:00"),
181
+ backgroundColor: '#ef6c00',
182
+ extendedProps: {
183
+ instructor: 'TA: Maria Garcia',
184
+ room: 'Physics Lab, Room 502',
185
+ meetingLink: 'https://teams.microsoft.com/l/meetup-join/phys151-lab',
186
+ courseCode: 'PHYS 151',
187
+ type: 'Lab',
188
+ description: 'Experimental Physics and Data Analysis',
189
+ },
190
+ },
191
+ {
192
+ id: 'eng102-thu',
193
+ title: 'English Literature',
194
+ start: format(addDays(weekStart, 3), "yyyy-MM-dd'T'14:00:00"),
195
+ end: format(addDays(weekStart, 3), "yyyy-MM-dd'T'15:30:00"),
196
+ backgroundColor: '#7b1fa2',
197
+ extendedProps: {
198
+ instructor: 'Dr. Emily Watson',
199
+ room: 'Humanities Building, Room 105',
200
+ meetingLink:
201
+ 'https://teams.microsoft.com/l/meetup-join/eng102-discussion',
202
+ courseCode: 'ENG 102',
203
+ type: 'Discussion',
204
+ description: 'Student Presentations and Group Analysis',
205
+ },
206
+ },
207
+
208
+ // Friday
209
+ {
210
+ id: 'cs101-fri',
211
+ title: 'Computer Science 101',
212
+ start: format(addDays(weekStart, 4), "yyyy-MM-dd'T'09:00:00"),
213
+ end: format(addDays(weekStart, 4), "yyyy-MM-dd'T'10:30:00"),
214
+ backgroundColor: '#1976d2',
215
+ extendedProps: {
216
+ instructor: 'Dr. Sarah Johnson',
217
+ room: 'Room 204, Computer Lab',
218
+ meetingLink: 'https://teams.microsoft.com/l/meetup-join/cs101-lecture',
219
+ courseCode: 'CS 101',
220
+ type: 'Lecture',
221
+ description: 'Project Work and Code Review',
222
+ },
223
+ },
224
+ {
225
+ id: 'math201-fri',
226
+ title: 'Calculus II',
227
+ start: format(addDays(weekStart, 4), "yyyy-MM-dd'T'11:00:00"),
228
+ end: format(addDays(weekStart, 4), "yyyy-MM-dd'T'12:30:00"),
229
+ backgroundColor: '#388e3c',
230
+ extendedProps: {
231
+ instructor: 'Prof. Michael Chen',
232
+ room: 'Mathematics Building, Room 301',
233
+ meetingLink: 'https://zoom.us/j/123456789?pwd=calculus2',
234
+ courseCode: 'MATH 201',
235
+ type: 'Lecture',
236
+ description: 'Problem Solving Session',
237
+ },
238
+ },
239
+ ];
240
+
241
+ return classes;
242
+ };
243
+
244
+ const meta: Meta<typeof Calendar> = {
245
+ title: 'Navigation/Calendar',
246
+ component: Calendar,
247
+ parameters: {
248
+ layout: 'fullscreen',
249
+ docs: {
250
+ description: {
251
+ component:
252
+ 'A feature-rich calendar component built on FullCalendar with theme integration.',
253
+ },
254
+ },
255
+ },
256
+ argTypes: {
257
+ initialView: {
258
+ control: 'select',
259
+ options: ['dayGridMonth', 'timeGridWeek', 'timeGridDay'],
260
+ description: 'The initial view to display when the calendar loads',
261
+ },
262
+ events: {
263
+ description: 'Array of calendar events to display',
264
+ },
265
+ headerToolbar: {
266
+ description: 'Configuration for the calendar header toolbar',
267
+ },
268
+ height: {
269
+ control: 'text',
270
+ description: 'Height of the calendar container',
271
+ },
272
+ onEventClick: {
273
+ description: 'Callback function when an event is clicked',
274
+ },
275
+ onDateSelect: {
276
+ description: 'Callback function when dates are selected',
277
+ },
278
+ onEventDrop: {
279
+ description:
280
+ 'Callback function when an event is dragged to a new time/date',
281
+ },
282
+ onEventResize: {
283
+ description: 'Callback function when an event is resized',
284
+ },
285
+ },
286
+ };
287
+
288
+ export default meta;
289
+ type Story = StoryObj<typeof Calendar>;
290
+
291
+ // Default calendar view
292
+ export const Default: Story = {
293
+ args: {
294
+ events: generateUniversitySchedule(),
295
+ initialView: 'dayGridMonth',
296
+ height: 'auto',
297
+ },
298
+ };
299
+
300
+ // Month view with interactions
301
+ export const MonthView: Story = {
302
+ args: {
303
+ events: generateUniversitySchedule(),
304
+ initialView: 'dayGridMonth',
305
+ height: 'auto',
306
+ selectable: true,
307
+ editable: true,
308
+ onEventClick: (info) => {
309
+ console.log('Event clicked:', info.event.title);
310
+ },
311
+ onDateSelect: (info) => {
312
+ console.log('Date selected:', info.start, info.end);
313
+ },
314
+ },
315
+ };
316
+
317
+ // Week view
318
+ export const WeekView: Story = {
319
+ args: {
320
+ events: generateUniversitySchedule(),
321
+ initialView: 'timeGridWeek',
322
+ height: 'auto',
323
+ selectable: true,
324
+ editable: true,
325
+ },
326
+ };
327
+
328
+ // Day view
329
+ export const DayView: Story = {
330
+ args: {
331
+ events: generateUniversitySchedule(),
332
+ initialView: 'timeGridDay',
333
+ height: 'auto',
334
+ selectable: true,
335
+ editable: true,
336
+ },
337
+ };
338
+
339
+ // Student Calendar with Class Details Modal
340
+ export const StudentCalendar: Story = {
341
+ render: (args) => {
342
+ const [selectedClass, setSelectedClass] = useState<any>(null);
343
+ const [isModalOpen, setIsModalOpen] = useState(false);
344
+
345
+ const handleEventClick = (eventInfo: CalendarEventClickInfo) => {
346
+ // Prevent event bubbling and potential DOM issues
347
+ if (eventInfo.jsEvent) {
348
+ eventInfo.jsEvent.preventDefault();
349
+ eventInfo.jsEvent.stopPropagation();
350
+ }
351
+
352
+ setSelectedClass(eventInfo.event);
353
+ setIsModalOpen(true);
354
+ };
355
+
356
+ const handleCloseModal = () => {
357
+ setIsModalOpen(false);
358
+ setSelectedClass(null);
359
+ };
360
+
361
+ const handleJoinClass = () => {
362
+ const meetingLink = selectedClass?.extendedProps?.meetingLink;
363
+ if (meetingLink) {
364
+ window.open(meetingLink, '_blank');
365
+ }
366
+ };
367
+
368
+ return (
369
+ <>
370
+ <Calendar
371
+ {...args}
372
+ events={generateUniversitySchedule()}
373
+ onEventClick={handleEventClick}
374
+ initialView="timeGridWeek"
375
+ height="700px"
376
+ headerToolbar={{
377
+ left: 'prev,next today',
378
+ center: 'title',
379
+ right: 'timeGridWeek,timeGridDay',
380
+ }}
381
+ />
382
+
383
+ <Dialog
384
+ open={isModalOpen}
385
+ onClose={handleCloseModal}
386
+ maxWidth="md"
387
+ fullWidth
388
+ >
389
+ <DialogTitle>
390
+ <Typography variant="h5" component="div">
391
+ {selectedClass?.title}
392
+ </Typography>
393
+ <Typography variant="subtitle1" color="textSecondary">
394
+ {selectedClass?.extendedProps?.courseCode} -{' '}
395
+ {selectedClass?.extendedProps?.type}
396
+ </Typography>
397
+ </DialogTitle>
398
+
399
+ <DialogContent>
400
+ <Box sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
401
+ <Typography variant="body1">
402
+ <strong>Description:</strong>{' '}
403
+ {selectedClass?.extendedProps?.description}
404
+ </Typography>
405
+
406
+ <Typography variant="body1">
407
+ <strong>Instructor:</strong>{' '}
408
+ {selectedClass?.extendedProps?.instructor}
409
+ </Typography>
410
+
411
+ <Typography variant="body1">
412
+ <strong>Location:</strong> {selectedClass?.extendedProps?.room}
413
+ </Typography>
414
+
415
+ <Typography variant="body1">
416
+ <strong>Time:</strong>{' '}
417
+ {selectedClass?.start &&
418
+ format(new Date(selectedClass.start), 'h:mm a')}{' '}
419
+ -{' '}
420
+ {selectedClass?.end &&
421
+ format(new Date(selectedClass.end), 'h:mm a')}
422
+ </Typography>
423
+
424
+ {selectedClass?.extendedProps?.meetingLink && (
425
+ <Box
426
+ sx={{
427
+ mt: 2,
428
+ p: 2,
429
+ backgroundColor: 'action.hover',
430
+ borderRadius: 1,
431
+ }}
432
+ >
433
+ <Typography variant="body1" sx={{ mb: 1 }}>
434
+ <strong>Online Meeting:</strong>
435
+ </Typography>
436
+ <Link
437
+ href={selectedClass.extendedProps.meetingLink}
438
+ target="_blank"
439
+ rel="noopener noreferrer"
440
+ color="primary"
441
+ >
442
+ {selectedClass.extendedProps.meetingLink}
443
+ </Link>
444
+ </Box>
445
+ )}
446
+ </Box>
447
+ </DialogContent>
448
+
449
+ <DialogActions>
450
+ <Button onClick={handleCloseModal} color="secondary">
451
+ Close
452
+ </Button>
453
+ {selectedClass?.extendedProps?.meetingLink && (
454
+ <Button
455
+ onClick={handleJoinClass}
456
+ variant="contained"
457
+ color="primary"
458
+ >
459
+ Join Class
460
+ </Button>
461
+ )}
462
+ </DialogActions>
463
+ </Dialog>
464
+ </>
465
+ );
466
+ },
467
+ parameters: {
468
+ docs: {
469
+ description: {
470
+ story:
471
+ 'A realistic student calendar showing university class schedule with interactive class details modal and meeting links.',
472
+ },
473
+ },
474
+ },
475
+ };