Skip to content

Commit dbbbe89

Browse files
authored
feature/BA-2855-default-avatar-and-username-display (#304)
2 Fixes in 1 PR Default Avatar is Inconsistent: https://silverlogic.atlassian.net/browse/BA-2855 Username in messages and group chat not matching design: https://silverlogic.atlassian.net/browse/BA-2216 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Handles now consistently strip leading slashes and display with an @ prefix. * **Style** * Updated avatar visuals and switched group avatars to a placeholder-aware avatar for more consistent appearance. * **New Features** * Added a shared handle-formatting utility and re-exported common utilities for wider use. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent e489dba commit dbbbe89

File tree

14 files changed

+46
-14
lines changed

14 files changed

+46
-14
lines changed

packages/components/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# @baseapp-frontend/components
22

3+
## 1.4.10
4+
5+
### Patch Changes
6+
7+
- Improved handle formatting with consistent @ display, updated avatar visuals, and added shared utilities for broader use
8+
- Updated dependencies
9+
- @baseapp-frontend/design-system@1.1.6
10+
311
## 1.4.9
412

513
### Patch Changes

packages/components/modules/__shared__/common/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
export * from './constants'
44
export type * from './types'
5+
export * from './utils'
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export function formatHandle(path?: string): string | null {
2+
if (!path) return null
3+
return `@${path.replace('/', '')}`
4+
}

packages/components/modules/activity-log/web/ActivityLogComponent/LogGroups/index.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { FC } from 'react'
22

3+
import { AvatarWithPlaceholder } from '@baseapp-frontend/design-system/components/web/avatars'
34
import { AvatarDeletedUserIcon } from '@baseapp-frontend/design-system/components/web/icons'
45

5-
import { Avatar, Box, CircularProgress, Typography } from '@mui/material'
6+
import { Box, CircularProgress, Typography } from '@mui/material'
67
import { Virtuoso } from 'react-virtuoso'
78

89
import { Timestamp } from '../../../../__shared__/web'
@@ -44,11 +45,12 @@ const LogGroups: FC<LogGroupsProps> = ({
4445
const renderAvatar = (group: LogGroup) => {
4546
if (group.logs[0]?.user == null) return <AvatarDeletedUserIcon />
4647
return (
47-
<Avatar
48-
style={{ marginBottom: '4px' }}
49-
sizes="small"
48+
<AvatarWithPlaceholder
49+
width={40}
50+
height={40}
51+
className="self-start justify-self-center"
5052
src={group.logs[0]?.user?.avatar?.url ?? ''}
51-
alt={group.logs[0]?.user?.fullName ?? 'User activity log avatar'}
53+
sx={{ border: 'none', marginBottom: '4px' }}
5254
/>
5355
)
5456
}

packages/components/modules/messages/web/GroupChatDetails/ProfileCard/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Box, IconButton, Typography } from '@mui/material'
1212
import { useFragment } from 'react-relay'
1313

1414
import { ProfileItemFragment$key } from '../../../../../__generated__/ProfileItemFragment.graphql'
15+
import { formatHandle } from '../../../../__shared__/common/utils'
1516
import { ProfileItemFragment } from '../../../../profiles/common'
1617
import { ADMIN_LABEL, CHAT_ROOM_PARTICIPANT_ROLES } from '../../../common'
1718
import AdminOptionsMenu from './AdminOptionsMenu'
@@ -88,7 +89,7 @@ const ProfileCard: FC<ProfileCardProps> = ({
8889
}}
8990
>
9091
<Typography variant="caption" color="text.secondary">
91-
{showUrlPath && `@${urlPath.path}`}
92+
{showUrlPath && formatHandle(urlPath.path)}
9293
</Typography>
9394
{showAdminLabel && showUrlPath && (
9495
<Box

packages/components/modules/messages/web/ProfileSummary/Body/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Box, Divider, Typography } from '@mui/material'
1313
import { useFragment } from 'react-relay'
1414

1515
import { ProfileSummaryFragment$key } from '../../../../../__generated__/ProfileSummaryFragment.graphql'
16+
import { formatHandle } from '../../../../__shared__/common/utils'
1617
import { ProfileSummaryFragment } from '../../../common/graphql/fragments/ProfileSummary'
1718
import {
1819
ButtonContainer,
@@ -48,7 +49,6 @@ const Body: FC<BodyProps> = ({ avatarSize = 144, chatRoomRef }) => {
4849
}
4950

5051
const { name, avatar, username, biography, pk } = getroomNameAndAvatar() || {}
51-
const formattedUsername = username ? username.replace(/^\/+/, '') : ''
5252
const profilePath = username ?? (pk ? `/profile/${pk}` : undefined)
5353

5454
return (
@@ -59,9 +59,9 @@ const Body: FC<BodyProps> = ({ avatarSize = 144, chatRoomRef }) => {
5959
<TypographyWithEllipsis variant="subtitle1" color="text.primary">
6060
{name}
6161
</TypographyWithEllipsis>
62-
{formattedUsername && (
62+
{username && (
6363
<TypographyWithEllipsis variant="body2" color="text.secondary">
64-
{`@${formattedUsername}`}
64+
{formatHandle(username)}
6565
</TypographyWithEllipsis>
6666
)}
6767
</TitleContainer>

packages/components/modules/messages/web/SingleChatCreate/ChatRoomListItem/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { LoadingButton } from '@mui/lab'
1010
import { Box, Typography } from '@mui/material'
1111
import { ConnectionHandler, useFragment } from 'react-relay'
1212

13+
import { formatHandle } from '../../../../__shared__/common/utils'
1314
import { ProfileItemFragment } from '../../../../profiles/common'
1415
import { useCreateChatRoomMutation } from '../../../common'
1516
import { MainContainer } from './styled'
@@ -32,7 +33,7 @@ const ChatRoomListItem: FC<ChatRoomListItemProps> = ({ profile: profileRef, onCh
3233
<Box sx={{ display: 'grid', gridTemplateRows: 'repeat(2, minmax(0, 1fr))' }}>
3334
<TypographyWithEllipsis variant="subtitle2">{name}</TypographyWithEllipsis>
3435
<Typography variant="caption" color="text.secondary">
35-
{urlPath?.path && `@${urlPath.path?.replace('/', '')}`}
36+
{urlPath?.path && formatHandle(urlPath.path)}
3637
</Typography>
3738
</Box>
3839
<LoadingButton

packages/components/modules/messages/web/__shared__/GroupChatMembersList/ProfileCard/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Box, Button, Typography } from '@mui/material'
88
import { useFragment } from 'react-relay'
99

1010
import { ProfileItemFragment$key } from '../../../../../../__generated__/ProfileItemFragment.graphql'
11+
import { formatHandle } from '../../../../../__shared__/common/utils'
1112
import { ProfileItemFragment } from '../../../../../profiles/common'
1213
import { MainContainer } from './styled'
1314
import { ProfileCardProps } from './types'
@@ -34,7 +35,7 @@ const ProfileCard: FC<ProfileCardProps> = ({
3435
<Box sx={{ display: 'grid', gridTemplateRows: 'repeat(2, minmax(0, 1fr))' }}>
3536
<Typography variant="subtitle2">{name}</Typography>
3637
<Typography variant="caption" color="text.secondary">
37-
{urlPath?.path && `@${urlPath.path}`}
38+
{urlPath?.path && formatHandle(urlPath.path)}
3839
</Typography>
3940
</Box>
4041
<Button

packages/components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@baseapp-frontend/components",
33
"description": "BaseApp components modules such as comments, notifications, messages, and more.",
4-
"version": "1.4.9",
4+
"version": "1.4.10",
55
"sideEffects": false,
66
"scripts": {
77
"build": "rm -rf dist && pnpm relay && tsc --build tsconfig.build.json",

packages/design-system/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @baseapp-frontend/design-system
22

3+
## 1.1.6
4+
5+
### Patch Changes
6+
7+
- Improved handle formatting with consistent @ display, updated avatar visuals, and added shared utilities for broader use
8+
39
## 1.1.5
410

511
### Patch Changes

0 commit comments

Comments
 (0)