diff --git a/packages/twenty-front/src/modules/activities/emails/components/EmailPreview.tsx b/packages/twenty-front/src/modules/activities/emails/components/EmailPreview.tsx new file mode 100644 index 000000000..d595fdf18 --- /dev/null +++ b/packages/twenty-front/src/modules/activities/emails/components/EmailPreview.tsx @@ -0,0 +1,88 @@ +import styled from '@emotion/styled'; + +import { CardContent } from '@/ui/layout/card/components/CardContent'; +import { Avatar } from '@/users/components/Avatar'; +import { formatToHumanReadableDate } from '~/utils'; + +import { Email } from '../types/email'; + +const StyledCardContent = styled(CardContent)` + align-items: center; + display: flex; + gap: ${({ theme }) => theme.spacing(2)}; + height: ${({ theme }) => theme.spacing(12)}; + padding: ${({ theme }) => theme.spacing(0, 4)}; +`; + +const StyledHeading = styled.div<{ unread: boolean }>` + align-items: center; + 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)}; + 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; + } +`; + +const StyledAvatar = styled(Avatar)` + margin: ${({ theme }) => theme.spacing(0, 1)}; +`; + +const StyledThreadCount = styled.span` + color: ${({ theme }) => theme.font.color.tertiary}; +`; + +const StyledSubject = styled.div<{ unread: boolean }>` + color: ${({ theme, unread }) => + unread ? theme.font.color.primary : theme.font.color.secondary}; +`; + +const StyledBody = styled.div` + color: ${({ theme }) => theme.font.color.tertiary}; + flex: 1 0 0; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +`; + +const StyledReceivedAt = styled.div` + font-size: ${({ theme }) => theme.font.size.sm}; + font-weight: ${({ theme }) => theme.font.weight.regular}; + padding: ${({ theme }) => theme.spacing(0, 1)}; +`; + +type EmailPreviewProps = { + divider?: boolean; + email: Email; +}; + +export const EmailPreview = ({ divider, email }: EmailPreviewProps) => ( + + + + {email.senderName}{' '} + {email.numberOfEmailsInThread} + + {email.subject} + {email.body} + + {formatToHumanReadableDate(email.receivedAt)} + + +); diff --git a/packages/twenty-front/src/modules/activities/emails/components/Emails.tsx b/packages/twenty-front/src/modules/activities/emails/components/Emails.tsx index 6e77927a6..368e3faa6 100644 --- a/packages/twenty-front/src/modules/activities/emails/components/Emails.tsx +++ b/packages/twenty-front/src/modules/activities/emails/components/Emails.tsx @@ -4,7 +4,11 @@ import { H1Title, H1TitleFontColor, } from '@/ui/display/typography/components/H1Title'; +import { Card } from '@/ui/layout/card/components/Card'; import { Section } from '@/ui/layout/section/components/Section'; +import { mockedEmails as emails } from '~/testing/mock-data/activities'; + +import { EmailPreview } from './EmailPreview'; const StyledContainer = styled.div` display: flex; @@ -28,11 +32,16 @@ export const Emails = () => ( - Inbox 2 + Inbox {emails.length} } fontColor={H1TitleFontColor.Primary} /> + + {emails.map((email, index) => ( + + ))} + ); diff --git a/packages/twenty-front/src/modules/activities/emails/components/__stories__/Emails.stories.tsx b/packages/twenty-front/src/modules/activities/emails/components/__stories__/Emails.stories.tsx new file mode 100644 index 000000000..c6712a903 --- /dev/null +++ b/packages/twenty-front/src/modules/activities/emails/components/__stories__/Emails.stories.tsx @@ -0,0 +1,13 @@ +import { Meta, StoryObj } from '@storybook/react'; + +import { Emails } from '../Emails'; + +const meta: Meta = { + title: 'Modules/Activity/Emails/Emails', + component: Emails, +}; + +export default meta; +type Story = StoryObj; + +export const Default: Story = {}; diff --git a/packages/twenty-front/src/modules/activities/emails/types/email.ts b/packages/twenty-front/src/modules/activities/emails/types/email.ts new file mode 100644 index 000000000..a49c2be3f --- /dev/null +++ b/packages/twenty-front/src/modules/activities/emails/types/email.ts @@ -0,0 +1,9 @@ +export type Email = { + body: string; + numberOfEmailsInThread: number; + read: boolean; + receivedAt: Date; + senderName: string; + senderPictureUrl: string; + subject: string; +}; diff --git a/packages/twenty-front/src/modules/users/components/Avatar.tsx b/packages/twenty-front/src/modules/users/components/Avatar.tsx index acefd87f7..782aedbcd 100644 --- a/packages/twenty-front/src/modules/users/components/Avatar.tsx +++ b/packages/twenty-front/src/modules/users/components/Avatar.tsx @@ -12,6 +12,7 @@ export type AvatarSize = 'xl' | 'lg' | 'md' | 'sm' | 'xs'; export type AvatarProps = { avatarUrl: string | null | undefined; + className?: string; size?: AvatarSize; placeholder: string | undefined; colorId?: string; @@ -90,6 +91,7 @@ const StyledAvatar = styled.div` export const Avatar = ({ avatarUrl, + className, size = 'md', placeholder, colorId = placeholder, @@ -113,6 +115,7 @@ export const Avatar = ({ return ( = [ __typename: 'Activity', }, ]; + +export const mockedEmails: Email[] = [ + { + body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras dignissim nisi eu tellus dapibus, egestas placerat risus placerat. Praesent eget arcu consectetur, efficitur felis.', + numberOfEmailsInThread: 4, + read: false, + receivedAt: new Date('11/04/2023'), + senderName: 'Steve Anahi', + senderPictureUrl: '', + subject: 'Partnerships', + }, + { + body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras dignissim nisi eu tellus dapibus, egestas placerat risus placerat. Praesent eget arcu consectetur, efficitur felis.', + numberOfEmailsInThread: 3, + read: true, + receivedAt: new Date('11/04/2023'), + senderName: 'Alexandre Prot', + senderPictureUrl: '', + subject: 'Next step', + }, +];