first
This commit is contained in:
120
Modules/Chatbot/resources/assets/css/chatbot.css
Normal file
120
Modules/Chatbot/resources/assets/css/chatbot.css
Normal file
@@ -0,0 +1,120 @@
|
||||
/* Message Styling */
|
||||
.message {
|
||||
padding: 8px;
|
||||
margin: 5px 0;
|
||||
border-radius: 10px;
|
||||
max-width: 100%;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
/* User Message (Blue with transparency) */
|
||||
.user-message {
|
||||
background-color: rgba(0, 123, 255, 0.2); /* Blue with 70% opacity */
|
||||
color: black;
|
||||
text-align: right;
|
||||
align-self: flex-end;
|
||||
}
|
||||
|
||||
/* Bot Message (vz-primary with transparency) */
|
||||
.bot-message {
|
||||
background-color: rgba(var(--vz-primary-rgb), 0.2); /* Assuming var(--vz-primary-rgb) holds RGB value */
|
||||
color: black;
|
||||
text-align: left;
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
/* Floating Chatbot Button */
|
||||
#chatbot-toggle {
|
||||
position: fixed;
|
||||
bottom: 45px;
|
||||
right: 38px;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
background-color: var(--vz-primary); /* Using CSS variable */
|
||||
color: white;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
||||
transition: all 0.3s ease-in-out;
|
||||
z-index: 1000; /* Ensure it's above other elements */
|
||||
}
|
||||
|
||||
/* Chatbot Container */
|
||||
#chatbot-container {
|
||||
position: fixed;
|
||||
bottom: 42px;
|
||||
right: 32px;
|
||||
width: 320px;
|
||||
background: white;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
|
||||
font-family: Arial, sans-serif;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
z-index: 1000; /* Ensure it floats above the content */
|
||||
}
|
||||
|
||||
/* Chatbot Header */
|
||||
#chatbot-header {
|
||||
background-color: var(--vz-primary);
|
||||
color: white;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* Close Button */
|
||||
#chatbot-close {
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Chatbot Body */
|
||||
#chatbot-body {
|
||||
height: 250px;
|
||||
overflow-y: auto;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
/* Input and Send Button Styling */
|
||||
#chatbot-input-container {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
margin-top: 10px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#chatbot-input {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 20px;
|
||||
outline: none;
|
||||
font-size: 14px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#chatbot-send {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
color: var(--vz-primary);
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
0
Modules/Chatbot/resources/assets/js/app.js
Normal file
0
Modules/Chatbot/resources/assets/js/app.js
Normal file
47
Modules/Chatbot/resources/assets/js/chatbot.js
Normal file
47
Modules/Chatbot/resources/assets/js/chatbot.js
Normal file
@@ -0,0 +1,47 @@
|
||||
$(document).ready(function() {
|
||||
// Toggle chatbot visibility
|
||||
$('#chatbot-toggle').click(function() {
|
||||
$('#chatbot-container').fadeIn();
|
||||
$('#chatbot-toggle').hide();
|
||||
});
|
||||
|
||||
// Close chatbot
|
||||
$('#chatbot-close').click(function() {
|
||||
$('#chatbot-container').fadeOut();
|
||||
$('#chatbot-toggle').show();
|
||||
});
|
||||
|
||||
// Send message on button click
|
||||
$('#chatbot-send').click(function() {
|
||||
sendMessage();
|
||||
});
|
||||
|
||||
// Send message on "Enter" key
|
||||
$('#chatbot-input').keypress(function(e) {
|
||||
if (e.which == 13) {
|
||||
sendMessage();
|
||||
}
|
||||
});
|
||||
|
||||
function sendMessage() {
|
||||
var message = $('#chatbot-input').val().trim();
|
||||
if (message === '') return;
|
||||
|
||||
$('#chatbot-body').append('<div class="message user-message"><strong>You:</strong> ' + message + '</div>');
|
||||
$('#chatbot-input').val('');
|
||||
$('#chatbot-body').scrollTop($('#chatbot-body')[0].scrollHeight);
|
||||
|
||||
$.ajax({
|
||||
url: '{{ route('chatbot.query') }}',
|
||||
type: 'POST',
|
||||
data: { message: message, _token: '{{ csrf_token() }}' },
|
||||
success: function(response) {
|
||||
$('#chatbot-body').append('<div class="message bot-message"><strong>Bot:</strong> ' + response.reply + '</div>');
|
||||
$('#chatbot-body').scrollTop($('#chatbot-body')[0].scrollHeight);
|
||||
},
|
||||
error: function() {
|
||||
$('#chatbot-body').append('<div class="message bot-message"><strong>Bot:</strong> Sorry, something went wrong.</div>');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
0
Modules/Chatbot/resources/assets/sass/app.scss
Normal file
0
Modules/Chatbot/resources/assets/sass/app.scss
Normal file
0
Modules/Chatbot/resources/views/.gitkeep
Normal file
0
Modules/Chatbot/resources/views/.gitkeep
Normal file
252
Modules/Chatbot/resources/views/chatbot.blade.php
Normal file
252
Modules/Chatbot/resources/views/chatbot.blade.php
Normal file
@@ -0,0 +1,252 @@
|
||||
@push('css')
|
||||
<style>
|
||||
/* Floating Chatbot Button */
|
||||
#chatbot-toggle {
|
||||
position: fixed;
|
||||
bottom: 45px;
|
||||
right: 38px;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
background-color: var(--vz-primary);
|
||||
color: white;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
||||
z-index: 1000;
|
||||
transition: all 0.3s ease-in-out;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
/* Glowing Animation */
|
||||
.glowing-animation {
|
||||
background-color: #F98D1E;
|
||||
box-shadow: 0 0 10px rgba(249, 141, 30, 0.5),
|
||||
0 0 20px rgba(249, 141, 30, 0.4),
|
||||
0 0 30px rgba(249, 141, 30, 0.3);
|
||||
animation: pulseGlow 2s ease-in-out infinite;
|
||||
border-radius: 50%;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
@keyframes pulseGlow {
|
||||
0%, 100% {
|
||||
box-shadow: 0 0 10px rgba(249, 141, 30, 0.4),
|
||||
0 0 20px rgba(249, 141, 30, 0.3),
|
||||
0 0 30px rgba(249, 141, 30, 0.2);
|
||||
}
|
||||
50% {
|
||||
box-shadow: 0 0 20px rgba(249, 141, 30, 0.6),
|
||||
0 0 30px rgba(249, 141, 30, 0.5),
|
||||
0 0 40px rgba(249, 141, 30, 0.4);
|
||||
}
|
||||
}
|
||||
|
||||
/* Chat Container */
|
||||
#chatbot-container {
|
||||
position: fixed;
|
||||
bottom: 42px;
|
||||
right: 36px;
|
||||
width: 340px;
|
||||
height: 400px;
|
||||
background: #fff;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 14px;
|
||||
box-shadow: 0px 8px 24px rgba(0, 0, 0, 0.25);
|
||||
font-family: 'Segoe UI', sans-serif;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
/* Chatbot Header */
|
||||
#chatbot-header {
|
||||
background-color: var(--vz-primary);
|
||||
color: white;
|
||||
padding: 12px 16px;
|
||||
font-size: 16px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Close Button */
|
||||
#chatbot-close {
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Chat Body */
|
||||
#chatbot-body {
|
||||
flex: 1;
|
||||
padding: 12px;
|
||||
overflow-y: auto;
|
||||
background: #f9f9f9;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
/* Message Styles */
|
||||
.message {
|
||||
position: relative;
|
||||
padding: 10px 16px;
|
||||
margin: 6px 0;
|
||||
border-radius: 20px;
|
||||
max-width: 80%;
|
||||
font-size: 14px;
|
||||
line-height: 1.4;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.user-message {
|
||||
background-color: rgba(0, 123, 255, 0.15);
|
||||
color: black;
|
||||
align-self: flex-end;
|
||||
margin-left: auto;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
.bot-message {
|
||||
background-color: rgba(var(--vz-primary-rgb), 0.15);
|
||||
color: black;
|
||||
align-self: flex-start;
|
||||
margin-right: auto;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
/* Typing Indicator */
|
||||
.typing-indicator {
|
||||
font-style: italic;
|
||||
font-size: 13px;
|
||||
color: #888;
|
||||
margin-top: 5px;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
/* Input Area */
|
||||
#chatbot-input-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
border-top: 1px solid #eee;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
#chatbot-input {
|
||||
flex: 1;
|
||||
padding: 10px 15px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 30px;
|
||||
font-size: 14px;
|
||||
outline: none;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
#chatbot-send {
|
||||
background: var(--vz-primary);
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Chatbot Floating Button -->
|
||||
<div id="chatbot-toggle" class="glowing-animation">
|
||||
<i class="ri-message-2-fill" style="font-size: 30px; color: white;"></i>
|
||||
</div>
|
||||
|
||||
<!-- Chatbot UI -->
|
||||
<div id="chatbot-container" style="z-index: 9999">
|
||||
<div id="chatbot-header">
|
||||
Chatbot
|
||||
<span id="chatbot-close">×</span>
|
||||
</div>
|
||||
<div id="chatbot-body"></div>
|
||||
<div id="chatbot-input-container">
|
||||
<input type="text" id="chatbot-input" placeholder="Ask me something...">
|
||||
<button id="chatbot-send">
|
||||
<i class="ri-send-plane-2-fill"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Scripts -->
|
||||
@push('js')
|
||||
{{-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> --}}
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#chatbot-toggle').click(function() {
|
||||
$('#chatbot-container').fadeIn();
|
||||
$(this).hide();
|
||||
});
|
||||
|
||||
$('#chatbot-close').click(function() {
|
||||
$('#chatbot-container').fadeOut();
|
||||
$('#chatbot-toggle').show();
|
||||
});
|
||||
|
||||
$('#chatbot-send').click(sendMessage);
|
||||
$('#chatbot-input').keypress(function(e) {
|
||||
if (e.which == 13) sendMessage();
|
||||
});
|
||||
|
||||
function sendMessage() {
|
||||
const input = $('#chatbot-input');
|
||||
const body = $('#chatbot-body');
|
||||
const message = input.val().trim();
|
||||
|
||||
if (message === '') return;
|
||||
|
||||
body.append('<div class="message user-message">You: ' + message + '</div>');
|
||||
input.val('');
|
||||
body.append('<div class="typing-indicator" id="typing">Bot is typing...</div>');
|
||||
scrollToBottom();
|
||||
|
||||
$.ajax({
|
||||
url: '{{ route('chatbot.query') }}',
|
||||
type: 'POST',
|
||||
data: {
|
||||
message: message,
|
||||
_token: '{{ csrf_token() }}'
|
||||
},
|
||||
success: function(response) {
|
||||
$('#typing').remove();
|
||||
body.append('<div class="message bot-message">Bot: ' + response.reply +
|
||||
'</div>');
|
||||
scrollToBottom();
|
||||
},
|
||||
error: function() {
|
||||
$('#typing').remove();
|
||||
body.append(
|
||||
'<div class="message bot-message">Bot: Sorry, something went wrong.</div>'
|
||||
);
|
||||
scrollToBottom();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function scrollToBottom() {
|
||||
const body = $('#chatbot-body');
|
||||
body.scrollTop(body[0].scrollHeight);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
7
Modules/Chatbot/resources/views/index.blade.php
Normal file
7
Modules/Chatbot/resources/views/index.blade.php
Normal file
@@ -0,0 +1,7 @@
|
||||
@extends('chatbot::layouts.master')
|
||||
|
||||
@section('content')
|
||||
<h1>Hello World</h1>
|
||||
|
||||
<p>Module: {!! config('chatbot.name') !!}</p>
|
||||
@endsection
|
||||
29
Modules/Chatbot/resources/views/layouts/master.blade.php
Normal file
29
Modules/Chatbot/resources/views/layouts/master.blade.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
|
||||
<title>Chatbot Module - {{ config('app.name', 'Laravel') }}</title>
|
||||
|
||||
<meta name="description" content="{{ $description ?? '' }}">
|
||||
<meta name="keywords" content="{{ $keywords ?? '' }}">
|
||||
<meta name="author" content="{{ $author ?? '' }}">
|
||||
|
||||
<!-- Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.bunny.net">
|
||||
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
|
||||
|
||||
{{-- Vite CSS --}}
|
||||
{{-- {{ module_vite('build-chatbot', 'resources/assets/sass/app.scss', storage_path('vite.hot')) }} --}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@yield('content')
|
||||
|
||||
{{-- Vite JS --}}
|
||||
{{-- {{ module_vite('build-chatbot', 'resources/assets/js/app.js', storage_path('vite.hot')) }} --}}
|
||||
</body>
|
||||
Reference in New Issue
Block a user