From e8252eca862e8ea399da32345252a1120dbe0589 Mon Sep 17 00:00:00 2001 From: Abhishek Bindra Date: Thu, 7 Mar 2024 16:56:19 +0530 Subject: [PATCH] Chore: Only show 2 relations in ActivityTargetChips (#4325) * limits activity target relations count to 2 * Remove dynamic width calculation --------- Co-authored-by: Abhishek Bindra Co-authored-by: Thomas Trompette --- .../components/ActivityTargetChips.tsx | 80 ++++++++++++++++--- 1 file changed, 71 insertions(+), 9 deletions(-) diff --git a/packages/twenty-front/src/modules/activities/components/ActivityTargetChips.tsx b/packages/twenty-front/src/modules/activities/components/ActivityTargetChips.tsx index c88d5f5e6..d5d37739c 100644 --- a/packages/twenty-front/src/modules/activities/components/ActivityTargetChips.tsx +++ b/packages/twenty-front/src/modules/activities/components/ActivityTargetChips.tsx @@ -1,7 +1,14 @@ +import { useMemo } from 'react'; import styled from '@emotion/styled'; +import { v4 } from 'uuid'; import { ActivityTargetWithTargetRecord } from '@/activities/types/ActivityTargetObject'; import { RecordChip } from '@/object-record/components/RecordChip'; +import { Chip, ChipVariant } from '@/ui/display/chip/components/Chip'; +import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; +import { RGBA } from '@/ui/theme/constants/Rgba'; + +const MAX_RECORD_CHIPS_DISPLAY = 2; const StyledContainer = styled.div` display: flex; @@ -9,22 +16,77 @@ const StyledContainer = styled.div` gap: ${({ theme }) => theme.spacing(1)}; `; +const StyledRelationsListContainer = styled(StyledContainer)` + padding: ${({ theme }) => theme.spacing(2)}; + border-radius: ${({ theme }) => theme.spacing(1)}; + background-color: ${({ theme }) => RGBA(theme.color.gray10, 0.8)}; + box-shadow: '0px 2px 4px ${({ theme }) => + theme.boxShadow.light}, 2px 4px 16px ${({ theme }) => + theme.boxShadow.strong}'; + backdrop-filter: ${({ theme }) => theme.blur.strong}; +`; + +const showMoreRelationsHandler = (event?: React.MouseEvent) => { + event?.preventDefault(); + event?.stopPropagation(); +}; + export const ActivityTargetChips = ({ activityTargetObjectRecords, }: { activityTargetObjectRecords: ActivityTargetWithTargetRecord[]; }) => { + const dropdownId = useMemo(() => `multiple-relations-dropdown-${v4()}`, []); + return ( - {activityTargetObjectRecords?.map((activityTargetObjectRecord) => ( - - ))} + {activityTargetObjectRecords + ?.slice(0, MAX_RECORD_CHIPS_DISPLAY) + .map((activityTargetObjectRecord) => ( + + ))} + + {activityTargetObjectRecords.length > MAX_RECORD_CHIPS_DISPLAY && ( +
+ + } + dropdownOffset={{ x: 0, y: -20 }} + dropdownComponents={ + + {activityTargetObjectRecords.map( + (activityTargetObjectRecord) => ( + + ), + )} + + } + /> +
+ )}
); };