Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import Message from '@patternfly/virtual-assistant/dist/dynamic/Message';
import patternflyAvatar from './patternfly_avatar.jpg';

export const AttachmentMenuExample: React.FunctionComponent = () => {
export const BotMessageExample: React.FunctionComponent = () => {
const markdown = `
Here is some YAML code:

Expand Down Expand Up @@ -62,18 +62,26 @@ export default MessageLoading;

return (
<>
<Message name="Bot" role="bot" avatar={patternflyAvatar} content={`Text-based message from a bot named "Bot"`} />
<Message
name="Bot"
role="bot"
avatar={patternflyAvatar}
content="Example content with updated timestamp text"
content={`Text-based message from a bot named "Bot," with updated timestamp`}
timestamp="1 hour ago"
/>
<Message name="Bot" role="bot" avatar={patternflyAvatar} content={markdown} />
<Message name="Bot" role="bot" avatar={patternflyAvatar} content={orderedList} />
<Message name="Bot" role="bot" avatar={patternflyAvatar} content={unorderedList} />
<Message name="Bot" role="bot" avatar={patternflyAvatar} content={moreComplexList} />
<Message name="Bot" role="bot" avatar={patternflyAvatar} content="Example content" isLoading />
<Message role="bot" avatar={patternflyAvatar} content="Text-based message from a nameless bot" />
<Message
name="Default Openshift Container Platform Assistant That Can Help With Any Query You Might Need Help With"
role="bot"
avatar={patternflyAvatar}
content="Text-based message, where the bot's name is truncated"
/>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Messages from the chatbot will be marked with an "AI" label to clearly communica

<br />

By default, a date and timestamp is displayed with each message. You can update `timestamp` with a different [date and time format](/ux-writing/numerics) as needed.
By default, a date and timestamp is displayed with each message. We recommend using the `timestamp` prop in real chatbots, since it will allow you to set persistent dates and times on messages, even if the messages re-render. You can update `timestamp` with a different [date and time format](/ux-writing/numerics) as needed.

```js file="./BotMessage.tsx"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import Message from '@patternfly/virtual-assistant/dist/dynamic/Message';
import userAvatar from './user_avatar.jpg';

export const AttachmentMenuExample: React.FunctionComponent = () => {
export const UserMessageExample: React.FunctionComponent = () => {
const markdown = `A paragraph with *emphasis* and **strong importance**.

> A block quote with ~strikethrough~ and a URL: https://reactjs.org.
Expand Down
9 changes: 9 additions & 0 deletions packages/module/src/Message/Message.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
gap: var(--pf-t--global--spacer--lg);
padding-bottom: var(--pf-t--global--spacer--2xl);

// Name
// --------------------------------------------------------------------------
.pf-v6-c-truncate {
--pf-v6-c-truncate--MinWidth: 0ch;
--pf-v6-c-truncate__start--MinWidth: 0ch;
}
// Avatar
// --------------------------------------------------------------------------
.pf-v6-c-avatar {
Expand Down Expand Up @@ -61,6 +67,9 @@
}

// Timestamp
.pf-v6-c-timestamp {
flex: 1 0 max-content;
}
time {
font-size: var(--pf-t--global--font--size--xs);
}
Expand Down
8 changes: 6 additions & 2 deletions packages/module/src/Message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React from 'react';

import Markdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import { Avatar, Label, LabelGroup, LabelGroupProps, LabelProps, Timestamp } from '@patternfly/react-core';
import { Avatar, Label, LabelGroup, LabelGroupProps, LabelProps, Timestamp, Truncate } from '@patternfly/react-core';
import MessageLoading from './MessageLoading';
import CodeBlockMessage from './CodeBlockMessage/CodeBlockMessage';
import TextMessage from './TextMessage/TextMessage';
Expand Down Expand Up @@ -116,7 +116,11 @@ export const Message: React.FunctionComponent<MessageProps> = ({
<Avatar src={avatar ?? DEFAULTS[role].avatar} alt="" />
<div className="pf-chatbot__message-contents">
<div className="pf-chatbot__message-meta">
<span className="pf-chatbot__message-name">{name}</span>
{name && (
<span className="pf-chatbot__message-name">
<Truncate content={name} />
</span>
)}
{role === 'bot' && (
<Label variant="outline" isCompact>
{botWord}
Expand Down
Loading