Skip to content

Commit 197282d

Browse files
committed
fix(Message): Truncate very long names
1 parent 9b1ed94 commit 197282d

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

packages/module/patternfly-docs/content/extensions/virtual-assistant/examples/Messages/BotMessage.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ export default MessageLoading;
7474
<Message name="Bot" role="bot" avatar={patternflyAvatar} content={unorderedList} />
7575
<Message name="Bot" role="bot" avatar={patternflyAvatar} content={moreComplexList} />
7676
<Message name="Bot" role="bot" avatar={patternflyAvatar} content="Example content" isLoading />
77+
<Message role="bot" avatar={patternflyAvatar} content="Message with no name" />
78+
<Message
79+
name="Default Openshift Container Platform Assistant That Can Help With Any Query You Might Need Help With"
80+
role="bot"
81+
avatar={patternflyAvatar}
82+
content="Message with very long name"
83+
/>
7784
</>
7885
);
7986
};

packages/module/src/Message/Message.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
gap: var(--pf-t--global--spacer--lg);
1616
padding-bottom: var(--pf-t--global--spacer--2xl);
1717

18+
// Name
19+
// --------------------------------------------------------------------------
20+
.pf-v6-c-truncate {
21+
--pf-v6-c-truncate--MinWidth: 0ch;
22+
--pf-v6-c-truncate__start--MinWidth: 0ch;
23+
}
1824
// Avatar
1925
// --------------------------------------------------------------------------
2026
.pf-v6-c-avatar {
@@ -61,6 +67,9 @@
6167
}
6268

6369
// Timestamp
70+
.pf-v6-c-timestamp {
71+
flex: 1 0 max-content;
72+
}
6473
time {
6574
font-size: var(--pf-t--global--font--size--xs);
6675
}

packages/module/src/Message/Message.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import React from 'react';
66

77
import Markdown from 'react-markdown';
88
import remarkGfm from 'remark-gfm';
9-
import { Avatar, Label, LabelGroup, LabelGroupProps, LabelProps, Timestamp } from '@patternfly/react-core';
9+
import { Avatar, Label, LabelGroup, LabelGroupProps, LabelProps, Timestamp, Truncate } from '@patternfly/react-core';
1010
import MessageLoading from './MessageLoading';
1111
import CodeBlockMessage from './CodeBlockMessage/CodeBlockMessage';
1212
import TextMessage from './TextMessage/TextMessage';
@@ -116,7 +116,11 @@ export const Message: React.FunctionComponent<MessageProps> = ({
116116
<Avatar src={avatar ?? DEFAULTS[role].avatar} alt="" />
117117
<div className="pf-chatbot__message-contents">
118118
<div className="pf-chatbot__message-meta">
119-
<span className="pf-chatbot__message-name">{name}</span>
119+
{name && (
120+
<span className="pf-chatbot__message-name">
121+
<Truncate content={name} />
122+
</span>
123+
)}
120124
{role === 'bot' && (
121125
<Label variant="outline" isCompact>
122126
{botWord}

0 commit comments

Comments
 (0)