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 type { Message } from '../types/dialogue-message';
import { useAuthStore } from 'src/stores/auth-store';
import { watch, nextTick } from 'vue';
const authStore = useAuthStore();
const currentUser = authStore.user;
defineProps<{
const props = defineProps<{
messages: Message[];
}>();
watch(props.messages, async () => {
await nextTick(() => {
const chatBody = document.querySelector('.chat-body');
if (chatBody) chatBody.scrollTop = chatBody.scrollHeight;
});
});
</script>
<template>
@ -38,18 +46,3 @@ defineProps<{
</template>
</q-infinite-scroll>
</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"
:text="[text]"
:bg-color="!sent ? 'secondary' : 'accent'"
class="bubble"
:class="sent ? 'user' : 'ai'"
>
</q-chat-message>
</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>