diff --git a/src/EntityCard/EntityCard.styled.ts b/src/EntityCard/EntityCard.styled.ts index 73d76c2..fefc657 100644 --- a/src/EntityCard/EntityCard.styled.ts +++ b/src/EntityCard/EntityCard.styled.ts @@ -472,6 +472,14 @@ export const Tag = styled.span` } } + /* when title is clickable */ + &.title.clickable { + &:hover { + background-color: var(--md-sys-color-surface-container-highest-hover); + cursor: pointer; + } + } + /* user image overrides */ &.users { padding: 0 1px; diff --git a/src/EntityCard/EntityCard.tsx b/src/EntityCard/EntityCard.tsx index 080706b..35e5b86 100644 --- a/src/EntityCard/EntityCard.tsx +++ b/src/EntityCard/EntityCard.tsx @@ -89,12 +89,20 @@ export interface EntityCardProps extends React.HTMLAttributes { onPriorityChange?: (priority: string[]) => void // other functions onActivate?: () => void + onTitleClick?: (e: MouseEvent) => void pt?: { thumbnail?: HTMLAttributes image?: HTMLAttributes assigneeSelect?: Partial statusSelect?: Partial prioritySelect?: Partial + title?: HTMLAttributes + topRow?: HTMLAttributes + playableTag?: HTMLAttributes + bottomRow?: HTMLAttributes + usersTag?: HTMLAttributes + statusTag?: HTMLAttributes + priorityTag?: HTMLAttributes } } @@ -137,6 +145,7 @@ export const EntityCard = forwardRef( onStatusChange, onPriorityChange, onActivate, + onTitleClick, pt = {}, ...props }, @@ -223,6 +232,15 @@ export const EntityCard = forwardRef( }) }, [bottomRowRef.current, status]) + const handleTitleClick = (e: MouseEvent) => { + if (!onTitleClick) return + + // prevent the card from being clicked + e.stopPropagation() + // call the onTitleClick function + onTitleClick(e) + } + // check thumbnail image const [isThumbnailLoading, isThumbnailError] = useImageLoader(imageUrl) // check first and second user images @@ -325,10 +343,14 @@ export const EntityCard = forwardRef( /> )} {/* TOP ROW */} - + {/* top left */} {(!isLoading || loadingSections.includes('title')) && ( - + {isLoading ? ( 'loading card...' ) : ( @@ -342,7 +364,7 @@ export const EntityCard = forwardRef( {/* top right */} {isPlayable && ( - + )} @@ -354,6 +376,7 @@ export const EntityCard = forwardRef( ['hide-priority']: hidePriority, })} ref={bottomRowRef} + {...pt.bottomRow} > {atLeastOneEditable && ( <> @@ -410,6 +433,7 @@ export const EntityCard = forwardRef( })} onMouseEnter={(e) => editOnHover && handleEditableHover(e, 'assignees')} onClick={(e) => handleEditableHover(e, 'assignees')} + {...pt.usersTag} > {users?.length ? ( 2 })}> @@ -451,6 +475,7 @@ export const EntityCard = forwardRef( })} onMouseEnter={(e) => editOnHover && handleEditableHover(e, 'status')} onClick={(e) => handleEditableHover(e, 'status')} + {...pt.statusTag} > {status?.icon && ( ( className={clsx('tag priority', { editable: priorityEditable, isLoading })} onMouseEnter={(e) => editOnHover && handleEditableHover(e, 'priority')} onClick={(e) => handleEditableHover(e, 'priority')} + {...pt.priorityTag} > {priority?.icon && }