ui cleanup mobile view also
This commit is contained in:
+103
-35
@@ -15,6 +15,9 @@
|
||||
--border: #2b303a;
|
||||
--accent: #8f9cff;
|
||||
--accent-dim: #737fd3;
|
||||
--danger: #d93d3d;
|
||||
--danger-soft: rgba(217, 61, 61, 0.16);
|
||||
--danger-text: #ffd1d1;
|
||||
--text: #eceff4;
|
||||
--muted: #9aa3b2;
|
||||
--user: #8f9cff;
|
||||
@@ -25,33 +28,40 @@
|
||||
body {
|
||||
background: var(--bg);
|
||||
min-height: 100vh;
|
||||
min-height: 100dvh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
||||
color: var(--text);
|
||||
padding: 1rem;
|
||||
padding: 4.4rem 1rem 1rem;
|
||||
}
|
||||
|
||||
.page-timer {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: fixed;
|
||||
top: 1rem;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
color: var(--muted);
|
||||
border: 1px solid var(--border);
|
||||
color: var(--danger-text);
|
||||
border: 1px solid var(--danger);
|
||||
border-radius: 999px;
|
||||
padding: 0.35rem 0.75rem;
|
||||
font-size: 0.78rem;
|
||||
background: var(--surface);
|
||||
padding: 0.38rem 0.8rem;
|
||||
font-size: 0.82rem;
|
||||
font-weight: 800;
|
||||
background: var(--danger-soft);
|
||||
box-shadow: 0 0 0 1px rgba(217, 61, 61, 0.08), 0 8px 24px rgba(217, 61, 61, 0.08);
|
||||
z-index: 10;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#start-form {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 20px;
|
||||
padding: 2.2rem;
|
||||
padding: 2rem;
|
||||
width: min(360px, 100%);
|
||||
text-align: left;
|
||||
box-shadow: 0 18px 55px rgba(0, 0, 0, 0.22);
|
||||
@@ -67,13 +77,13 @@
|
||||
#start-form p {
|
||||
font-size: 0.9rem;
|
||||
color: var(--muted);
|
||||
margin-bottom: 1.5rem;
|
||||
margin-bottom: 1.35rem;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
#start-form input[type="text"] {
|
||||
width: 100%;
|
||||
padding: 0.75rem 1rem;
|
||||
padding: 0.72rem 0.95rem;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
@@ -88,7 +98,7 @@
|
||||
|
||||
#start-form button {
|
||||
width: 100%;
|
||||
padding: 0.75rem;
|
||||
padding: 0.72rem;
|
||||
background: var(--accent);
|
||||
color: #111318;
|
||||
border: none;
|
||||
@@ -105,7 +115,8 @@
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
width: min(390px, 100%);
|
||||
height: min(600px, calc(100vh - 4.5rem));
|
||||
height: min(620px, calc(100vh - 5.4rem));
|
||||
height: min(620px, calc(100dvh - 5.4rem));
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 20px;
|
||||
@@ -117,23 +128,26 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.6rem;
|
||||
padding: 1rem 1.2rem;
|
||||
padding: 0.9rem 1rem;
|
||||
border-bottom: 1px solid var(--border);
|
||||
font-weight: 700;
|
||||
font-size: 0.95rem;
|
||||
min-height: 52px;
|
||||
}
|
||||
|
||||
.chat-session-id {
|
||||
margin-left: auto;
|
||||
font-size: 0.75rem;
|
||||
font-size: 0.72rem;
|
||||
color: var(--muted);
|
||||
font-weight: 400;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#messages {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
padding: 1rem;
|
||||
padding: 0.9rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
@@ -149,11 +163,12 @@
|
||||
.msg-supporter-wrap { justify-content: flex-start; }
|
||||
|
||||
.msg-user, .msg-supporter {
|
||||
max-width: 75%;
|
||||
padding: 0.6rem 0.9rem;
|
||||
max-width: 78%;
|
||||
padding: 0.58rem 0.85rem;
|
||||
border-radius: 16px;
|
||||
font-size: 0.88rem;
|
||||
line-height: 1.5;
|
||||
line-height: 1.48;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.msg-user {
|
||||
@@ -170,7 +185,7 @@
|
||||
|
||||
.msg-label {
|
||||
display: block;
|
||||
font-size: 0.7rem;
|
||||
font-size: 0.68rem;
|
||||
font-weight: 600;
|
||||
opacity: 0.7;
|
||||
margin-bottom: 2px;
|
||||
@@ -182,7 +197,7 @@
|
||||
|
||||
.msg-time {
|
||||
display: block;
|
||||
font-size: 0.68rem;
|
||||
font-size: 0.66rem;
|
||||
opacity: 0.55;
|
||||
margin-top: 4px;
|
||||
text-align: right;
|
||||
@@ -200,27 +215,41 @@
|
||||
background: var(--bg);
|
||||
padding: 0.25rem 0.75rem;
|
||||
border-radius: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.typing-bubble {
|
||||
display: none;
|
||||
padding: 0 1rem 0.55rem;
|
||||
padding: 0 0.9rem 0.55rem;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.typing-bubble.visible { display: flex; }
|
||||
|
||||
.typing-bubble-inner {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
min-width: 48px;
|
||||
padding: 0.65rem 0.85rem;
|
||||
padding: 0.58rem 0.78rem;
|
||||
background: var(--supporter);
|
||||
border-radius: 16px;
|
||||
border-bottom-left-radius: 4px;
|
||||
}
|
||||
|
||||
.typing-bubble-inner::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 7px;
|
||||
bottom: -4px;
|
||||
width: 9px;
|
||||
height: 9px;
|
||||
background: var(--supporter);
|
||||
transform: rotate(45deg);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.typing-dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
@@ -239,14 +268,15 @@
|
||||
|
||||
#chat-form {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
padding: 0.75rem 1rem;
|
||||
gap: 0.45rem;
|
||||
padding: 0.65rem 0.85rem 0.8rem;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
#chat-form input[type="text"] {
|
||||
flex: 1;
|
||||
padding: 0.6rem 0.9rem;
|
||||
min-width: 0;
|
||||
padding: 0.58rem 0.85rem;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
@@ -259,7 +289,7 @@
|
||||
#chat-form input[type="text"]:focus { border-color: var(--accent); }
|
||||
|
||||
#chat-form button {
|
||||
padding: 0.6rem 1.1rem;
|
||||
padding: 0.58rem 1rem;
|
||||
background: var(--accent);
|
||||
color: #111318;
|
||||
border: none;
|
||||
@@ -268,9 +298,19 @@
|
||||
font-size: 0.88rem;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#chat-form button:hover { background: var(--accent-dim); }
|
||||
|
||||
@media (max-width: 520px) {
|
||||
body { align-items: stretch; padding: 4.2rem 0.75rem 0.75rem; }
|
||||
.page-timer { top: 0.75rem; width: calc(100% - 1.5rem); text-align: center; justify-content: center; }
|
||||
#start-form { align-self: center; padding: 1.45rem; border-radius: 18px; }
|
||||
#chat-container { height: calc(100vh - 5rem); height: calc(100dvh - 5rem); border-radius: 18px; }
|
||||
.chat-session-id { display: none; }
|
||||
.msg-user, .msg-supporter { max-width: 86%; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -291,8 +331,7 @@
|
||||
|
||||
<script>
|
||||
let ws = null;
|
||||
let typingHideTimer = null;
|
||||
let lastTypingSent = 0;
|
||||
let userTypingActive = false;
|
||||
|
||||
function scrollMessages() {
|
||||
const el = document.getElementById('messages');
|
||||
@@ -303,27 +342,51 @@
|
||||
const indicator = document.getElementById('peer-typing');
|
||||
if (!indicator) return;
|
||||
indicator.classList.add('visible');
|
||||
clearTimeout(typingHideTimer);
|
||||
typingHideTimer = setTimeout(() => indicator.classList.remove('visible'), 1400);
|
||||
scrollMessages();
|
||||
}
|
||||
|
||||
function sendUserTyping() {
|
||||
function hideSupporterTyping() {
|
||||
const indicator = document.getElementById('peer-typing');
|
||||
if (indicator) indicator.classList.remove('visible');
|
||||
}
|
||||
|
||||
function sendUserTypingState(state) {
|
||||
if (!ws || ws.readyState !== WebSocket.OPEN || !window.__sessionId) return;
|
||||
const now = Date.now();
|
||||
if (now - lastTypingSent < 500) return;
|
||||
lastTypingSent = now;
|
||||
ws.send(`typing:user:${window.__sessionId}`);
|
||||
ws.send(`typing:user:${state}:${window.__sessionId}`);
|
||||
}
|
||||
|
||||
function startUserTyping() {
|
||||
if (userTypingActive) return;
|
||||
userTypingActive = true;
|
||||
sendUserTypingState('start');
|
||||
}
|
||||
|
||||
function stopUserTyping() {
|
||||
if (!userTypingActive) return;
|
||||
sendUserTypingState('stop');
|
||||
userTypingActive = false;
|
||||
}
|
||||
|
||||
function handleUserTypingInput() {
|
||||
const input = document.getElementById('chat-input');
|
||||
if (input && input.value.trim()) startUserTyping();
|
||||
else stopUserTyping();
|
||||
}
|
||||
|
||||
document.addEventListener('htmx:afterSwap', (e) => {
|
||||
if (e.detail.target.id === 'messages') scrollMessages();
|
||||
});
|
||||
|
||||
document.addEventListener('htmx:beforeRequest', (e) => {
|
||||
if (e.detail.elt && e.detail.elt.id === 'chat-form') stopUserTyping();
|
||||
});
|
||||
|
||||
function resetChat() {
|
||||
stopUserTyping();
|
||||
const oldWs = ws;
|
||||
ws = null;
|
||||
window.__sessionId = null;
|
||||
userTypingActive = false;
|
||||
if (oldWs) oldWs.close();
|
||||
const startForm = document.getElementById('start-form');
|
||||
const chatContainer = document.getElementById('chat-container');
|
||||
@@ -349,11 +412,16 @@
|
||||
resetChat();
|
||||
return;
|
||||
}
|
||||
if (message.data.startsWith('typing:supporter:')) {
|
||||
if (message.data.startsWith('typing:supporter:start:')) {
|
||||
showSupporterTyping();
|
||||
return;
|
||||
}
|
||||
if (message.data.startsWith('typing:supporter:stop:')) {
|
||||
hideSupporterTyping();
|
||||
return;
|
||||
}
|
||||
if (message.data.startsWith('typing:user:')) return;
|
||||
hideSupporterTyping();
|
||||
htmx.trigger('#messages', 'refresh');
|
||||
};
|
||||
ws.onerror = () => console.warn('WebSocket error; polling will continue.');
|
||||
|
||||
Reference in New Issue
Block a user