The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix count avatar color + align thread preview items (#3695)
Thomas Trompette511627ccb8aa
diff --git a/packages/twenty-front/src/modules/activities/comment/CommentHeader.tsx b/packages/twenty-front/src/modules/activities/comment/CommentHeader.tsxindex a8cbb6b19b5..390851d5276 100644--- a/packages/twenty-front/src/modules/activities/comment/CommentHeader.tsx+++ b/packages/twenty-front/src/modules/activities/comment/CommentHeader.tsx@@ -77,7 +77,7 @@ export const CommentHeader = ({ comment, actionBar }: CommentHeaderProps) => {<AvataravatarUrl={avatarUrl}size="md"- colorId={author?.id}+ entityId={author?.id}placeholder={authorName}/><StyledName>{authorName}</StyledName>diff --git a/packages/twenty-front/src/modules/activities/emails/components/EmailThreadPreview.tsx b/packages/twenty-front/src/modules/activities/emails/components/EmailThreadPreview.tsxindex 431c6ef0a03..cd3e8b08b9d 100644--- a/packages/twenty-front/src/modules/activities/emails/components/EmailThreadPreview.tsx+++ b/packages/twenty-front/src/modules/activities/emails/components/EmailThreadPreview.tsx@@ -1,6 +1,7 @@import styled from '@emotion/styled';import { CardContent } from '@/ui/layout/card/components/CardContent';+import { grayScale } from '@/ui/theme/constants/colors';import { Avatar } from '@/users/components/Avatar';import { TimelineThread } from '~/generated/graphql';import { formatToHumanReadableDate } from '~/utils';@@ -15,29 +16,17 @@ const StyledCardContent = styled(CardContent)``;const StyledHeading = styled.div<{ unread: boolean }>`- align-items: center;+ display: flex;color: ${({ theme, unread }) =>unread ? theme.font.color.primary : theme.font.color.secondary};- display: flex;font-weight: ${({ theme, unread }) =>unread ? theme.font.weight.medium : theme.font.weight.regular};- gap: ${({ theme }) => theme.spacing(1)};overflow: hidden;- width: 160px;-- :before {- background-color: ${({ theme, unread }) =>- unread ? theme.color.blue : 'transparent'};- border-radius: ${({ theme }) => theme.border.radius.rounded};- content: '';- display: block;- height: 6px;- width: 6px;- }+ width: 20%;`;const StyledParticipantsContainer = styled.div`- align-items: center;+ align-items: flex-start;display: flex;`;@@ -46,6 +35,7 @@ const StyledAvatar = styled(Avatar)``;const StyledSenderNames = styled.span`+ display: flex;margin: ${({ theme }) => theme.spacing(0, 1)};overflow: hidden;text-overflow: ellipsis;@@ -56,28 +46,29 @@ const StyledThreadCount = styled.span`color: ${({ theme }) => theme.font.color.tertiary};`;+const StyledSubjectAndBody = styled.div`+ display: flex;+ flex: 1;+ gap: ${({ theme }) => theme.spacing(2)};+ overflow: hidden;+`;+const StyledSubject = styled.span<{ unread: boolean }>`color: ${({ theme, unread }) =>unread ? theme.font.color.primary : theme.font.color.secondary};white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+ flex-shrink: 0;`;const StyledBody = styled.span`color: ${({ theme }) => theme.font.color.tertiary};- min-width: 0;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;`;-const StyledSubjectAndBody = styled.div`- display: flex;- flex: 1;- gap: ${({ theme }) => theme.spacing(2)};- overflow: hidden;- text-overflow: ellipsis;-`;-const StyledReceivedAt = styled.div`font-size: ${({ theme }) => theme.font.size.sm};font-weight: ${({ theme }) => theme.font.weight.regular};@@ -104,12 +95,13 @@ export const EmailThreadPreview = ({? `, ${thread.lastTwoParticipants?.[1]?.displayName}`: '');- const [finalDisplayedName, finalAvatarUrl] =+ const [finalDisplayedName, finalAvatarUrl, isCountIcon] =thread.participantCount > 3- ? [`${thread.participantCount}`, '']+ ? [`${thread.participantCount}`, '', true]: [thread?.lastTwoParticipants?.[1]?.displayName,thread?.lastTwoParticipants?.[1]?.avatarUrl,+ false,];return (@@ -133,6 +125,8 @@ export const EmailThreadPreview = ({avatarUrl={finalAvatarUrl}placeholder={finalDisplayedName}type="rounded"+ color={isCountIcon ? grayScale.gray50 : undefined}+ backgroundColor={isCountIcon ? grayScale.gray10 : undefined}/>)}</StyledParticipantsContainer>diff --git a/packages/twenty-front/src/modules/command-menu/components/CommandMenu.tsx b/packages/twenty-front/src/modules/command-menu/components/CommandMenu.tsxindex 1e3a4722437..68fdaac2493 100644--- a/packages/twenty-front/src/modules/command-menu/components/CommandMenu.tsx+++ b/packages/twenty-front/src/modules/command-menu/components/CommandMenu.tsx@@ -328,7 +328,7 @@ export const CommandMenu = () => {<Avatartype="rounded"avatarUrl={null}- colorId={person.id}+ entityId={person.id}placeholder={person.name.firstName +' ' +@@ -350,7 +350,7 @@ export const CommandMenu = () => {to={`object/company/${company.id}`}Icon={() => (<Avatar- colorId={company.id}+ entityId={company.id}placeholder={company.name}avatarUrl={getLogoUrlFromDomainName(company.domainName,diff --git a/packages/twenty-front/src/modules/favorites/components/Favorites.tsx b/packages/twenty-front/src/modules/favorites/components/Favorites.tsxindex c0dc98a04f5..bda4a5db6e3 100644--- a/packages/twenty-front/src/modules/favorites/components/Favorites.tsx+++ b/packages/twenty-front/src/modules/favorites/components/Favorites.tsx@@ -46,7 +46,7 @@ export const Favorites = () => {label={labelIdentifier}Icon={() => (<Avatar- colorId={recordId}+ entityId={recordId}avatarUrl={avatarUrl}type={avatarType}placeholder={labelIdentifier}diff --git a/packages/twenty-front/src/modules/object-record/relation-picker/components/MultipleObjectRecordSelectItem.tsx b/packages/twenty-front/src/modules/object-record/relation-picker/components/MultipleObjectRecordSelectItem.tsxindex e798f78ea6e..21136c4d53c 100644--- a/packages/twenty-front/src/modules/object-record/relation-picker/components/MultipleObjectRecordSelectItem.tsx+++ b/packages/twenty-front/src/modules/object-record/relation-picker/components/MultipleObjectRecordSelectItem.tsx@@ -43,7 +43,7 @@ export const MultipleObjectRecordSelectItem = ({avatar={<AvataravatarUrl={objectRecordForSelect.recordIdentifier.avatarUrl}- colorId={objectRecordForSelect.record.id}+ entityId={objectRecordForSelect.record.id}placeholder={objectRecordForSelect.recordIdentifier.name}size="md"type={diff --git a/packages/twenty-front/src/modules/object-record/relation-picker/components/SelectableMenuItemSelect.tsx b/packages/twenty-front/src/modules/object-record/relation-picker/components/SelectableMenuItemSelect.tsxindex 5d8784fab5c..00e113fd6cf 100644--- a/packages/twenty-front/src/modules/object-record/relation-picker/components/SelectableMenuItemSelect.tsx+++ b/packages/twenty-front/src/modules/object-record/relation-picker/components/SelectableMenuItemSelect.tsx@@ -40,7 +40,7 @@ export const SelectableMenuItemSelect = ({avatar={<AvataravatarUrl={entity.avatarUrl}- colorId={entity.id}+ entityId={entity.id}placeholder={entity.name}size="md"type={entity.avatarType ?? 'rounded'}diff --git a/packages/twenty-front/src/modules/object-record/select/components/MultipleRecordSelectDropdown.tsx b/packages/twenty-front/src/modules/object-record/select/components/MultipleRecordSelectDropdown.tsxindex 15914204d25..763bd595db7 100644--- a/packages/twenty-front/src/modules/object-record/select/components/MultipleRecordSelectDropdown.tsx+++ b/packages/twenty-front/src/modules/object-record/select/components/MultipleRecordSelectDropdown.tsx@@ -69,7 +69,7 @@ export const MultipleRecordSelectDropdown = ({avatar={<AvataravatarUrl={record.avatarUrl}- colorId={record.id}+ entityId={record.id}placeholder={record.name}size="md"type={record.avatarType ?? 'rounded'}diff --git a/packages/twenty-front/src/modules/ui/display/chip/components/EntityChip.tsx b/packages/twenty-front/src/modules/ui/display/chip/components/EntityChip.tsxindex e06337cc79e..9d64cba0754 100644--- a/packages/twenty-front/src/modules/ui/display/chip/components/EntityChip.tsx+++ b/packages/twenty-front/src/modules/ui/display/chip/components/EntityChip.tsx@@ -64,7 +64,7 @@ export const EntityChip = ({) : (<AvataravatarUrl={avatarUrl}- colorId={entityId}+ entityId={entityId}placeholder={name}size="sm"type={avatarType}diff --git a/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageSummaryCard.tsx b/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageSummaryCard.tsxindex 0e1a8dbdb63..5eb2406bc66 100644--- a/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageSummaryCard.tsx+++ b/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageSummaryCard.tsx@@ -99,7 +99,7 @@ export const ShowPageSummaryCard = ({avatarUrl={logoOrAvatar}onClick={onUploadPicture ? handleAvatarClick : undefined}size="xl"- colorId={id}+ entityId={id}placeholder={avatarPlaceholder}type={avatarType}/>diff --git a/packages/twenty-front/src/modules/users/components/Avatar.tsx b/packages/twenty-front/src/modules/users/components/Avatar.tsxindex 12dc109fd54..9097c3ddcea 100644--- a/packages/twenty-front/src/modules/users/components/Avatar.tsx+++ b/packages/twenty-front/src/modules/users/components/Avatar.tsx@@ -16,21 +16,24 @@ export type AvatarProps = {className?: string;size?: AvatarSize;placeholder: string | undefined;- colorId?: string;+ entityId?: string;type?: Nullable<AvatarType>;+ color?: string;+ backgroundColor?: string;onClick?: () => void;};-const StyledAvatar = styled.div<AvatarProps & { colorId: string }>`+export const StyledAvatar = styled.div<+ AvatarProps & { color: string; backgroundColor: string }+>`align-items: center;- background-color: ${({ avatarUrl, colorId }) =>- !isNonEmptyString(avatarUrl) ? stringToHslColor(colorId, 75, 85) : 'none'};+ background-color: ${({ backgroundColor }) => backgroundColor};${({ avatarUrl }) =>isNonEmptyString(avatarUrl) ? `background-image: url(${avatarUrl});` : ''}background-position: center;background-size: cover;border-radius: ${(props) => (props.type === 'rounded' ? '50%' : '2px')};- color: ${({ colorId }) => stringToHslColor(colorId, 75, 25)};+ color: ${({ color }) => color};cursor: ${({ onClick }) => (onClick ? 'pointer' : 'default')};display: flex;@@ -95,9 +98,11 @@ export const Avatar = ({className,size = 'md',placeholder,- colorId = placeholder,+ entityId = placeholder,onClick,type = 'squared',+ color,+ backgroundColor,}: AvatarProps) => {const noAvatarUrl = !isNonEmptyString(avatarUrl);const [isInvalidAvatarUrl, setIsInvalidAvatarUrl] = useState(false);@@ -114,6 +119,13 @@ export const Avatar = ({}}, [avatarUrl]);+ const fixedColor = color ?? stringToHslColor(entityId ?? '', 75, 25);+ const fixedBackgroundColor =+ backgroundColor ??+ (!isNonEmptyString(avatarUrl)+ ? stringToHslColor(entityId ?? '', 75, 85)+ : 'none');+return (<StyledAvatarclassName={className}@@ -121,8 +133,10 @@ export const Avatar = ({placeholder={placeholder}size={size}type={type}- colorId={colorId ?? ''}+ entityId={entityId}onClick={onClick}+ color={fixedColor}+ backgroundColor={fixedBackgroundColor}>{(noAvatarUrl || isInvalidAvatarUrl) &&placeholder?.[0]?.toLocaleUpperCase()}diff --git a/packages/twenty-front/src/modules/workspace/components/WorkspaceMemberCard.tsx b/packages/twenty-front/src/modules/workspace/components/WorkspaceMemberCard.tsxindex 3c5e3acab9b..c6529442a6e 100644--- a/packages/twenty-front/src/modules/workspace/components/WorkspaceMemberCard.tsx+++ b/packages/twenty-front/src/modules/workspace/components/WorkspaceMemberCard.tsx@@ -40,7 +40,7 @@ export const WorkspaceMemberCard = ({<StyledContainer><AvataravatarUrl={workspaceMember.avatarUrl}- colorId={workspaceMember.id}+ entityId={workspaceMember.id}placeholder={workspaceMember.name.firstName || ''}type="squared"size="xl"