Skip to content

Commit cc56df9

Browse files
authored
Merge pull request #519 from rebeccaalpert/density-components
feat(Message): Add compact sources, quick starts, and quick responses
2 parents bd11579 + 943ff93 commit cc56df9

File tree

7 files changed

+73
-3
lines changed

7 files changed

+73
-3
lines changed

packages/module/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickResponses.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,29 @@ export const MessageWithQuickResponsesExample: React.FunctionComponent = () => (
5050
{ id: '2', content: 'No', onClick: () => alert('Clicked no') }
5151
]}
5252
/>
53+
<Message
54+
name="Bot"
55+
role="bot"
56+
avatar={patternflyAvatar}
57+
content="Welcome back, User! How can I help you today?"
58+
quickResponses={[
59+
{ id: '1', content: 'Help me with an access issue', onClick: () => alert('Clicked id 1') },
60+
{ id: '2', content: 'Show my critical vulnerabilities', onClick: () => alert('Clicked id 2') },
61+
{ id: '3', content: 'Create new integrations', onClick: () => alert('Clicked id 3') },
62+
{ id: '4', content: 'Get recommendations from an advisor', onClick: () => alert('Clicked id 4') },
63+
{ id: '5', content: 'Something else', onClick: () => alert('Clicked id 5') }
64+
]}
65+
/>
66+
<Message
67+
name="Bot"
68+
role="bot"
69+
avatar={patternflyAvatar}
70+
content="Example with compact responses"
71+
quickResponses={[
72+
{ id: '1', content: 'Yes', onClick: () => alert('Clicked id 1') },
73+
{ id: '2', content: 'No', onClick: () => alert('Clicked id 2') }
74+
]}
75+
isCompact
76+
/>
5377
</>
5478
);

packages/module/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickStart.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,16 @@ export const MessageWithQuickStartExample: React.FunctionComponent = () => (
2727
onSelectQuickStart: (id) => alert(id)
2828
}}
2929
/>
30+
<Message
31+
name="Bot"
32+
role="bot"
33+
avatar={patternflyAvatar}
34+
content="This quick start tile is compact"
35+
quickStarts={{
36+
quickStart: monitorSampleAppQuickStart,
37+
onSelectQuickStart: (id) => alert(id)
38+
}}
39+
isCompact
40+
/>
3041
</>
3142
);

packages/module/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithSources.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,27 @@ export const MessageWithSourcesExample: React.FunctionComponent = () => {
150150
onSetPage
151151
}}
152152
/>
153+
<Message
154+
name="Bot"
155+
role="bot"
156+
avatar={patternflyAvatar}
157+
content="This example displays a compact sources card"
158+
sources={{
159+
sources: [
160+
{
161+
link: '#'
162+
},
163+
{
164+
link: '#'
165+
},
166+
{
167+
link: '#'
168+
}
169+
],
170+
onSetPage
171+
}}
172+
isCompact
173+
/>
153174
</>
154175
);
155176
};

packages/module/src/Message/Message.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ export const MessageBase: React.FunctionComponent<MessageProps> = ({
339339
<div className="pf-chatbot__message-and-actions">
340340
{renderMessage()}
341341
{afterMainContent && <>{afterMainContent}</>}
342-
{!isLoading && sources && <SourcesCard {...sources} />}
342+
{!isLoading && sources && <SourcesCard {...sources} isCompact={isCompact} />}
343343
{quickStarts && quickStarts.quickStart && (
344344
<QuickStartTile
345345
quickStart={quickStarts.quickStart}
@@ -349,6 +349,7 @@ export const MessageBase: React.FunctionComponent<MessageProps> = ({
349349
prerequisiteWord={quickStarts.prerequisiteWord}
350350
prerequisiteWordPlural={quickStarts.prerequisiteWordPlural}
351351
quickStartButtonAriaLabel={quickStarts.quickStartButtonAriaLabel}
352+
isCompact={isCompact}
352353
/>
353354
)}
354355
{!isLoading && actions && <ResponseActions actions={actions} />}

packages/module/src/Message/QuickStarts/QuickStartTile.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export interface QuickStartTileProps {
4949
prerequisiteWordPlural?: string;
5050
/** Aria-label for the quick start description button */
5151
quickStartButtonAriaLabel?: string;
52+
/** Sets the tile to compact styling */
53+
isCompact?: boolean;
5254
}
5355

5456
const QuickStartTile: React.FC<QuickStartTileProps> = ({
@@ -61,7 +63,8 @@ const QuickStartTile: React.FC<QuickStartTileProps> = ({
6163
prerequisiteWord,
6264
prerequisiteWordPlural,
6365
quickStartButtonAriaLabel,
64-
action
66+
action,
67+
isCompact
6568
}) => {
6669
const {
6770
metadata: { name: id },
@@ -105,6 +108,7 @@ const QuickStartTile: React.FC<QuickStartTileProps> = ({
105108
id={`${id}-chatbot-qs-tile`}
106109
style={{ height: '100%' }}
107110
data-testid={`chatbot-qs-card-${camelize(displayName)}`}
111+
isCompact={isCompact}
108112
>
109113
<CardHeader
110114
{...(action && {

packages/module/src/SourcesCard/SourcesCard.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,11 @@
7474
}
7575
}
7676
}
77+
78+
.pf-v6-c-card.pf-m-compact.pf-chatbot__sources-card {
79+
.pf-v6-c-card__footer.pf-chatbot__sources-card-footer-container {
80+
border-top: var(--pf-t--global--border--width--regular) solid var(--pf-t--global--border--color--default);
81+
padding: var(--pf-t--global--spacer--xs) var(--pf-t--global--spacer--sm) var(--pf-t--global--spacer--xs)
82+
var(--pf-t--global--spacer--xs) !important;
83+
}
84+
}

packages/module/src/SourcesCard/SourcesCard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const SourcesCard: React.FunctionComponent<SourcesCardProps> = ({
7171
onSetPage,
7272
showMoreWords = 'show more',
7373
showLessWords = 'show less',
74+
isCompact,
7475
...props
7576
}: SourcesCardProps) => {
7677
const [page, setPage] = React.useState(1);
@@ -95,7 +96,7 @@ const SourcesCard: React.FunctionComponent<SourcesCardProps> = ({
9596
return (
9697
<div className="pf-chatbot__source">
9798
<span>{pluralize(sources.length, sourceWord, sourceWordPlural)}</span>
98-
<Card className="pf-chatbot__sources-card" {...props}>
99+
<Card isCompact={isCompact} className="pf-chatbot__sources-card" {...props}>
99100
<CardTitle className="pf-chatbot__sources-card-title">
100101
<Button
101102
component="a"

0 commit comments

Comments
 (0)