chahuadev
Update README
857cdcf
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chahuadev Group Chat</title>
<style>
:root {
--bg-color: #09090f;
--sidebar-bg: #111118;
--chat-bg: #0d0d14;
--border-color: #1e1e2d;
--text-color: #e2e8f0;
--text-muted: #64748b;
--primary: #3b82f6;
--primary-hover: #2563eb;
--bubble-self: #2563eb;
--bubble-other: #1e1e2d;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body, html {
height: 100%;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
background-color: var(--bg-color);
color: var(--text-color);
overflow: hidden;
}
.app-container {
display: flex;
height: 100%;
}
.sidebar {
width: 260px;
background-color: var(--sidebar-bg);
border-right: 1px solid var(--border-color);
display: flex;
flex-direction: column;
}
.sidebar-header {
padding: 20px 16px;
border-bottom: 1px solid var(--border-color);
font-weight: 600;
font-size: 15px;
display: flex;
align-items: center;
gap: 10px;
}
.sidebar-header svg {
color: #10b981;
}
.channel-list {
flex: 1;
overflow-y: auto;
padding: 12px 8px;
display: flex;
flex-direction: column;
gap: 4px;
}
.channel-item {
padding: 10px 12px;
border-radius: 6px;
cursor: pointer;
font-size: 14px;
display: flex;
align-items: center;
gap: 10px;
color: var(--text-muted);
transition: all 0.2s;
}
.channel-item:hover {
background-color: rgba(255, 255, 255, 0.05);
color: #fff;
}
.channel-item.active {
background-color: rgba(59, 130, 246, 0.15);
color: #fff;
font-weight: 500;
border: 1px solid rgba(59, 130, 246, 0.3);
}
.chat-area {
flex: 1;
display: flex;
flex-direction: column;
background-color: var(--chat-bg);
position: relative;
}
.chat-header {
padding: 16px 20px;
border-bottom: 1px solid var(--border-color);
background-color: rgba(17, 17, 24, 0.8);
backdrop-filter: blur(10px);
z-index: 10;
}
.chat-header h2 {
font-size: 16px;
font-weight: 600;
margin-bottom: 4px;
}
.chat-header p {
font-size: 12px;
color: var(--text-muted);
}
.messages-container {
flex: 1;
padding: 20px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 16px;
}
.message {
display: flex;
max-width: 80%;
animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.message.self {
align-self: flex-end;
flex-direction: row-reverse;
}
.message.other {
align-self: flex-start;
}
.avatar {
width: 32px;
height: 32px;
border-radius: 50%;
background-color: #334155;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
font-weight: bold;
flex-shrink: 0;
margin: 0 10px;
}
.self .avatar {
background-color: #0369a1;
}
.message-content {
display: flex;
flex-direction: column;
}
.self .message-content {
align-items: flex-end;
}
.sender-name {
font-size: 11px;
color: var(--text-muted);
margin-bottom: 4px;
margin-left: 2px;
margin-right: 2px;
}
.bubble {
padding: 10px 14px;
border-radius: 8px;
font-size: 14px;
line-height: 1.4;
position: relative;
word-break: break-word;
}
.self .bubble {
background-color: var(--bubble-self);
color: #fff;
border-top-right-radius: 2px;
}
.other .bubble {
background-color: var(--bubble-other);
border-top-left-radius: 2px;
border: 1px solid rgba(255,255,255,0.05);
}
.time {
font-size: 10px;
color: var(--text-muted);
margin-top: 4px;
}
.input-area {
padding: 16px 20px;
background-color: var(--sidebar-bg);
border-top: 1px solid var(--border-color);
display: flex;
gap: 12px;
align-items: center;
}
.input-wrapper {
flex: 1;
background-color: #1e1e2d;
border-radius: 8px;
padding: 8px 16px;
display: flex;
align-items: center;
border: 1px solid transparent;
transition: border-color 0.2s;
}
.input-wrapper:focus-within {
border-color: var(--primary);
}
.message-input {
flex: 1;
background: transparent;
border: none;
color: #fff;
font-size: 14px;
outline: none;
padding: 4px 0;
font-family: inherit;
}
.send-btn {
background-color: var(--primary);
color: #fff;
border: none;
width: 40px;
height: 40px;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: background-color 0.2s;
flex-shrink: 0;
}
.send-btn:hover {
background-color: var(--primary-hover);
}
.status-bar {
position: absolute;
top: 60px;
left: 50%;
transform: translateX(-50%);
background: rgba(16, 185, 129, 0.1);
border: 1px solid rgba(16, 185, 129, 0.4);
color: #10b981;
padding: 4px 12px;
border-radius: 12px;
font-size: 11px;
display: flex;
align-items: center;
gap: 6px;
z-index: 20;
pointer-events: none;
}
.status-dot {
width: 6px;
height: 6px;
background-color: #10b981;
border-radius: 50%;
box-shadow: 0 0 8px #10b981;
}
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: #334155;
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: #475569;
}
</style>
</head>
<body>
<div class="app-container">
<div class="sidebar">
<div class="sidebar-header">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path>
</svg>
Dev Network
</div>
<div class="channel-list">
<div class="channel-item active">
<span style="color:#64748b">#</span> global-chat
</div>
<div class="channel-item">
<span style="color:#64748b">#</span> announcements
</div>
<div class="channel-item">
<span style="color:#64748b">#</span> updates
</div>
</div>
</div>
<div class="chat-area">
<div class="chat-header">
<h2># global-chat</h2>
<p>System-wide discussion across all Chahuadev tools</p>
<div style="margin-top: 8px; font-size: 11px; color: #fbbf24; background: rgba(251, 191, 36, 0.1); border: 1px solid rgba(251, 191, 36, 0.3); padding: 6px 10px; border-radius: 4px; display: inline-flex; align-items: center; gap: 6px;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
<strong>Under Development:</strong> This local group chat feature is currently still in active development.
</div>
</div>
<div class="status-bar" id="connection-status">
<div class="status-dot"></div>
Connected to local peer network
</div>
<div class="messages-container" id="messages">
<!-- Messages will be injected here -->
<div class="message other">
<div class="avatar">S</div>
<div class="message-content">
<div class="sender-name">System</div>
<div class="bubble">Welcome to the new embedded Global Chat. This UI operates natively within the app without relying on slow external services like Firebase.</div>
<div class="time">Just now</div>
</div>
</div>
</div>
<div class="input-area">
<div class="input-wrapper">
<input type="text" class="message-input" id="msg-input" placeholder="Type a message to #global-chat..." autocomplete="off">
</div>
<button class="send-btn" id="send-btn">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="22" y1="2" x2="11" y2="13"></line>
<polygon points="22 2 15 22 11 13 2 9 22 2"></polygon>
</svg>
</button>
</div>
</div>
</div>
<script>
const msgsContainer = document.getElementById('messages');
const input = document.getElementById('msg-input');
const sendBtn = document.getElementById('send-btn');
let userName = "Me";
function formatTime() {
const now = new Date();
let h = now.getHours();
let m = now.getMinutes();
let ampm = h >= 12 ? 'PM' : 'AM';
h = h % 12;
h = h ? h : 12;
m = m < 10 ? '0' + m : m;
return `${h}:${m} ${ampm}`;
}
function addMessage(text, isSelf = true, sender = "Me") {
if (!text.trim()) return;
const msgDiv = document.createElement('div');
msgDiv.className = `message ${isSelf ? 'self' : 'other'}`;
const initial = sender.charAt(0).toUpperCase();
msgDiv.innerHTML = `
<div class="avatar">${initial}</div>
<div class="message-content">
<div class="sender-name">${sender}</div>
<div class="bubble">${text.replace(/</g, "&lt;").replace(/>/g, "&gt;")}</div>
<div class="time">${formatTime()}</div>
</div>
`;
msgsContainer.appendChild(msgDiv);
msgsContainer.scrollTop = msgsContainer.scrollHeight;
}
// Send on enter key
input.addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
const text = input.value;
addMessage(text, true, userName);
input.value = '';
// Simulate a fast peer response just to demonstrate it's not latent
if(text.toLowerCase().includes('hello') || text.toLowerCase().includes('hi')) {
setTimeout(() => {
addMessage("Hello there! This local chat is much faster right?", false, "Developer");
}, 600);
}
}
});
// Send on button click
sendBtn.addEventListener('click', function() {
const text = input.value;
if (text) {
addMessage(text, true, userName);
input.value = '';
}
});
// Auto-scroll to bottom on load
msgsContainer.scrollTop = msgsContainer.scrollHeight;
// Setup simple WebSocket or IPC channel here in the future
// window.addEventListener('message', (event) => { ... })
</script>
</body>
</html>