Skip to content

Commit 62f58f0

Browse files
Merging feat/quickAction-experience to main (#383)
* feat: add generic bordered card (#376) * fix: only show commandActionHeader when it is not null * fix: unit test cases --------- Co-authored-by: Randall-Jiang <[email protected]>
1 parent eb24c04 commit 62f58f0

File tree

8 files changed

+42
-5
lines changed

8 files changed

+42
-5
lines changed

example/src/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export enum Commands {
2121
INFORMATION_CARDS = '/information-cards',
2222
CONFIRMATION_BUTTONS = '/confirmation-buttons',
2323
BUTTONS = '/buttons',
24+
BORDERED_CARDS = '/bordered-cards',
2425

2526
NOTIFY = '/show-notification',
2627
CLEAR = '/clear',

example/src/config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ export const QuickActionCommands: QuickActionCommandGroup[] = [
215215
description:
216216
'You can set the position of the followups too. By simply setting the type of the ChatItem.',
217217
},
218+
{
219+
command: Commands.BORDERED_CARDS,
220+
icon: MynahIcons.INFO,
221+
description:
222+
'ChatItem cards with border styling for important notifications or reroute messages.',
223+
},
218224
],
219225
},
220226
{

example/src/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
sampleAllInOneList,
3939
sampleTableList,
4040
exampleInformationCard,
41+
exampleBorderedCard,
4142
exploreTabData,
4243
qAgentQuickActions,
4344
welcomeScreenTabData,
@@ -1725,6 +1726,10 @@ here to see if it gets cut off properly as expected, with an ellipsis through cs
17251726
mynahUI.addChatItem(tabId, exampleInformationCard('success', 'Successfully completed this task!'));
17261727
mynahUI.addChatItem(tabId, defaultFollowUps);
17271728
break;
1729+
case Commands.BORDERED_CARDS:
1730+
mynahUI.addChatItem(tabId, exampleBorderedCard());
1731+
mynahUI.addChatItem(tabId, defaultFollowUps);
1732+
break;
17281733
case Commands.CONFIRMATION_BUTTONS:
17291734
mynahUI.addChatItem(tabId, exampleConfirmationButtons);
17301735
mynahUI.addChatItem(tabId, defaultFollowUps);

example/src/samples/sample-data.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,10 @@ export const defaultFollowUps: ChatItem = {
576576
command: Commands.HEADER_TYPES,
577577
pillText: 'Cards with headers',
578578
},
579+
{
580+
command: Commands.BORDERED_CARDS,
581+
pillText: 'Bordered cards',
582+
},
579583
{
580584
command: Commands.SUMMARY_CARD,
581585
pillText: 'Card with summary field',
@@ -1251,6 +1255,7 @@ export const exampleCustomRendererWithDomBuilderJson: ChatItem = {
12511255
],
12521256
};
12531257

1258+
12541259
export const exampleDownloadFile: ChatItem = {
12551260
messageId: new Date().getTime().toString(),
12561261
type: ChatItemType.ANSWER,
@@ -1297,13 +1302,13 @@ export const exampleInformationCard = (
12971302
};
12981303
};
12991304

1300-
export const exampleBorderCard = (): ChatItem => {
1305+
export const exampleBorderedCard = (): ChatItem => {
13011306
return {
13021307
messageId: generateUID(),
13031308
type: ChatItemType.ANSWER,
13041309
border: true,
1305-
padding: true,
13061310
header: {
1311+
padding: true,
13071312
iconForegroundStatus: 'warning',
13081313
icon: MynahIcons.INFO,
13091314
body: '### /dev is going away soon!'

src/components/chat-item/chat-item-card.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,18 @@ export class ChatItemCard {
112112
testId: testIds.chatItem.card,
113113
children: this.initialSpinner ?? [],
114114
background: this.props.inline !== true && this.props.chatItem.type !== ChatItemType.DIRECTIVE && !(this.props.chatItem.fullWidth !== true && (this.props.chatItem.type === ChatItemType.ANSWER || this.props.chatItem.type === ChatItemType.ANSWER_STREAM)),
115-
border: this.props.inline !== true && this.props.chatItem.type !== ChatItemType.DIRECTIVE && !(this.props.chatItem.fullWidth !== true && (this.props.chatItem.type === ChatItemType.ANSWER || this.props.chatItem.type === ChatItemType.ANSWER_STREAM)),
116-
padding: this.props.inline === true || this.props.chatItem.padding === false || (this.props.chatItem.fullWidth !== true && (this.props.chatItem.type === ChatItemType.ANSWER || this.props.chatItem.type === ChatItemType.ANSWER_STREAM)) ? 'none' : undefined,
115+
border: (this.props.inline !== true &&
116+
this.props.chatItem.type !== ChatItemType.DIRECTIVE &&
117+
!(this.props.chatItem.fullWidth !== true &&
118+
(this.props.chatItem.type === ChatItemType.ANSWER ||
119+
this.props.chatItem.type === ChatItemType.ANSWER_STREAM))) ||
120+
// Auto border for warning/info headers
121+
(this.props.chatItem.border === true),
122+
padding: ((this.props.inline === true || this.props.chatItem.padding === false || (this.props.chatItem.fullWidth !== true && (this.props.chatItem.type === ChatItemType.ANSWER || this.props.chatItem.type === ChatItemType.ANSWER_STREAM))) &&
123+
// Exception: warning/info headers should have padding
124+
!(this.props.chatItem.header?.padding === true))
125+
? 'none'
126+
: undefined,
117127
});
118128
this.updateCardContent();
119129
this.render = this.generateCard();
@@ -214,6 +224,7 @@ export class ChatItemCard {
214224
...(this.props.chatItem.icon !== undefined ? [ 'mynah-chat-item-card-has-icon' ] : []),
215225
...(this.props.chatItem.fullWidth === true || this.props.chatItem.type === ChatItemType.ANSWER || this.props.chatItem.type === ChatItemType.ANSWER_STREAM ? [ 'full-width' ] : []),
216226
...(this.props.chatItem.padding === false ? [ 'no-padding' ] : []),
227+
217228
...(this.props.inline === true ? [ 'mynah-ui-chat-item-inline-card' ] : []),
218229
...(this.props.chatItem.muted === true ? [ 'muted' ] : []),
219230
...(this.props.small === true ? [ 'mynah-ui-chat-item-small-card' ] : []),

src/components/chat-item/chat-prompt-input.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,11 +734,18 @@ export class ChatPromptInput {
734734
headerComponent = newHeaderComponent;
735735
});
736736

737+
// Only show header if it has meaningful content
738+
const hasHeaderContent = headerInfo != null && (
739+
(headerInfo.title != null && headerInfo.title.trim() !== '') ||
740+
(headerInfo.description != null && headerInfo.description.trim() !== '') ||
741+
headerInfo.icon != null
742+
);
743+
737744
return DomBuilder.getInstance().build({
738745
type: 'div',
739746
classNames: [ 'mynah-chat-prompt-quick-picks-overlay-wrapper' ],
740747
children: [
741-
...(this.quickPickType === 'quick-action' && headerInfo != null
748+
...(this.quickPickType === 'quick-action' && hasHeaderContent
742749
? [ headerComponent ]
743750
: []),
744751
this.quickPickItemsSelectorContainer.render

src/static.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ export interface ChatItem extends ChatItemContent {
474474
status?: Status;
475475
shimmer?: boolean;
476476
collapse?: boolean;
477+
border?: boolean;
477478
}
478479

479480
export interface ValidationPattern {

src/styles/components/chat/_chat-item-card.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
transform-origin: center bottom;
1616
gap: var(--mynah-sizing-4);
1717
z-index: var(--mynah-z-1);
18+
1819
&-status {
1920
@each $status in $mynah-statuses {
2021
&-#{$status} {

0 commit comments

Comments
 (0)