started development
This commit is contained in:
@@ -0,0 +1 @@
|
||||
/target
|
||||
Generated
+1378
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,26 @@
|
||||
[package]
|
||||
name = "chatapp-frontend"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
yew = { version = "0.21", features = ["csr"] }
|
||||
yew-router = "0.18"
|
||||
gloo = { version = "0.10", features = ["futures", "storage"] }
|
||||
wasm-bindgen = "0.2"
|
||||
wasm-bindgen-futures = "0.4"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
gloo-net = "0.4"
|
||||
web-sys = { version = "0.3", features = [
|
||||
"WebSocket",
|
||||
"MessageEvent",
|
||||
"ErrorEvent",
|
||||
"Event",
|
||||
"CloseEvent",
|
||||
"Window",
|
||||
"Location",
|
||||
"History"
|
||||
]}
|
||||
futures = "0.3"
|
||||
chrono = "0.4"
|
||||
+1095
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Vendored
+153
@@ -0,0 +1,153 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Chat App</title>
|
||||
<link rel="stylesheet" href="/styles-a0f557a2c187e84.css" integrity="sha384-IY1p3eyyGzgt1dx8oous21mdUqg5fUoBJDo0cnEt0Dzc0zNGKH5Z/fRO8S/o/z+X"/>
|
||||
<link rel="modulepreload" href="/chatapp-frontend-2d9721327d80d1a4.js" crossorigin=anonymous integrity="sha384-NUMxiXeKeAJvxebMe8KYjMxliEtODVyz5/Z481fZRPDW2uYnad9e2ra9tGdLMFpa"><link rel="preload" href="/chatapp-frontend-2d9721327d80d1a4_bg.wasm" crossorigin=anonymous integrity="sha384-2mAsbkb1UNVlDtYPNO/P2i3j3N0eQcSD4sqqXRdf0Y5CtCnprvY5LjoqgSeLoJul" as="fetch" type="application/wasm"></head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
<script type="module" nonce="2WTPFE+DH5nuGYeLSROE+A==">
|
||||
import init, * as bindings from '/chatapp-frontend-2d9721327d80d1a4.js';
|
||||
const wasm = await init('/chatapp-frontend-2d9721327d80d1a4_bg.wasm');
|
||||
|
||||
|
||||
window.wasmBindings = bindings;
|
||||
|
||||
|
||||
dispatchEvent(new CustomEvent("TrunkApplicationStarted", {detail: {wasm}}));
|
||||
|
||||
</script><script>"use strict";
|
||||
|
||||
(function () {
|
||||
|
||||
const address = '{{__TRUNK_ADDRESS__}}';
|
||||
const base = '{{__TRUNK_WS_BASE__}}';
|
||||
let protocol = '';
|
||||
protocol =
|
||||
protocol
|
||||
? protocol
|
||||
: window.location.protocol === 'https:'
|
||||
? 'wss'
|
||||
: 'ws';
|
||||
const url = protocol + '://' + address + base + '.well-known/trunk/ws';
|
||||
|
||||
class Overlay {
|
||||
constructor() {
|
||||
// create an overlay
|
||||
this._overlay = document.createElement("div");
|
||||
const style = this._overlay.style;
|
||||
style.height = "100vh";
|
||||
style.width = "100vw";
|
||||
style.position = "fixed";
|
||||
style.top = "0";
|
||||
style.left = "0";
|
||||
style.backgroundColor = "rgba(222, 222, 222, 0.5)";
|
||||
style.fontFamily = "sans-serif";
|
||||
// not sure that's the right approach
|
||||
style.zIndex = "1000000";
|
||||
style.backdropFilter = "blur(1rem)";
|
||||
|
||||
const container = document.createElement("div");
|
||||
// center it
|
||||
container.style.position = "absolute";
|
||||
container.style.top = "30%";
|
||||
container.style.left = "15%";
|
||||
container.style.maxWidth = "85%";
|
||||
|
||||
this._title = document.createElement("div");
|
||||
this._title.innerText = "Build failure";
|
||||
this._title.style.paddingBottom = "2rem";
|
||||
this._title.style.fontSize = "2.5rem";
|
||||
|
||||
this._message = document.createElement("div");
|
||||
this._message.style.whiteSpace = "pre-wrap";
|
||||
|
||||
const icon= document.createElement("div");
|
||||
icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" fill="#dc3545" viewBox="0 0 16 16"><path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/></svg>';
|
||||
this._title.prepend(icon);
|
||||
|
||||
container.append(this._title, this._message);
|
||||
this._overlay.append(container);
|
||||
|
||||
this._inject();
|
||||
window.setInterval(() => {
|
||||
this._inject();
|
||||
}, 250);
|
||||
}
|
||||
|
||||
set reason(reason) {
|
||||
this._message.textContent = reason;
|
||||
}
|
||||
|
||||
_inject() {
|
||||
if (!this._overlay.isConnected) {
|
||||
// prepend it
|
||||
document.body?.prepend(this._overlay);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Client {
|
||||
constructor(url) {
|
||||
this.url = url;
|
||||
this.poll_interval = 5000;
|
||||
this._overlay = null;
|
||||
}
|
||||
|
||||
start() {
|
||||
const ws = new WebSocket(this.url);
|
||||
ws.onmessage = (ev) => {
|
||||
const msg = JSON.parse(ev.data);
|
||||
switch (msg.type) {
|
||||
case "reload":
|
||||
this.reload();
|
||||
break;
|
||||
case "buildFailure":
|
||||
this.buildFailure(msg.data)
|
||||
break;
|
||||
}
|
||||
};
|
||||
ws.onclose = this.onclose;
|
||||
}
|
||||
|
||||
onclose() {
|
||||
window.setTimeout(
|
||||
() => {
|
||||
// when we successfully reconnect, we'll force a
|
||||
// reload (since we presumably lost connection to
|
||||
// trunk due to it being killed, so it will have
|
||||
// rebuilt on restart)
|
||||
const ws = new WebSocket(this.url);
|
||||
ws.onopen = () => window.location.reload();
|
||||
ws.onclose = this.onclose;
|
||||
},
|
||||
this.poll_interval);
|
||||
}
|
||||
|
||||
reload() {
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
buildFailure({reason}) {
|
||||
// also log the console
|
||||
console.error("Build failed:", reason);
|
||||
|
||||
console.debug("Overlay", this._overlay);
|
||||
|
||||
if (!this._overlay) {
|
||||
this._overlay = new Overlay();
|
||||
}
|
||||
this._overlay.reason = reason;
|
||||
}
|
||||
}
|
||||
|
||||
new Client(url).start();
|
||||
|
||||
})()
|
||||
</script></body>
|
||||
</html>
|
||||
+311
@@ -0,0 +1,311 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:root {
|
||||
--blur-amount: 10px;
|
||||
--border-radius: 15px;
|
||||
--glow-color: rgba(255, 255, 255, 0.3);
|
||||
--message-bubble-color: rgba(255, 255, 255, 0.1);
|
||||
--border-color: rgba(255, 255, 255, 0.1);
|
||||
--shadow-color: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
background: linear-gradient(135deg, #1a2a6c, #2a4858, #141E30);
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.app-container {
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.chat-container {
|
||||
flex: 1;
|
||||
margin: 0 2rem;
|
||||
padding: 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
width: 100%;
|
||||
max-width: 1400px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.messages-container {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 1rem;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
backdrop-filter: blur(var(--blur-amount));
|
||||
-webkit-backdrop-filter: blur(var(--blur-amount));
|
||||
border-radius: var(--border-radius);
|
||||
border: 1px solid var(--border-color);
|
||||
box-shadow: 0 4px 24px var(--shadow-color);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.message {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
margin: 0 0;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.profile-picture {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background-size: cover !important;
|
||||
background-position: center !important;
|
||||
background-repeat: no-repeat !important;
|
||||
border-radius: 5px;
|
||||
flex-shrink: 0;
|
||||
box-shadow: 0 2px 8px var(--shadow-color);
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.message-bubble {
|
||||
background: var(--message-bubble-color);
|
||||
backdrop-filter: blur(var(--blur-amount));
|
||||
-webkit-backdrop-filter: blur(var(--blur-amount));
|
||||
padding: 0.75rem;
|
||||
border-radius: 0 var(--border-radius) var(--border-radius) var(--border-radius);
|
||||
flex-grow: 1;
|
||||
position: relative;
|
||||
border: 1px solid var(--border-color);
|
||||
box-shadow: 0 2px 12px var(--shadow-color);
|
||||
}
|
||||
|
||||
.message-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.username {
|
||||
font-weight: 600;
|
||||
font-size: 0.9rem;
|
||||
color: #fff;
|
||||
text-shadow: 0 2px 4px var(--shadow-color);
|
||||
}
|
||||
|
||||
.timestamp {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.message-content {
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
.message-form {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
padding: 1rem;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
backdrop-filter: blur(var(--blur-amount));
|
||||
-webkit-backdrop-filter: blur(var(--blur-amount));
|
||||
border-radius: var(--border-radius);
|
||||
border: 1px solid var(--border-color);
|
||||
box-shadow: 0 4px 24px var(--shadow-color);
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
.message-input {
|
||||
flex: 1;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--border-radius);
|
||||
padding: 0.8rem 1rem;
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
resize: vertical;
|
||||
min-height: 1.5rem;
|
||||
max-height: 150px;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 8px var(--shadow-color);
|
||||
}
|
||||
|
||||
.message-input:hover, .message-input:focus {
|
||||
border-color: var(--glow-color);
|
||||
box-shadow: 0 0 15px var(--glow-color);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.send-button {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--border-radius);
|
||||
padding: 0.8rem 1.5rem;
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 8px var(--shadow-color);
|
||||
}
|
||||
|
||||
.send-button:hover {
|
||||
border-color: var(--glow-color);
|
||||
box-shadow: 0 0 15px var(--glow-color);
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.navbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 1rem 2rem;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
backdrop-filter: blur(var(--blur-amount));
|
||||
-webkit-backdrop-filter: blur(var(--blur-amount));
|
||||
border: none;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
box-shadow: 0 4px 24px var(--shadow-color);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.nav-brand {
|
||||
font-size: 1.5rem;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
text-shadow: 0 2px 4px var(--shadow-color);
|
||||
}
|
||||
|
||||
/* Login styles */
|
||||
.login-container {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 90%;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
padding: 2rem;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
backdrop-filter: blur(var(--blur-amount));
|
||||
-webkit-backdrop-filter: blur(var(--blur-amount));
|
||||
border-radius: var(--border-radius);
|
||||
border: 1px solid var(--border-color);
|
||||
box-shadow: 0 4px 24px var(--shadow-color);
|
||||
}
|
||||
|
||||
.login-title {
|
||||
font-size: 1.5rem;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
color: white;
|
||||
text-shadow: 0 2px 4px var(--shadow-color);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.login-input {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--border-radius);
|
||||
padding: 0.8rem 1rem;
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 8px var(--shadow-color);
|
||||
}
|
||||
|
||||
.login-input:hover, .login-input:focus {
|
||||
border-color: var(--glow-color);
|
||||
box-shadow: 0 0 15px var(--glow-color);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.login-input::placeholder {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
}
|
||||
|
||||
.login-button {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--border-radius);
|
||||
padding: 0.8rem 1.5rem;
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 8px var(--shadow-color);
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.login-button:hover {
|
||||
border-color: var(--glow-color);
|
||||
box-shadow: 0 0 15px var(--glow-color);
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.login-text {
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
text-align: center;
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
|
||||
.login-link {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.login-link:hover {
|
||||
text-shadow: 0 0 10px var(--glow-color);
|
||||
}
|
||||
|
||||
.login-error {
|
||||
background: rgba(255, 0, 0, 0.1);
|
||||
border: 1px solid rgba(255, 0, 0, 0.3);
|
||||
border-radius: var(--border-radius);
|
||||
padding: 0.8rem 1.5rem;
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
text-align: center;
|
||||
backdrop-filter: blur(var(--blur-amount));
|
||||
-webkit-backdrop-filter: blur(var(--blur-amount));
|
||||
box-shadow: 0 2px 8px var(--shadow-color);
|
||||
}
|
||||
|
||||
/* Custom scrollbar */
|
||||
.messages-container::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
.messages-container::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.messages-container::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.messages-container::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Chat App</title>
|
||||
<link data-trunk rel="css" href="styles.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,99 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use yew::prelude::*;
|
||||
use web_sys::HtmlInputElement;
|
||||
use chrono::prelude::*;
|
||||
use crate::hooks::websocket::use_websocket;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct RealTimeMessage {
|
||||
pub message_id: i32,
|
||||
pub user_id: i32,
|
||||
pub display_name: String,
|
||||
pub created_at: i64,
|
||||
pub content: String,
|
||||
}
|
||||
|
||||
#[function_component(Chat)]
|
||||
pub fn chat() -> Html {
|
||||
let ws = use_websocket("ws://localhost:8000/messenger/connect/1");
|
||||
let input_ref = use_node_ref();
|
||||
let dark_theme = use_state(|| true);
|
||||
|
||||
// let theme_toggle = {
|
||||
// let dark_theme = dark_theme.clone();
|
||||
// Callback::from(move |_| {
|
||||
// dark_theme.set(!*dark_theme);
|
||||
// })
|
||||
// };
|
||||
|
||||
let onsubmit = {
|
||||
let ws = ws.ws.clone();
|
||||
let input_ref = input_ref.clone();
|
||||
|
||||
Callback::from(move |e: SubmitEvent| {
|
||||
e.prevent_default();
|
||||
if let Some(input) = input_ref.cast::<HtmlInputElement>() {
|
||||
let message = input.value();
|
||||
if !message.is_empty() {
|
||||
ws.send_with_str(&message).unwrap();
|
||||
input.set_value("");
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
html! {
|
||||
<div class={classes!("app-container", if *dark_theme { "dark-theme" } else { "light-theme" })}>
|
||||
<nav class="navbar">
|
||||
<div class="nav-brand">{"Chat App"}</div>
|
||||
// <div class="theme-toggle">
|
||||
// <button onclick={theme_toggle} class="theme-button">
|
||||
// if *dark_theme {
|
||||
// {"🌞"}
|
||||
// } else {
|
||||
// {"🌙"}
|
||||
// }
|
||||
// </button>
|
||||
// </div>
|
||||
</nav>
|
||||
<div class="chat-container">
|
||||
<div class="messages-container">
|
||||
{ws.messages.messages().iter().map(|msg| {
|
||||
let timestamp = Local.timestamp_millis_opt(msg.created_at).unwrap();
|
||||
let formatted_time = timestamp.format("%d/%m/%y %H:%M").to_string();
|
||||
let userid = msg.user_id;
|
||||
|
||||
html! {
|
||||
<div class="message">
|
||||
<div class="profile-picture" style={ format!(
|
||||
"background-image: url('http://localhost:8000/static/pfp/{userid}.png')"
|
||||
)}></div>
|
||||
<div class="message-bubble">
|
||||
<div class="message-header">
|
||||
<span class="username">{&msg.display_name}</span>
|
||||
<span class="timestamp">{formatted_time}</span>
|
||||
</div>
|
||||
<div class="message-content">{&msg.content}</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}).collect::<Html>()}
|
||||
</div>
|
||||
if let Some(error) = (*ws.error).as_ref() {
|
||||
<div class="error-message">
|
||||
{format!("Error: {}", error)}
|
||||
</div>
|
||||
}
|
||||
<form {onsubmit} class="message-form">
|
||||
<input
|
||||
type="text"
|
||||
ref={input_ref}
|
||||
class="message-input"
|
||||
placeholder="Type a message..."
|
||||
/>
|
||||
<button type="submit" class="send-button">{"Send"}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
use gloo_net::http::Request;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use yew::prelude::*;
|
||||
use yew_router::{navigator, prelude::*};
|
||||
use gloo::storage::{LocalStorage, Storage};
|
||||
use web_sys::HtmlInputElement;
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen_futures::spawn_local;
|
||||
|
||||
use crate::Route;
|
||||
|
||||
#[function_component(Login)]
|
||||
pub fn login_page() -> Html {
|
||||
let navigator = use_navigator().unwrap();
|
||||
let username_ref = use_node_ref();
|
||||
let password_ref = use_node_ref();
|
||||
let login_success = use_state(|| true);
|
||||
|
||||
let navigator_clone = navigator.clone();
|
||||
let username_ref_clone = username_ref.clone();
|
||||
let password_ref_clone = password_ref.clone();
|
||||
let login_success_clone = login_success.clone();
|
||||
let onsubmit = Callback::from(move |e: SubmitEvent| {
|
||||
e.prevent_default();
|
||||
let username = username_ref_clone.cast::<HtmlInputElement>().unwrap().value();
|
||||
let password = password_ref_clone.cast::<HtmlInputElement>().unwrap().value();
|
||||
|
||||
// TODO: Replace this with actual authentication
|
||||
// For now, we'll just set a dummy token
|
||||
if !( username.is_empty() || password.is_empty() ) {
|
||||
let navigator = navigator_clone.clone();
|
||||
let login_success = login_success_clone.clone();
|
||||
spawn_local(async move {
|
||||
match login(username, password).await {
|
||||
Ok(_) => navigator.push(&Route::Chat),
|
||||
Err(_) => login_success.set(false),
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
let go_to_signup = {
|
||||
let navigator_clone = navigator.clone();
|
||||
Callback::from(move |_| {
|
||||
navigator_clone.push(&Route::Signup);
|
||||
})
|
||||
};
|
||||
|
||||
html! {
|
||||
<div class="login-container">
|
||||
<form {onsubmit} class="login-form">
|
||||
<h2 class="login-title">{"Login"}</h2>
|
||||
<input
|
||||
ref={username_ref}
|
||||
class="login-input"
|
||||
type="text"
|
||||
id="username"
|
||||
name="username"
|
||||
placeholder="Username"
|
||||
/>
|
||||
<input
|
||||
ref={password_ref}
|
||||
class="login-input"
|
||||
type="password"
|
||||
id="password"
|
||||
name="password"
|
||||
placeholder="Password"
|
||||
/>
|
||||
<button class="login-button" type="submit">{"Login"}</button>
|
||||
{
|
||||
if !(*login_success) {
|
||||
html! {
|
||||
<p class="login-error">{"Incorrect username or password"}</p>
|
||||
}
|
||||
} else {
|
||||
html! {}
|
||||
}
|
||||
}
|
||||
|
||||
<p class="login-text">{"Don't have an account?"}</p>
|
||||
<a onclick={go_to_signup}
|
||||
href=""
|
||||
class="login-button"
|
||||
>
|
||||
{"Create Account"}
|
||||
</a>
|
||||
</form>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct LoginRequest {
|
||||
username: String,
|
||||
password: String,
|
||||
}
|
||||
|
||||
async fn login(username: String, password: String) -> Result<(), String> {
|
||||
let login_request = LoginRequest {
|
||||
username,
|
||||
password,
|
||||
};
|
||||
|
||||
match Request::post("http://127.0.0.1:8000/login")
|
||||
.json(&login_request)
|
||||
.map_err(|e| e.to_string())?
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| e.to_string())?
|
||||
.status()
|
||||
{
|
||||
200 => Ok(()),
|
||||
_ => Err("Login failed".to_string()),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
use gloo_net::http::Request;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use yew::{function_component, html, use_node_ref, use_state, Callback, Html, SubmitEvent};
|
||||
use yew_router::{navigator, prelude::*};
|
||||
use gloo::storage::{LocalStorage, Storage};
|
||||
use web_sys::HtmlInputElement;
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen_futures::spawn_local;
|
||||
|
||||
use crate::Route;
|
||||
|
||||
#[function_component(Signup)]
|
||||
pub fn signup_page() -> Html {
|
||||
let navigator = use_navigator().unwrap();
|
||||
let username_ref = use_node_ref();
|
||||
let password_ref = use_node_ref();
|
||||
let confirm_password_ref = use_node_ref();
|
||||
let signup_error = use_state(|| None::<String>);
|
||||
|
||||
let navigator_clone = navigator.clone();
|
||||
let username_ref_clone = username_ref.clone();
|
||||
let password_ref_clone = password_ref.clone();
|
||||
let confirm_password_ref_clone = confirm_password_ref.clone();
|
||||
let signup_error_clone = signup_error.clone();
|
||||
|
||||
let onsubmit = Callback::from(move |e: SubmitEvent| {
|
||||
e.prevent_default();
|
||||
let username = username_ref_clone.cast::<HtmlInputElement>().unwrap().value();
|
||||
let password = password_ref_clone.cast::<HtmlInputElement>().unwrap().value();
|
||||
let confirm_password = confirm_password_ref_clone.cast::<HtmlInputElement>().unwrap().value();
|
||||
|
||||
if username.is_empty() || password.is_empty() {
|
||||
signup_error_clone.set(Some("Please fill in all fields".to_string()));
|
||||
return;
|
||||
}
|
||||
|
||||
if password != confirm_password {
|
||||
signup_error_clone.set(Some("Passwords do not match".to_string()));
|
||||
return;
|
||||
}
|
||||
|
||||
let navigator = navigator_clone.clone();
|
||||
let signup_error = signup_error_clone.clone();
|
||||
spawn_local(async move {
|
||||
match signup(username, password).await {
|
||||
Ok(_) => navigator.push(&Route::Chat),
|
||||
Err(e) => signup_error.set(Some(e)),
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
let go_to_login = {
|
||||
let navigator = navigator.clone();
|
||||
Callback::from(move |_| {
|
||||
navigator.push(&Route::Login);
|
||||
})
|
||||
};
|
||||
|
||||
html! {
|
||||
<div class="login-container">
|
||||
<form {onsubmit} class="login-form">
|
||||
<h2 class="login-title">{"Sign Up"}</h2>
|
||||
<input
|
||||
ref={username_ref}
|
||||
class="login-input"
|
||||
type="text"
|
||||
id="username"
|
||||
name="username"
|
||||
placeholder="Username"
|
||||
/>
|
||||
<input
|
||||
ref={password_ref}
|
||||
class="login-input"
|
||||
type="password"
|
||||
id="password"
|
||||
name="password"
|
||||
placeholder="Password"
|
||||
/>
|
||||
<input
|
||||
ref={confirm_password_ref}
|
||||
class="login-input"
|
||||
type="password"
|
||||
id="confirm_password"
|
||||
name="confirm_password"
|
||||
placeholder="Confirm Password"
|
||||
/>
|
||||
<button class="login-button" type="submit">{"Sign Up"}</button>
|
||||
{
|
||||
if let Some(error) = (*signup_error).clone() {
|
||||
html! {
|
||||
<p class="login-error">{error}</p>
|
||||
}
|
||||
} else {
|
||||
html! {}
|
||||
}
|
||||
}
|
||||
|
||||
<p class="login-text">{"Already have an account?"}</p>
|
||||
<a onclick={go_to_login}
|
||||
href=""
|
||||
class="login-button"
|
||||
>
|
||||
{"Login"}
|
||||
</a>
|
||||
</form>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct SignupRequest {
|
||||
username: String,
|
||||
password: String,
|
||||
}
|
||||
|
||||
async fn signup(username: String, password: String) -> Result<(), String> {
|
||||
let signup_request = SignupRequest {
|
||||
username,
|
||||
password,
|
||||
};
|
||||
|
||||
match Request::post("http://127.0.0.1:8000/signup")
|
||||
.json(&signup_request)
|
||||
.map_err(|e| e.to_string())?
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| e.to_string())?
|
||||
.status()
|
||||
{
|
||||
200 => Ok(()),
|
||||
409 => Err("Username already exists".to_string()),
|
||||
x => Err(format!("Signup failed with status code {}", x)),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
use yew::prelude::*;
|
||||
use web_sys::{WebSocket, MessageEvent, ErrorEvent};
|
||||
use wasm_bindgen::{prelude::*, JsCast};
|
||||
use std::rc::Rc;
|
||||
use crate::components::chat::RealTimeMessage;
|
||||
|
||||
pub struct UseWebSocketHandle {
|
||||
pub ws: Rc<WebSocket>,
|
||||
pub messages: UseReducerHandle<MessagesState>,
|
||||
pub error: UseStateHandle<Option<String>>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct MessagesState {
|
||||
messages: Vec<RealTimeMessage>,
|
||||
}
|
||||
|
||||
pub enum MessagesAction {
|
||||
AddMessage(RealTimeMessage),
|
||||
}
|
||||
|
||||
impl Reducible for MessagesState {
|
||||
type Action = MessagesAction;
|
||||
|
||||
fn reduce(self: Rc<Self>, action: Self::Action) -> Rc<Self> {
|
||||
match action {
|
||||
MessagesAction::AddMessage(msg) => {
|
||||
let mut new_messages = self.messages.clone();
|
||||
new_messages.push(msg);
|
||||
Rc::new(MessagesState {
|
||||
messages: new_messages,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MessagesState {
|
||||
pub fn messages(&self) -> Vec<RealTimeMessage> {
|
||||
self.messages.clone()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[hook]
|
||||
pub fn use_websocket(url: &str) -> UseWebSocketHandle {
|
||||
use web_sys::js_sys;
|
||||
|
||||
let messages = use_reducer(|| MessagesState { messages: Vec::new() });
|
||||
let error = use_state(|| None::<String>);
|
||||
|
||||
let ws = use_state_eq(|| {
|
||||
Rc::new(WebSocket::new(url).unwrap_or_else(|e| panic!("Failed to open WebSocket: {:?}", e)))
|
||||
});
|
||||
|
||||
{
|
||||
let messages = messages.clone();
|
||||
let error = error.clone();
|
||||
let ws = (*ws).clone();
|
||||
|
||||
use_effect_with((), move |_| {
|
||||
let ws_clone = ws.clone();
|
||||
let error_clone = error.clone();
|
||||
|
||||
// Set up message handler
|
||||
let onmessage_callback = {
|
||||
let messages = messages.clone();
|
||||
Closure::wrap(Box::new(move |e: MessageEvent| {
|
||||
if let Ok(txt) = e.data().dyn_into::<js_sys::JsString>() {
|
||||
if let Ok(msg) = serde_json::from_str::<RealTimeMessage>(&txt.as_string().unwrap()) {
|
||||
messages.dispatch(MessagesAction::AddMessage(msg));
|
||||
} else {
|
||||
error_clone.set(Some("Failed to parse message".to_string()));
|
||||
}
|
||||
}
|
||||
}) as Box<dyn FnMut(MessageEvent)>)
|
||||
};
|
||||
|
||||
ws.set_onmessage(Some(onmessage_callback.as_ref().unchecked_ref()));
|
||||
onmessage_callback.forget();
|
||||
|
||||
// Set up error handler
|
||||
let error_clone = error.clone();
|
||||
let onerror_callback = Closure::wrap(Box::new(move |e: ErrorEvent| {
|
||||
error_clone.set(Some(e.message()));
|
||||
}) as Box<dyn FnMut(ErrorEvent)>);
|
||||
|
||||
ws.set_onerror(Some(onerror_callback.as_ref().unchecked_ref()));
|
||||
onerror_callback.forget();
|
||||
|
||||
move || {
|
||||
ws_clone.close().unwrap_or_else(|_| {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
UseWebSocketHandle {
|
||||
ws: (*ws).clone(),
|
||||
messages,
|
||||
error,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
use yew::prelude::*;
|
||||
use yew_router::prelude::*;
|
||||
use gloo::storage::{LocalStorage, Storage};
|
||||
|
||||
mod hooks {
|
||||
pub mod websocket;
|
||||
}
|
||||
|
||||
mod components {
|
||||
pub mod chat;
|
||||
pub mod signup;
|
||||
pub mod login;
|
||||
}
|
||||
|
||||
use components::{
|
||||
chat::Chat,
|
||||
login::Login,
|
||||
signup::Signup,
|
||||
};
|
||||
|
||||
#[derive(Clone, Routable, PartialEq)]
|
||||
enum Route {
|
||||
#[at("/")]
|
||||
Root,
|
||||
#[at("/login")]
|
||||
Login,
|
||||
#[at("/signup")]
|
||||
Signup,
|
||||
#[at("/chat")]
|
||||
Chat,
|
||||
#[not_found]
|
||||
#[at("/404")]
|
||||
NotFound,
|
||||
}
|
||||
|
||||
fn switch(route: Route) -> Html {
|
||||
match route {
|
||||
Route::Root => html! { <Redirect<Route> to={Route::Login}/> },
|
||||
Route::Login => html! { <Login /> },
|
||||
Route::Signup => html! { <Signup /> },
|
||||
Route::Chat => {
|
||||
if let Ok(token) = LocalStorage::get::<String>("auth_token") {
|
||||
html! { <Chat /> }
|
||||
} else {
|
||||
html! { <Redirect<Route> to={Route::Login}/> }
|
||||
}
|
||||
}
|
||||
Route::NotFound => html! { <h1>{"404 Not Found"}</h1> },
|
||||
}
|
||||
}
|
||||
|
||||
#[function_component(App)]
|
||||
fn app() -> Html {
|
||||
html! {
|
||||
<BrowserRouter>
|
||||
<Switch<Route> render={switch} />
|
||||
</BrowserRouter>
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
yew::Renderer::<App>::new().render();
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:root {
|
||||
--blur-amount: 10px;
|
||||
--border-radius: 15px;
|
||||
--glow-color: rgba(255, 255, 255, 0.3);
|
||||
--message-bubble-color: rgba(255, 255, 255, 0.1);
|
||||
--border-color: rgba(255, 255, 255, 0.1);
|
||||
--shadow-color: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
background: linear-gradient(135deg, #1a2a6c, #2a4858, #141E30);
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.app-container {
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.chat-container {
|
||||
flex: 1;
|
||||
margin: 0 2rem;
|
||||
padding: 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
width: 100%;
|
||||
max-width: 1400px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.messages-container {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 1rem;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
backdrop-filter: blur(var(--blur-amount));
|
||||
-webkit-backdrop-filter: blur(var(--blur-amount));
|
||||
border-radius: var(--border-radius);
|
||||
border: 1px solid var(--border-color);
|
||||
box-shadow: 0 4px 24px var(--shadow-color);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.message {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
margin: 0 0;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.profile-picture {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background-size: cover !important;
|
||||
background-position: center !important;
|
||||
background-repeat: no-repeat !important;
|
||||
border-radius: 5px;
|
||||
flex-shrink: 0;
|
||||
box-shadow: 0 2px 8px var(--shadow-color);
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.message-bubble {
|
||||
background: var(--message-bubble-color);
|
||||
backdrop-filter: blur(var(--blur-amount));
|
||||
-webkit-backdrop-filter: blur(var(--blur-amount));
|
||||
padding: 0.75rem;
|
||||
border-radius: 0 var(--border-radius) var(--border-radius) var(--border-radius);
|
||||
flex-grow: 1;
|
||||
position: relative;
|
||||
border: 1px solid var(--border-color);
|
||||
box-shadow: 0 2px 12px var(--shadow-color);
|
||||
}
|
||||
|
||||
.message-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.username {
|
||||
font-weight: 600;
|
||||
font-size: 0.9rem;
|
||||
color: #fff;
|
||||
text-shadow: 0 2px 4px var(--shadow-color);
|
||||
}
|
||||
|
||||
.timestamp {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.message-content {
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
.message-form {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
padding: 1rem;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
backdrop-filter: blur(var(--blur-amount));
|
||||
-webkit-backdrop-filter: blur(var(--blur-amount));
|
||||
border-radius: var(--border-radius);
|
||||
border: 1px solid var(--border-color);
|
||||
box-shadow: 0 4px 24px var(--shadow-color);
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
.message-input {
|
||||
flex: 1;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--border-radius);
|
||||
padding: 0.8rem 1rem;
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
resize: vertical;
|
||||
min-height: 1.5rem;
|
||||
max-height: 150px;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 8px var(--shadow-color);
|
||||
}
|
||||
|
||||
.message-input:hover, .message-input:focus {
|
||||
border-color: var(--glow-color);
|
||||
box-shadow: 0 0 15px var(--glow-color);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.send-button {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--border-radius);
|
||||
padding: 0.8rem 1.5rem;
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 8px var(--shadow-color);
|
||||
}
|
||||
|
||||
.send-button:hover {
|
||||
border-color: var(--glow-color);
|
||||
box-shadow: 0 0 15px var(--glow-color);
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.navbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 1rem 2rem;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
backdrop-filter: blur(var(--blur-amount));
|
||||
-webkit-backdrop-filter: blur(var(--blur-amount));
|
||||
border: none;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
box-shadow: 0 4px 24px var(--shadow-color);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.nav-brand {
|
||||
font-size: 1.5rem;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
text-shadow: 0 2px 4px var(--shadow-color);
|
||||
}
|
||||
|
||||
/* Login styles */
|
||||
.login-container {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 90%;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
padding: 2rem;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
backdrop-filter: blur(var(--blur-amount));
|
||||
-webkit-backdrop-filter: blur(var(--blur-amount));
|
||||
border-radius: var(--border-radius);
|
||||
border: 1px solid var(--border-color);
|
||||
box-shadow: 0 4px 24px var(--shadow-color);
|
||||
}
|
||||
|
||||
.login-title {
|
||||
font-size: 1.5rem;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
color: white;
|
||||
text-shadow: 0 2px 4px var(--shadow-color);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.login-input {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--border-radius);
|
||||
padding: 0.8rem 1rem;
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 8px var(--shadow-color);
|
||||
}
|
||||
|
||||
.login-input:hover, .login-input:focus {
|
||||
border-color: var(--glow-color);
|
||||
box-shadow: 0 0 15px var(--glow-color);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.login-input::placeholder {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
}
|
||||
|
||||
.login-button {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--border-radius);
|
||||
padding: 0.8rem 1.5rem;
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 8px var(--shadow-color);
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.login-button:hover {
|
||||
border-color: var(--glow-color);
|
||||
box-shadow: 0 0 15px var(--glow-color);
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.login-text {
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
text-align: center;
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
|
||||
.login-link {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.login-link:hover {
|
||||
text-shadow: 0 0 10px var(--glow-color);
|
||||
}
|
||||
|
||||
.login-error {
|
||||
background: rgba(255, 0, 0, 0.1);
|
||||
border: 1px solid rgba(255, 0, 0, 0.3);
|
||||
border-radius: var(--border-radius);
|
||||
padding: 0.8rem 1.5rem;
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
text-align: center;
|
||||
backdrop-filter: blur(var(--blur-amount));
|
||||
-webkit-backdrop-filter: blur(var(--blur-amount));
|
||||
box-shadow: 0 2px 8px var(--shadow-color);
|
||||
}
|
||||
|
||||
/* Custom scrollbar */
|
||||
.messages-container::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
.messages-container::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.messages-container::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.messages-container::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
Reference in New Issue
Block a user