Skip to content

Commit 1be97ff

Browse files
committed
feat(chat): add default suggestions header and reaction tooltips
1 parent 4194e8f commit 1be97ff

File tree

4 files changed

+66
-14
lines changed

4 files changed

+66
-14
lines changed

src/components/chat/chat-message.ts

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ import IgcMessageAttachmentsComponent from './message-attachments.js';
1313
import { styles } from './themes/message.base.css.js';
1414
import { all } from './themes/message.js';
1515
import { styles as shared } from './themes/shared/chat-message/chat-message.common.css.js';
16+
import '../tooltip/tooltip.js';
17+
import { IgcChatResourceStringEN } from '../common/i18n/chat.resources.js';
18+
import IgcTooltipComponent from '../tooltip/tooltip.js';
1619
import {
17-
copyIcon,
20+
thumbDownIcon as badResponseIcon,
21+
copyIcon as copyResponseIcon,
22+
thumbUpIcon as goodResponseIcon,
1823
type IgcMessage,
19-
regenerateIcon,
20-
thumbDownIcon,
21-
thumbUpIcon,
24+
regenerateIcon as redoIcon,
2225
} from './types.js';
2326

2427
/**
@@ -55,7 +58,8 @@ export default class IgcChatMessageComponent extends LitElement {
5558
registerComponent(
5659
IgcChatMessageComponent,
5760
IgcMessageAttachmentsComponent,
58-
IgcAvatarComponent
61+
IgcAvatarComponent,
62+
IgcTooltipComponent
5963
);
6064
}
6165

@@ -72,6 +76,10 @@ export default class IgcChatMessageComponent extends LitElement {
7276
@property({ attribute: false })
7377
public message: IgcMessage | undefined;
7478

79+
/** The resource strings. */
80+
@property({ attribute: false })
81+
public resourceStrings = IgcChatResourceStringEN;
82+
7583
/**
7684
* Sanitizes message text to prevent XSS or invalid HTML.
7785
* @param text The raw message text
@@ -85,10 +93,10 @@ export default class IgcChatMessageComponent extends LitElement {
8593
constructor() {
8694
super();
8795
addThemingController(this, all);
88-
registerIconFromText('copy', copyIcon, 'material');
89-
registerIconFromText('thumb_up', thumbUpIcon, 'material');
90-
registerIconFromText('thumb_down', thumbDownIcon, 'material');
91-
registerIconFromText('regenerate', regenerateIcon, 'material');
96+
registerIconFromText('copy-response', copyResponseIcon, 'material');
97+
registerIconFromText('good-response', goodResponseIcon, 'material');
98+
registerIconFromText('bad-response', badResponseIcon, 'material');
99+
registerIconFromText('redo', redoIcon, 'material');
92100
}
93101

94102
private get defaultMessageActionsTemplate() {
@@ -98,29 +106,45 @@ export default class IgcChatMessageComponent extends LitElement {
98106
(!isLastMessage || !this._chatState?.options?.isTyping)
99107
? html`<div part="message-actions">
100108
<igc-icon-button
101-
name="copy"
109+
id="copy-response-button"
110+
name="copy-response"
102111
collection="material"
103112
variant="flat"
104113
@click=${this.handleMessageActionClick}
105114
></igc-icon-button>
115+
<igc-tooltip anchor="copy-response-button" hide-delay="0">
116+
${this.resourceStrings.reactionCopyResponse}
117+
</igc-tooltip>
106118
<igc-icon-button
107-
name="thumb_up"
119+
id="good-response-button"
120+
name="good-response"
108121
collection="material"
109122
variant="flat"
110123
@click=${this.handleMessageActionClick}
111124
></igc-icon-button>
125+
<igc-tooltip anchor="good-response-button" hide-delay="0">
126+
${this.resourceStrings.reactionGoodResponse}
127+
</igc-tooltip>
112128
<igc-icon-button
113-
name="thumb_down"
129+
id="bad-response-button"
130+
name="bad-response"
114131
variant="flat"
115132
collection="material"
116133
@click=${this.handleMessageActionClick}
117134
></igc-icon-button>
135+
<igc-tooltip anchor="bad-response-button" hide-delay="0">
136+
${this.resourceStrings.reactionBadResponse}
137+
</igc-tooltip>
118138
<igc-icon-button
119-
name="regenerate"
139+
id="redo-button"
140+
name="redo"
120141
variant="flat"
121142
collection="material"
122143
@click=${this.handleMessageActionClick}
123144
></igc-icon-button>
145+
<igc-tooltip anchor="redo-button" hide-delay="0">
146+
${this.resourceStrings.reactionRedo}
147+
</igc-tooltip>
124148
</div>`
125149
: nothing;
126150
}

src/components/chat/chat.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { chatContext } from '../common/context.js';
77
import { addSlotController, setSlots } from '../common/controllers/slot.js';
88
import { watch } from '../common/decorators/watch.js';
99
import { registerComponent } from '../common/definitions/register.js';
10+
import { IgcChatResourceStringEN } from '../common/i18n/chat.resources.js';
1011
import type { Constructor } from '../common/mixins/constructor.js';
1112
import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
1213
import IgcIconComponent from '../icon/icon.js';
@@ -253,6 +254,10 @@ export default class IgcChatComponent extends EventEmitterMixin<
253254
return this._chatState.options;
254255
}
255256

257+
/** The resource strings. */
258+
@property({ attribute: false })
259+
public resourceStrings = IgcChatResourceStringEN;
260+
256261
/** Returns the default attachments element. */
257262
public get defaultAttachments(): TemplateResult {
258263
return this._chatInput.defaultAttachmentsArea;
@@ -331,7 +336,10 @@ export default class IgcChatComponent extends EventEmitterMixin<
331336
role="list"
332337
aria-label="Suggestions"
333338
>
334-
<igc-list-header part="suggestions-header" ?hidden=${!hasContent}>
339+
<igc-list-header part="suggestions-header">
340+
<span ?hidden=${hasContent}
341+
>${this.resourceStrings.suggestionsHeader}</span
342+
>
335343
<slot name="suggestions-header"></slot>
336344
</igc-list-header>
337345
<slot name="suggestions" part="suggestions">
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* blazorSuppress */
2+
export interface IgcChatResourceStrings {
3+
suggestionsHeader: string;
4+
reactionCopyResponse: string;
5+
reactionGoodResponse: string;
6+
reactionBadResponse: string;
7+
reactionRedo: string;
8+
}
9+
10+
export const IgcChatResourceStringEN: IgcChatResourceStrings = {
11+
suggestionsHeader: 'Suggestions',
12+
reactionCopyResponse: 'Copy Response',
13+
reactionGoodResponse: 'Good Response',
14+
reactionBadResponse: 'Bad Response',
15+
reactionRedo: 'Redo',
16+
};

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ export {
8989
IgcCalendarResourceStringEN,
9090
type IgcCalendarResourceStrings,
9191
} from './components/common/i18n/calendar.resources.js';
92+
export {
93+
IgcChatResourceStringEN,
94+
type IgcChatResourceStrings,
95+
} from './components/common/i18n/chat.resources.js';
9296

9397
// Event maps
9498
export type { IgcBannerComponentEventMap } from './components/banner/banner.js';

0 commit comments

Comments
 (0)