-
Notifications
You must be signed in to change notification settings - Fork 21
[PROD RELEASE] - Fixes & Updates #1476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8935e60
c512bb3
9030c30
87cb149
b1a463c
f52a0ff
9ff2bf7
ef6c7ae
05c5e3f
32f20a7
58dee42
c950f6d
ef6a97c
00049f5
83ee9dd
e1d9992
aef27e3
9f4035a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,6 +111,7 @@ | |
| } | ||
|
|
||
| .cell { | ||
| min-height: 72px; | ||
| min-height: 60px; | ||
| padding: 6px; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,7 +80,6 @@ | |
| } | ||
|
|
||
| .userItem { | ||
| width: 100%; | ||
| border-radius: 8px; | ||
| padding: 8px 10px; | ||
| font-weight: 700; | ||
|
|
@@ -129,16 +128,16 @@ | |
|
|
||
| @media (max-width: 768px) { | ||
| .teamCalendar { | ||
| padding: 12px; | ||
| padding: 5px; | ||
| } | ||
|
|
||
| .grid { | ||
| gap: 8px; | ||
| gap: 6px; | ||
| } | ||
|
|
||
| .cell { | ||
| min-height: 96px; | ||
| padding: 10px; | ||
| min-height: 60px; | ||
| padding: 6px; | ||
| } | ||
|
|
||
| .userItem { | ||
|
|
@@ -148,4 +147,89 @@ | |
| .dateNumber { | ||
| font-size: 15px; | ||
| } | ||
|
|
||
| .cellButton { | ||
| cursor: pointer; | ||
| } | ||
| } | ||
|
|
||
| .cellButton { | ||
| all: unset; | ||
| display: flex; | ||
| flex-direction: column; | ||
| width: 100%; | ||
| height: 100%; | ||
| gap: 8px; | ||
| cursor: default; | ||
| } | ||
|
|
||
|
|
||
| .countBadge { | ||
| align-self: center; | ||
| font-size: 12px; | ||
| font-weight: 800; | ||
| padding: 4px 6px; | ||
| border-radius: 999px; | ||
| background: #acaeb3; | ||
| color: #ffffff; | ||
| line-height: 1; | ||
| } | ||
|
|
||
| .modalRoot { | ||
| position: fixed; | ||
| inset: 0; | ||
| z-index: 1000; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| } | ||
|
|
||
| .backdrop { | ||
| position: absolute; | ||
| inset: 0; | ||
| background: var(--text-secondary); | ||
| } | ||
|
|
||
| .popover { | ||
| position: relative; | ||
| z-index: 1; | ||
|
|
||
| width: calc(100vw - 32px); | ||
| max-width: 420px; | ||
| max-height: 70vh; | ||
| overflow-y: auto; | ||
|
|
||
| background: #fff; | ||
| border: 1px solid #e5e7eb; | ||
| border-radius: 16px; | ||
| box-shadow: 0 24px 64px $tc-black; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [❗❗ |
||
| } | ||
|
|
||
| .popoverHeader { | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: space-between; | ||
| padding: 12px 14px; | ||
| border-bottom: 1px solid #e5e7eb; | ||
| } | ||
|
|
||
| .popoverTitle { | ||
| font-weight: 800; | ||
| color: #111827; | ||
| } | ||
|
|
||
| .closeBtn { | ||
| all: unset; | ||
| cursor: pointer; | ||
| font-size: 18px; | ||
| line-height: 1; | ||
| padding: 6px 8px; | ||
| border-radius: 8px; | ||
| } | ||
|
|
||
| .popoverBody { | ||
| padding: 12px 14px; | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: 8px; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| import { isWeekend } from 'date-fns' | ||
| import { FC, useMemo } from 'react' | ||
| import { format, isWeekend } from 'date-fns' | ||
| import { FC, useCallback, useMemo, useState } from 'react' | ||
| import classNames from 'classnames' | ||
|
|
||
| import { LoadingSpinner } from '~/libs/ui' | ||
| import { useCheckIsMobile } from '~/libs/shared' | ||
|
|
||
| import { LeaveStatus, TeamLeaveDate } from '../../models' | ||
| import { getDateKey, getMonthDates } from '../../utils' | ||
|
|
@@ -60,6 +61,25 @@ export const TeamCalendar: FC<TeamCalendarProps> = (props: TeamCalendarProps) => | |
| const currentDate = props.currentDate | ||
| const isLoading = props.isLoading | ||
| const teamLeaveDates = props.teamLeaveDates | ||
| const [openDateKey, setOpenDateKey] = useState<string | undefined>(undefined) | ||
|
|
||
| const isMobile: boolean = useCheckIsMobile() | ||
|
|
||
| const closePopover = useCallback(() => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| setOpenDateKey(undefined) | ||
| }, []) | ||
|
|
||
| const handleCellClick = useCallback( | ||
| (e: React.MouseEvent<HTMLButtonElement>) => { | ||
| if (!isMobile) return | ||
|
|
||
| const dateKey = e.currentTarget.dataset.dateKey | ||
| if (!dateKey) return | ||
|
|
||
| setOpenDateKey(prev => (prev === dateKey ? undefined : dateKey)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| }, | ||
| [isMobile], | ||
| ) | ||
|
|
||
| const monthDates = useMemo( | ||
| () => getMonthDates(currentDate.getFullYear(), currentDate.getMonth()), | ||
|
|
@@ -116,44 +136,126 @@ export const TeamCalendar: FC<TeamCalendarProps> = (props: TeamCalendarProps) => | |
| const overflowCount = sortedUsers.length - displayedUsers.length | ||
| const weekendClass = isWeekend(date) ? styles.weekend : undefined | ||
|
|
||
| // Mobile popover open/close | ||
| const isOpen = openDateKey === dateKey | ||
| const leaveCount = sortedUsers.length | ||
|
|
||
| return ( | ||
| <div | ||
| key={dateKey} | ||
| className={classNames(styles.cell, weekendClass, { | ||
| [styles.loading]: isLoading, | ||
| [styles.hasLeave]: leaveCount > 0, | ||
| })} | ||
| > | ||
| <span className={styles.dateNumber}>{date.getDate()}</span> | ||
| <div className={styles.userList}> | ||
| {displayedUsers.length > 0 | ||
| && displayedUsers.map((user, userIndex) => { | ||
| const isHolidayStatus = user.status === LeaveStatus.WIPRO_HOLIDAY | ||
| || user.status === LeaveStatus.HOLIDAY | ||
| {/* Whole cell tappable on mobile */} | ||
| <button | ||
| type='button' | ||
| className={styles.cellButton} | ||
| disabled={isLoading} | ||
| onClick={handleCellClick} | ||
| data-date-key={dateKey} | ||
| aria-haspopup='dialog' | ||
| aria-expanded={isMobile ? isOpen : undefined} | ||
| aria-label={`Open leave list for ${dateKey}`} | ||
| > | ||
| <span className={styles.dateNumber}>{date.getDate()}</span> | ||
|
|
||
| {/* MOBILE: only show count badge */} | ||
| {isMobile && leaveCount > 0 && ( | ||
| <span className={styles.countBadge}>{leaveCount}</span> | ||
| )} | ||
|
|
||
| {/* DESKTOP: show list in the cell (your existing UI) */} | ||
| {!isMobile && ( | ||
| <div className={styles.userList}> | ||
| {displayedUsers.length > 0 | ||
| && displayedUsers.map((user, userIndex) => { | ||
| const isHolidayStatus | ||
| = user.status === LeaveStatus.WIPRO_HOLIDAY | ||
| || user.status === LeaveStatus.HOLIDAY | ||
|
|
||
| return ( | ||
| <div | ||
| key={`${dateKey}-${user.userId}-${userIndex.toString()}`} | ||
| className={classNames( | ||
| styles.userItem, | ||
| isHolidayStatus | ||
| ? styles.userHoliday | ||
| : styles.userLeave, | ||
| )} | ||
| > | ||
| {getUserDisplayName(user)} | ||
| </div> | ||
| ) | ||
| })} | ||
| {overflowCount > 0 && ( | ||
| <div className={styles.overflowIndicator}> | ||
| {`+${overflowCount} more`} | ||
| </div> | ||
| )} | ||
| </div> | ||
| )} | ||
| </button> | ||
| </div> | ||
| ) | ||
| })} | ||
| </div> | ||
|
|
||
| {isMobile && openDateKey && (() => { | ||
| const selectedDate = paddedDates.find(d => d && getDateKey(d) === openDateKey) | ||
| if (!selectedDate) return undefined | ||
|
|
||
| const selectedEntry = teamLeaveDates.find(item => item.date === openDateKey) | ||
| const selectedUsers = [...(selectedEntry?.usersOnLeave ?? [])].sort(compareUsersByName) | ||
|
|
||
| return ( | ||
| <div className={styles.modalRoot}> | ||
| <div className={styles.backdrop} onClick={closePopover} /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [💡 |
||
|
|
||
| <div className={styles.popover} role='dialog' aria-label='Users on leave'> | ||
| <div className={styles.popoverHeader}> | ||
| <div className={styles.popoverTitle}> | ||
| {format(selectedDate, 'EEE, dd MMM yyyy')} | ||
| </div> | ||
|
|
||
| <button | ||
| type='button' | ||
| className={styles.closeBtn} | ||
| onClick={closePopover} | ||
| aria-label='Close' | ||
| > | ||
| ✕ | ||
| </button> | ||
| </div> | ||
|
|
||
| <div className={styles.popoverBody}> | ||
| {selectedUsers.length === 0 ? ( | ||
| <div className={styles.emptyState}>No leave</div> | ||
| ) : ( | ||
| selectedUsers.map((user, idx) => { | ||
| const isHolidayStatus | ||
| = user.status === LeaveStatus.WIPRO_HOLIDAY | ||
| || user.status === LeaveStatus.HOLIDAY | ||
|
|
||
| return ( | ||
| <div | ||
| key={`${dateKey}-${user.userId}-${userIndex.toString()}`} | ||
| key={`${openDateKey}-${user.userId}-${idx.toString()}`} | ||
| className={classNames( | ||
| styles.userItem, | ||
| isHolidayStatus | ||
| ? styles.userHoliday | ||
| : styles.userLeave, | ||
| isHolidayStatus ? styles.userHoliday : styles.userLeave, | ||
| )} | ||
| > | ||
| {getUserDisplayName(user)} | ||
| </div> | ||
| ) | ||
| })} | ||
| {overflowCount > 0 && ( | ||
| <div className={styles.overflowIndicator}> | ||
| {`+${overflowCount} more`} | ||
| </div> | ||
| }) | ||
| )} | ||
| </div> | ||
| </div> | ||
| ) | ||
| })} | ||
| </div> | ||
| </div> | ||
| ) | ||
| })()} | ||
|
|
||
| {isLoading && ( | ||
| <div className={styles.loadingOverlay}> | ||
|
|
@@ -162,6 +264,7 @@ export const TeamCalendar: FC<TeamCalendarProps> = (props: TeamCalendarProps) => | |
| )} | ||
| </div> | ||
| ) | ||
|
|
||
| } | ||
|
|
||
| export default TeamCalendar | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[⚠️
correctness]The background color for
.backdropuses a CSS variable--text-secondary. Ensure that this variable is defined and has the intended value, as missing or incorrect variable definitions can lead to unexpected styling.