Skip to content

Commit ac0185d

Browse files
committed
feat(chat): add template for suggestion prefix
1 parent b60b857 commit ac0185d

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

src/components/chat/chat.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,18 @@ export default class IgcChatComponent extends EventEmitterMixin<
329329
</div>`;
330330
}
331331

332+
private renderSuggestionPrefix() {
333+
const defaultPrefix = html`<igc-icon
334+
name="star-icon"
335+
collection="material"
336+
></igc-icon>`;
337+
return html`<span slot="start">
338+
${this._chatState?.options?.templates?.suggestionPrefixTemplate
339+
? this._chatState.options.templates.suggestionPrefixTemplate
340+
: defaultPrefix}
341+
</span>`;
342+
}
343+
332344
private renderSuggestions() {
333345
const hasContent = this._slots.hasAssignedElements('suggestions-header');
334346
return html`<div part="suggestions-container">
@@ -347,11 +359,7 @@ export default class IgcChatComponent extends EventEmitterMixin<
347359
@click=${() =>
348360
this._chatState?.handleSuggestionClick(suggestion)}
349361
>
350-
<igc-icon
351-
slot="start"
352-
name="star-icon"
353-
collection="material"
354-
></igc-icon>
362+
${this.renderSuggestionPrefix()}
355363
<span slot="title">${suggestion}</span>
356364
</igc-list-item>
357365
</slot>

src/components/chat/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ export type IgcChatTemplates = {
211211
* Template for rendering attachments that are currently queued for sending (in the input area).
212212
*/
213213
textAreaAttachmentsTemplate?: AttachmentTemplate;
214+
215+
/**
216+
* Template for rendering the suggestion prefix.
217+
*/
218+
suggestionPrefixTemplate?: unknown;
214219
};
215220

216221
export const attachmentIcon =

stories/chat.stories.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ export const Chat_Templates: Story = {
477477
templates: {
478478
messageActionsTemplate: _messageActionsTemplate,
479479
textAreaActionsTemplate: actionsTemplate,
480+
suggestionPrefixTemplate: html`✨`,
480481
},
481482
};
482483
chat.options = { ...options };

0 commit comments

Comments
 (0)