@@ -46,8 +46,8 @@ const regenerateIcon =
4646registerIconFromText ( 'thumb_up' , thumbUpIcon , 'material' ) ;
4747registerIconFromText ( 'thumb_down' , thumbDownIcon , 'material' ) ;
4848registerIconFromText ( 'regenerate' , regenerateIcon , 'material' ) ;
49-
50- let messages : any [ ] = [
49+ let messages : any [ ] = [ ] ;
50+ const initialMessages : any [ ] = [
5151 {
5252 id : '1' ,
5353 text : 'Hello! How can I help you today?' ,
@@ -80,7 +80,7 @@ const _messageActionsTemplate = (msg: any) => {
8080 return msg . sender !== 'user' && msg . text . trim ( )
8181 ? isResponseSent !== false
8282 ? html `
83- < div style ="float: right ">
83+ < div style ="float: left ">
8484 < igc-icon-button
8585 name ="thumb_up "
8686 collection ="material "
@@ -172,6 +172,7 @@ function handleMessageSend(e: CustomEvent) {
172172 if ( ! chat ) {
173173 return ;
174174 }
175+ chat . options = { ...chat . options , suggestions : [ ] } ;
175176
176177 const attachments : IgcMessageAttachment [ ] =
177178 newMessage . text . includes ( 'picture' ) ||
@@ -555,14 +556,17 @@ async function handleAIMessageSend(e: CustomEvent) {
555556}
556557
557558export const Basic : Story = {
558- render : ( ) => html `
559- < igc-chat
560- .messages =${ messages }
561- .options =${ chat_options }
562- @igcMessageCreated=${ handleMessageSend }
563- >
564- </ igc-chat >
565- ` ,
559+ render : ( ) => {
560+ messages = initialMessages ;
561+ return html `
562+ < igc-chat
563+ .messages =${ messages }
564+ .options =${ chat_options }
565+ @igcMessageCreated=${ handleMessageSend }
566+ >
567+ </ igc-chat >
568+ ` ;
569+ } ,
566570} ;
567571
568572export const Supabase : Story = {
@@ -590,3 +594,45 @@ export const AI: Story = {
590594 </ igc-chat >
591595 ` ,
592596} ;
597+
598+ let options : any ;
599+ export const Chat_Templates : Story = {
600+ play : async ( ) => {
601+ const chat = document . querySelector ( 'igc-chat' ) ;
602+ if ( chat ) {
603+ const actionsTemplate = html `
604+ < div >
605+ ${ chat . defaultFileUploadButton }
606+ < div >
607+ < igc-button @click =${ handleCustomSendClick } > Ask</ igc-button >
608+ < igc-button > ...</ igc-button >
609+ </ div >
610+ </ div >
611+ ` ;
612+ options = {
613+ headerText : 'Chat' ,
614+ inputPlaceholder : 'Type your message here...' ,
615+ suggestions : [ 'Hello' , 'Hi' , 'Generate an image!' ] ,
616+ templates : {
617+ messageActionsTemplate : _messageActionsTemplate ,
618+ textAreaActionsTemplate : actionsTemplate ,
619+ } ,
620+ } ;
621+ chat . options = { ...options } ;
622+ }
623+ } ,
624+ render : ( ) => {
625+ messages = [ ] ;
626+ return html `
627+ < igc-chat
628+ .messages =${ messages }
629+ .options =${ options }
630+ @igcMessageCreated=${ handleMessageSend }
631+ >
632+ < div slot ="suggestions-header ">
633+ < h5 > Suggestions</ h5 >
634+ </ div >
635+ </ igc-chat >
636+ ` ;
637+ } ,
638+ } ;
0 commit comments