feat: Added initial skeleton for the messaging system
This commit is contained in:
parent
e2eb795284
commit
398ef5f888
23
src/modules/chatbot/components/chat-button.vue
Normal file
23
src/modules/chatbot/components/chat-button.vue
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { isChatVisible } from "src/stores/dialogue-box";
|
||||||
|
|
||||||
|
const toggleChat = () => {
|
||||||
|
isChatVisible.value = !isChatVisible.value;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="accessBot">
|
||||||
|
<q-btn round color="primary" size="20px" class="glossy" icon="chat" @click="toggleChat">
|
||||||
|
</q-btn>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.accessBot {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 75px;
|
||||||
|
right: 75px;
|
||||||
|
z-index: 9999;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
104
src/modules/chatbot/components/conversation-box.vue
Normal file
104
src/modules/chatbot/components/conversation-box.vue
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { isChatVisible } from "src/stores/dialogue-box";
|
||||||
|
import { provide, ref } from "vue";
|
||||||
|
import DialogueContent from "./dialogue-content.vue";
|
||||||
|
import { Message } from "../types/dialogue-message";
|
||||||
|
|
||||||
|
const text = ref("");
|
||||||
|
const messages = ref<Message[]>([]);
|
||||||
|
|
||||||
|
const sendMessage = () => {
|
||||||
|
if (!text.value.trim()) return;
|
||||||
|
|
||||||
|
messages.value.push({
|
||||||
|
text: text.value,
|
||||||
|
sender: 'user',
|
||||||
|
timestamp: new Date()
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
messages.value.push({
|
||||||
|
text: 'Let me check that for you!',
|
||||||
|
sender: 'assistant',
|
||||||
|
timestamp: new Date()
|
||||||
|
});
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
provide('message', messages);
|
||||||
|
provide('sendMessage', sendMessage);
|
||||||
|
provide('text', text);
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<transition name="fade-slide">
|
||||||
|
<div v-if="isChatVisible" class="dialogue">
|
||||||
|
<div class="chat-header">AI Assistant</div>
|
||||||
|
<div class="chat-body">
|
||||||
|
<DialogueContent></DialogueContent>
|
||||||
|
</div>
|
||||||
|
<div class="row chat-footer">
|
||||||
|
<q-input v-model="text" label="Enter a Message" class="col" />
|
||||||
|
<q-btn :ripple="{ center: true }" color="primary" glossy label="Send"
|
||||||
|
style="width:60px; height:45px; margin-top: 8px; font-size: 14px;" class="col-2">
|
||||||
|
</q-btn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.dialogue {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 150px;
|
||||||
|
right: 30px;
|
||||||
|
width: 300px;
|
||||||
|
height: 400px;
|
||||||
|
background: white;
|
||||||
|
border-radius: 6px;
|
||||||
|
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-header {
|
||||||
|
background: #019547;
|
||||||
|
color: white;
|
||||||
|
padding: 10px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-body {
|
||||||
|
flex: 1;
|
||||||
|
padding: 10px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-footer {
|
||||||
|
padding: 10px;
|
||||||
|
border-top: 0.1px solid #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-wrapper {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.full-width {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.fade-slide-enter-active,
|
||||||
|
.fade-slide-leave-active {
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fade-slide-enter-from,
|
||||||
|
.fade-slide-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(20px);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
10
src/modules/chatbot/components/dialogue-content.vue
Normal file
10
src/modules/chatbot/components/dialogue-content.vue
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import DialoguePhrase from './dialogue-phrase.vue';
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<q-infinite-scroll>
|
||||||
|
<DialoguePhrase />
|
||||||
|
</q-infinite-scroll>
|
||||||
|
</template>
|
||||||
8
src/modules/chatbot/components/dialogue-phrase.vue
Normal file
8
src/modules/chatbot/components/dialogue-phrase.vue
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<q-chat-message sent :text="['What\'s the temperature outside?']">
|
||||||
|
|
||||||
|
</q-chat-message>
|
||||||
|
</template>
|
||||||
|
|
@ -1,23 +1,17 @@
|
||||||
<script setup lang="ts"></script>
|
<script setup lang="ts">
|
||||||
|
import Chatbutton from "src/modules/chatbot/components/chat-button.vue";
|
||||||
|
import ConversationBox from "../components/conversation-box.vue";
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="accessBot">
|
<div>
|
||||||
<q-btn
|
<ConversationBox></ConversationBox>
|
||||||
round
|
<Chatbutton></Chatbutton>
|
||||||
color="primary"
|
|
||||||
size="20px"
|
|
||||||
class="glossy"
|
|
||||||
icon="chat"
|
|
||||||
>
|
|
||||||
</q-btn>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.accessBot {
|
.box-settings {
|
||||||
position: fixed;
|
position: relative;
|
||||||
bottom: 75px;
|
|
||||||
right: 20px;
|
|
||||||
z-index: 9999;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
5
src/modules/chatbot/types/dialogue-message.ts
Normal file
5
src/modules/chatbot/types/dialogue-message.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
export interface Message{
|
||||||
|
text:string;
|
||||||
|
sender: 'user' | 'assistant';
|
||||||
|
timestamp: Date;
|
||||||
|
};
|
||||||
3
src/stores/dialogue-box.ts
Normal file
3
src/stores/dialogue-box.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
import { ref } from "vue";
|
||||||
|
|
||||||
|
export const isChatVisible = ref(false);
|
||||||
Loading…
Reference in New Issue
Block a user