style: right drawer is now dynamically expandable by the user to enhance user experience

This commit is contained in:
Lion Arar 2025-10-07 11:09:42 -04:00
parent 0b1ffe4787
commit 72bf750fb8

View File

@ -5,10 +5,34 @@ import { ref } from "vue";
import { useChatApi } from "../composables/chat-api"; import { useChatApi } from "../composables/chat-api";
import { useChatStore } from "src/stores/message-store"; import { useChatStore } from "src/stores/message-store";
// Block to enable editing the width of the drawer
const drawerWidth = ref(370);
let dragging = false
const startDrag = (e: MouseEvent) => {
dragging = true
e.preventDefault()
}
const onDrag = (e: MouseEvent) => {
if (!dragging) return
// calculate new width
const newWidth = window.innerWidth - e.clientX
drawerWidth.value = Math.max(350, Math.min(1000, newWidth)) // min/max width
}
const stopDrag = () => {
dragging = false
}
window.addEventListener('mousemove', onDrag)
window.addEventListener('mouseup', stopDrag)
// Block to handle the incomming and sending of the messages from the user and the ai
const text = ref(''); const text = ref('');
const { messages } = useChatStore(); const { messages } = useChatStore();
const { sendMessage } = useChatApi(); const { sendMessage } = useChatApi();
const handleSend = async () => { const handleSend = async () => {
if (!text.value.trim()) return; if (!text.value.trim()) return;
const userMessage = text.value; const userMessage = text.value;
@ -59,7 +83,8 @@ const handleSend = async () => {
side="right" side="right"
v-model="isChatVisible" v-model="isChatVisible"
class="chat-drawer" class="chat-drawer"
:width="370" style="box-shadow: -4px 0 12px rgba(0,0,0,0.15);"
:width="drawerWidth"
> >
<div class="chat-header">AI Assistant</div> <div class="chat-header">AI Assistant</div>
@ -80,10 +105,32 @@ const handleSend = async () => {
style="margin-left: 10px;" style="margin-left: 10px;"
/> />
</q-form> </q-form>
<div
class="drag-handle"
@mousedown.prevent="startDrag"
></div>
</q-drawer> </q-drawer>
</template> </template>
<style scoped> <style scoped>
.drag-handle {
position: absolute;
top: 0;
left: 0;
/* attach to the left edge of the drawer */
width: 8px;
/* sensitive area for hover */
height: 100%;
/* full height of the drawer */
cursor: ew-resize;
/* horizontal resize cursor */
z-index: 1000;
/* make sure it's above other content */
/* optional: visual feedback */
background-color: rgba(0, 0, 0, 0);
/* invisible but hoverable */
}
.chat-drawer { .chat-drawer {
display: flex; display: flex;
flex-direction: column; flex-direction: column;