Skip to content

Commit 5849e0f

Browse files
authored
[LG-5926] refactor(message): remove assistant avatar and name (#3482)
* refactor(message): remove assistant avatar and name * chore(message): changeset
1 parent 1aeaa66 commit 5849e0f

File tree

7 files changed

+28
-76
lines changed

7 files changed

+28
-76
lines changed

.changeset/heavy-clocks-sin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@lg-chat/message': major
3+
---
4+
5+
[LG-5926](https://jira.mongodb.org/browse/LG-5926): remove assistant avatar and name from `Message`

chat/message/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"access": "public"
1515
},
1616
"dependencies": {
17-
"@leafygreen-ui/avatar": "workspace:^",
1817
"@leafygreen-ui/badge": "workspace:^",
1918
"@leafygreen-ui/banner": "workspace:^",
2019
"@leafygreen-ui/button": "workspace:^",

chat/message/src/Message.stories.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ const meta: StoryMetaType<typeof Message> = {
200200
argTypes: {
201201
darkMode: storybookArgTypes.darkMode,
202202
isSender: { control: 'boolean' },
203-
avatar: { control: 'none' },
204203
components: { control: 'none' },
205204
markdownProps: { control: 'none' },
206205
},

chat/message/src/Message/Message.styles.ts

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,23 @@ import {
1010
} from '@leafygreen-ui/tokens';
1111

1212
const getBaseContainerStyles = (theme: Theme) => css`
13+
position: relative;
14+
max-width: 100%;
15+
width: 100%;
16+
white-space: pre-line;
17+
overflow-wrap: break-word;
1318
display: flex;
1419
flex-direction: column;
15-
gap: ${spacing[150]}px;
16-
align-items: flex-start;
20+
gap: ${spacing[200]}px;
1721
color: ${color[theme].text[Variant.Primary][InteractionState.Default]};
1822
`;
1923

20-
const senderStyles = css`
21-
align-items: flex-end;
24+
const getSenderContainerStyles = (theme: Theme) => css`
25+
width: auto;
26+
border-radius: ${borderRadius[300]}px ${borderRadius[300]}px 0;
27+
background-color: ${palette.gray[theme === Theme.Dark ? 'dark2' : 'light2']};
28+
padding: ${spacing[300]}px;
29+
align-self: flex-end;
2230
`;
2331

2432
export const getContainerStyles = ({
@@ -33,39 +41,7 @@ export const getContainerStyles = ({
3341
cx(
3442
getBaseContainerStyles(theme),
3543
{
36-
[senderStyles]: isSender,
44+
[getSenderContainerStyles(theme)]: isSender,
3745
},
3846
className,
3947
);
40-
41-
export const avatarContainerStyles = css`
42-
display: flex;
43-
gap: ${spacing[150]}px;
44-
`;
45-
46-
const baseMessageContainerStyles = css`
47-
position: relative;
48-
max-width: 100%;
49-
white-space: pre-line;
50-
overflow-wrap: break-word;
51-
display: flex;
52-
flex-direction: column;
53-
gap: ${spacing[200]}px;
54-
`;
55-
56-
const getSenderMessageContainerStyles = (theme: Theme) => css`
57-
border-radius: ${borderRadius[300]}px ${borderRadius[300]}px 0;
58-
background-color: ${palette.gray[theme === Theme.Dark ? 'dark2' : 'light2']};
59-
padding: ${spacing[300]}px;
60-
`;
61-
62-
export const getMessageContainerStyles = ({
63-
isSender,
64-
theme,
65-
}: {
66-
isSender: boolean;
67-
theme: Theme;
68-
}) =>
69-
cx(baseMessageContainerStyles, {
70-
[getSenderMessageContainerStyles(theme)]: isSender,
71-
});

chat/message/src/Message/Message.tsx

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import React, { forwardRef, useMemo } from 'react';
2-
import { useLeafyGreenChatContext } from '@lg-chat/leafygreen-chat-provider';
32

4-
import { AssistantAvatar } from '@leafygreen-ui/avatar';
53
import {
64
CompoundComponent,
75
filterChildren,
@@ -10,7 +8,6 @@ import {
108
import LeafyGreenProvider, {
119
useDarkMode,
1210
} from '@leafygreen-ui/leafygreen-provider';
13-
import { Body } from '@leafygreen-ui/typography';
1411

1512
import {
1613
ActionCard,
@@ -22,11 +19,7 @@ import {
2219
import { MessageContext } from '../MessageContext';
2320
import { MessageSubcomponentProperty } from '../shared.types';
2421

25-
import {
26-
avatarContainerStyles,
27-
getContainerStyles,
28-
getMessageContainerStyles,
29-
} from './Message.styles';
22+
import { getContainerStyles } from './Message.styles';
3023
import { type MessageProps } from './Message.types';
3124
import { MessageContent } from './MessageContent';
3225

@@ -47,7 +40,6 @@ export const Message = CompoundComponent(
4740
fwdRef,
4841
) => {
4942
const { darkMode, theme } = useDarkMode(darkModeProp);
50-
const { assistantName } = useLeafyGreenChatContext();
5143

5244
const contextValue = useMemo(
5345
() => ({
@@ -90,28 +82,15 @@ export const Message = CompoundComponent(
9082
ref={fwdRef}
9183
{...rest}
9284
>
93-
{!isSender && (
94-
<div className={avatarContainerStyles}>
95-
<AssistantAvatar size={20} />
96-
<Body weight="semiBold">{assistantName}</Body>
97-
</div>
98-
)}
99-
<div
100-
className={getMessageContainerStyles({
101-
isSender,
102-
theme,
103-
})}
104-
>
105-
<MessageContent sourceType={sourceType} {...markdownProps}>
106-
{messageBody ?? ''}
107-
</MessageContent>
108-
{actionCard}
109-
{promotion}
110-
{actions}
111-
{verifiedBanner}
112-
{links}
113-
{remainingChildren}
114-
</div>
85+
<MessageContent sourceType={sourceType} {...markdownProps}>
86+
{messageBody ?? ''}
87+
</MessageContent>
88+
{actionCard}
89+
{promotion}
90+
{actions}
91+
{verifiedBanner}
92+
{links}
93+
{remainingChildren}
11594
</div>
11695
</MessageContext.Provider>
11796
</LeafyGreenProvider>

chat/message/tsconfig.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
{
3636
"path": "../rich-links"
3737
},
38-
{
39-
"path": "../../packages/avatar"
40-
},
4138
{
4239
"path": "../../packages/badge"
4340
},

pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)