style: stylized the chat message to be a little more user friendly

This commit is contained in:
Lion Arar 2025-10-06 15:17:32 -04:00
parent d958f90053
commit 8cc700d0e7
2 changed files with 30 additions and 18 deletions

View File

@ -2,13 +2,21 @@
import DialoguePhrase from './dialogue-phrase.vue'; import DialoguePhrase from './dialogue-phrase.vue';
import type { Message } from '../types/dialogue-message'; import type { Message } from '../types/dialogue-message';
import { useAuthStore } from 'src/stores/auth-store'; import { useAuthStore } from 'src/stores/auth-store';
import { watch, nextTick } from 'vue';
const authStore = useAuthStore(); const authStore = useAuthStore();
const currentUser = authStore.user; const currentUser = authStore.user;
defineProps<{ const props = defineProps<{
messages: Message[]; messages: Message[];
}>(); }>();
watch(props.messages, async () => {
await nextTick(() => {
const chatBody = document.querySelector('.chat-body');
if (chatBody) chatBody.scrollTop = chatBody.scrollHeight;
});
});
</script> </script>
<template> <template>
@ -37,19 +45,4 @@ defineProps<{
</div> </div>
</template> </template>
</q-infinite-scroll> </q-infinite-scroll>
</template> </template>
<!-- <template>
<q-infinite-scroll>
<DialoguePhrase
v-for="(msg, index) in messages"
:key="index"
:text="msg.text"
:sent="msg.sent"
:name="msg.sent ? currentUser.firstName : 'AI Assistant'"
:class="['chat-message', msg.sent ? 'user' : 'ai']"
/>
</q-infinite-scroll>
</template> -->

View File

@ -12,8 +12,27 @@ const props = defineProps<{
:sent="props.sent" :sent="props.sent"
:text="[text]" :text="[text]"
:bg-color="!sent ? 'secondary' : 'accent'" :bg-color="!sent ? 'secondary' : 'accent'"
class="bubble"
:class="sent ? 'user' : 'ai'"
> >
</q-chat-message> </q-chat-message>
</template> </template>
<style></style> <style scoped>
.bubble {
margin: 8px;
border-radius: 12px;
line-height: 1.5;
word-break: break-word;
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.user {
align-self: flex-end;
}
.ai {
align-self: flex-start;
}
</style>