# Introduction closes https://github.com/twentyhq/core-team-issues/issues/591 Same than for `twenty-shared` made in https://github.com/twentyhq/twenty/pull/11083. ## TODO - [x] Manual migrate twenty-website twenty-ui imports ## What's next: - Generate barrel and migration script factorization within own package + tests - Refactoring using preconstruct ? TimeBox - Lint circular dependencies - Lint import from barrel and forbid them ### Preconstruct We need custom rollup plugins addition, but preconstruct does not expose its rollup configuration. It might be possible to handle this using the babel overrides. But was a big tunnel. We could give it a try afterwards ! ( allowing cjs interop and stuff like that ) Stuck to vite lib app Closed related PRs: - https://github.com/twentyhq/twenty/pull/11294 - https://github.com/twentyhq/twenty/pull/11203
87 lines
2.3 KiB
TypeScript
87 lines
2.3 KiB
TypeScript
import styled from '@emotion/styled';
|
|
|
|
import { getDisplayNameFromParticipant } from '@/activities/emails/utils/getDisplayNameFromParticipant';
|
|
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
|
import { RecordChip } from '@/object-record/components/RecordChip';
|
|
import { Avatar } from 'twenty-ui/display';
|
|
|
|
const StyledAvatar = styled(Avatar)`
|
|
margin-right: ${({ theme }) => theme.spacing(1)};
|
|
`;
|
|
|
|
const StyledSenderName = styled.span<{ variant?: 'default' | 'bold' }>`
|
|
color: ${({ theme }) => theme.font.color.primary};
|
|
font-size: ${({ theme }) => theme.font.size.md};
|
|
font-weight: ${({ theme, variant }) =>
|
|
variant === 'bold' ? theme.font.weight.medium : theme.font.weight.regular};
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
`;
|
|
|
|
const StyledContainer = styled.div`
|
|
align-items: flex-start;
|
|
display: flex;
|
|
`;
|
|
|
|
const StyledRecordChip = styled(RecordChip)<{
|
|
participantChipVariant: 'default' | 'bold';
|
|
}>`
|
|
font-weight: ${({ theme, participantChipVariant }) =>
|
|
participantChipVariant === 'bold'
|
|
? theme.font.weight.medium
|
|
: theme.font.weight.regular};
|
|
`;
|
|
|
|
const StyledChip = styled.div`
|
|
align-items: center;
|
|
display: flex;
|
|
padding: ${({ theme }) => theme.spacing(1)};
|
|
height: 20px;
|
|
box-sizing: border-box;
|
|
white-space: nowrap;
|
|
gap: ${({ theme }) => theme.spacing(1)};
|
|
`;
|
|
|
|
type ParticipantChipVariant = 'default' | 'bold';
|
|
|
|
export const ParticipantChip = ({
|
|
participant,
|
|
variant = 'default',
|
|
className,
|
|
}: {
|
|
participant: any;
|
|
variant?: ParticipantChipVariant;
|
|
className?: string;
|
|
}) => {
|
|
const { person, workspaceMember } = participant;
|
|
|
|
const displayName = getDisplayNameFromParticipant({
|
|
participant,
|
|
shouldUseFullName: true,
|
|
});
|
|
|
|
const avatarUrl = person?.avatarUrl ?? workspaceMember?.avatarUrl ?? '';
|
|
|
|
return (
|
|
<StyledContainer className={className}>
|
|
{person ? (
|
|
<StyledRecordChip
|
|
objectNameSingular={CoreObjectNameSingular.Person}
|
|
record={person}
|
|
participantChipVariant={variant}
|
|
/>
|
|
) : (
|
|
<StyledChip>
|
|
<StyledAvatar
|
|
avatarUrl={avatarUrl}
|
|
type="rounded"
|
|
placeholder={displayName}
|
|
size="sm"
|
|
/>
|
|
<StyledSenderName variant={variant}>{displayName}</StyledSenderName>
|
|
</StyledChip>
|
|
)}
|
|
</StyledContainer>
|
|
);
|
|
};
|