feat: colored avatar (#554)

* feat: colored avatar

* fix: use id instead of name & remove unused

* fix: remove unused

* Allow empty ID to avoid empty string

* Fix tests

* Add person chip story

---------

Co-authored-by: Emilien <emilien.chauvet.enpc@gmail.com>
This commit is contained in:
Jérémy M
2023-07-10 20:24:09 +02:00
committed by GitHub
parent c9292365c0
commit 3079747c83
18 changed files with 129 additions and 47 deletions

View File

@ -10,7 +10,7 @@ import {
import { useHandleCheckableCommentThreadTargetChange } from '@/comments/hooks/useHandleCheckableCommentThreadTargetChange';
import { CommentableEntityForSelect } from '@/comments/types/CommentableEntityForSelect';
import CompanyChip from '@/companies/components/CompanyChip';
import { CompanyChip } from '@/companies/components/CompanyChip';
import { useScopedHotkeys } from '@/hotkeys/hooks/useScopedHotkeys';
import { InternalHotkeysScope } from '@/hotkeys/types/internal/InternalHotkeysScope';
import { PersonChip } from '@/people/components/PersonChip';

View File

@ -8,7 +8,6 @@ import {
beautifyExactDate,
beautifyPastDateRelativeToNow,
} from '@/utils/datetime/date-utils';
import { isNonEmptyString } from '@/utils/type-guards/isNonEmptyString';
type OwnProps = {
comment: Pick<CommentForDrawer, 'id' | 'author' | 'createdAt'>;
@ -74,17 +73,14 @@ export function CommentHeader({ comment, actionBar }: OwnProps) {
const avatarUrl = author.avatarUrl;
const commentId = comment.id;
const capitalizedFirstUsernameLetter = isNonEmptyString(authorName)
? authorName.toLocaleUpperCase()[0]
: '';
return (
<StyledContainer>
<StyledLeftContainer>
<Avatar
avatarUrl={avatarUrl}
size={theme.icon.size.md}
placeholder={capitalizedFirstUsernameLetter}
colorId={author.id}
placeholder={author.displayName}
/>
<StyledName>{authorName}</StyledName>
{showDate && (