nebular icon indicating copy to clipboard operation
nebular copied to clipboard

I Want to Change Chat Ui component to feet my need

Open TnCoders opened this issue 5 years ago • 14 comments

Hello, As I didn't find any way to ask questions, no forum, I'am looking to change the Nebular Chat Ui component to fit My Need:I would like to use Chat Ui to create a simple Chatbot without IA.

For example:

  • in the Chat ui the Sender avatar is not Displayed only reply message type that display avatar
  • I would like also to put a waiting GIF when both make some APi call, for example and the sender waits for response.
  • I need for example to add the possibilities to have an input button that the boat will suggest to users inside the chat message.

My question how can I Change the Chat Ui component and then install it with new features ?

TnCoders avatar Jun 07 '19 14:06 TnCoders

You need to extend NbChatMessageComponent to customize chat messages. There is ngSwitch (source) which used to determine what component to render. You can add new message types to add a bot response or anything else you need.

To enable avatars in replies remove ngIf here.

Also, you need to extend NbChatComponent to change selector used in ng-content to your custom message selector.

To sum up:

  1. Add custom messages components, like bot suggestions.
  2. Extend NbChatMessageComponent to add support for custom messages created above.
  3. Update message selector in NbChatComponent template.
  4. Create Module where you declare and export your custom components along with reexporting NbChatModule.

yggg avatar Jul 22 '19 12:07 yggg

I'm looking to do something similar here. I extended NbChatComponent and NbChatMessageComponent however the custom child components I created lost all the original nebular theme styles. I tried to link the scss files directly from node_modules to my component styleUrls but that didn't work.

How to use the original nebular theme styles in my extended CustomChatComponent and CustomChatMessageComponent?

vodz avatar Jan 21 '20 09:01 vodz

@vodz @yggg How do i create class that override the component ? Because I need the component to be included in NbChatModule

Miftahunajat avatar Jan 21 '20 14:01 Miftahunajat

I'm looking to do something similar here. I extended NbChatComponent and NbChatMessageComponent however the custom child components I created lost all the original nebular theme styles. I tried to link the scss files directly from node_modules to my component styleUrls but that didn't work.

How to use the original nebular theme styles in my extended CustomChatComponent and CustomChatMessageComponent?

I partly solved my problem: if I copy all the styles from \node_modules\@nebular\theme\styles\core\_mixins.scss into global styles.scss the styles finally work in my extended component. However if I have them in my component stylesheet it seems the nb-theme() modifiers don't get recognized and do nothing, only a couple of "native" styles get applied.

Any idea how to fix this please?

vodz avatar Jan 22 '20 09:01 vodz

Finally I'm extending my NbChatComponent and NbChatMessageComponent by copying the whole chat folder to theme/components/chat in my directory i also copied the module the whole NbChatModule therefore i still have syle from nebular.

Miftahunajat avatar Jan 22 '20 15:01 Miftahunajat

I solved the styles issue by extending the three elements: ` app-chat { @extend nb-chat; }

app-chat-message { @extend nb-chat-message; }

app-chat-message-link-card { @extend nb-chat-message-text; } `

The chat component ('nb-chat' or 'app-chat' in the case) was not recognizing the size attribute, that I've set to "medium". To solve that, I copied the native code to the 'chat.component.scss' file:

:host { display: flex; flex-direction: column; position: relative; height: 100%; }

allanalves avatar May 11 '20 16:05 allanalves

@allanalves , Please what was the import of @extend nb-chat; ?

FilipK23 avatar Jun 24 '20 13:06 FilipK23

@allanalves , Please what was the import of @extend nb-chat; ?

@FilipK23, I imported these:

@import 'themes'; @import '~@nebular/theme/styles/globals';

Remembering this code is in styles.scss in the src folder.

allanalves avatar Jun 24 '20 13:06 allanalves

@allanalves gracias bro, me funcionó para customizar un componente con los estilos de nebular ❤

gllrm-andres avatar Aug 24 '20 14:08 gllrm-andres

@allanalves gracias bro, me funcionó para customizar un componente con los estilos de nebular ❤

Great! Happy to help.

allanalves avatar Aug 24 '20 15:08 allanalves

Thanks everyone, i was able to extend and create a custom chat component, I am unable to disable animations. any suggestions regarding this ?

zarghambetterfront avatar Jul 25 '21 17:07 zarghambetterfront

How could you extend the ChatComponent in Nebular 8? When I try to do it, it's complaining about not finding the NbCustomMessageService, but I can't add it to the providers list, because it's not in the public_api.ts and therefore I get Module not found: Error: Can't resolve '@nebular/theme/components/chat/custom-message.service' when trying to add it.

JustDoItSascha avatar Nov 16 '22 17:11 JustDoItSascha

Is there any example code of how to extend the NbChatMessageComponent and NbChatComponent?

derekfreed avatar May 17 '23 21:05 derekfreed

Same request!

GiKyouGetsu avatar Sep 11 '23 08:09 GiKyouGetsu