homepage/src/main/kte/Index.kte
2025-12-14 03:40:05 +01:00

162 lines
No EOL
6.6 KiB
Text

@import at.dokkae.homepage.templates.IndexTemplate
@import at.dokkae.homepage.templates.MessageTemplate
@import gg.jte.support.ForSupport
@param model: IndexTemplate
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Dokkae's Chat</title>
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.8/dist/htmx.min.js" integrity="sha384-/TgkGk7p307TH7EXJDuUlgG3Ce1UVolAOFopFekQkkXihi5u/6OCvVKyz1W+idaz" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/htmx-ext-sse@2.2.4" integrity="sha384-A986SAtodyH8eg8x8irJnYUk7i9inVQqYigD6qZ9evobksGNIXfeFvDwLSHcp31N" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
<style>
/* Custom scrollbar */
.scrollbar-custom::-webkit-scrollbar {
width: 8px;
}
.scrollbar-custom::-webkit-scrollbar-track {
background: #1a1a1a;
border-radius: 4px;
}
.scrollbar-custom::-webkit-scrollbar-thumb {
background: #444;
border-radius: 4px;
}
.scrollbar-custom::-webkit-scrollbar-thumb:hover {
background: #555;
}
/* Animation for new messages */
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.animate-slide-in.htmx-added {
opacity: 0;
}
.animate-slide-in {
opacity: 1;
animation: slideIn 0.3s ease-out;
}
/* Different border colors */
.message-border-red {
background-color: #ffb3ba !important;
}
.message-border-orange {
background-color: #ffdfba !important;
}
.message-border-yellow {
background-color: #ffffba !important;
}
.message-border-green {
background-color: #baffc9 !important;
}
.message-border-blue {
background-color: #bae1ff !important;
}
.message-border-pink {
background-color: #fddfdf !important;
}
</style>
</head>
<body hx-ext="sse" class="bg-neutral-900 text-neutral-100 min-h-screen overflow-hidden">
<main class="flex flex-col h-screen max-w-6xl mx-auto px-4 md:px-6">
<!-- Header -->
<header class="py-5 border-b border-neutral-800 shrink-0">
<h1 class="text-xl md:text-2xl font-bold text-white">Dokkae's Chat</h1>
</header>
<!-- Messages Container - CSS-only scroll to bottom -->
<div id="messages-container" class="flex-1 flex flex-col-reverse overflow-y-auto overflow-x-hidden scrollbar-custom py-4">
<div id="messages" class="flex flex-col-reverse" sse-connect="/message-events" sse-swap="message" hx-swap="afterbegin">
@for (message in model.messages)
@template.partials.Message(MessageTemplate(message))
@endfor
</div>
</div>
<!-- Message Form -->
<form class="bg-neutral-800/50 border border-neutral-700 rounded-lg p-4 mb-4 mt-2 shrink-0"
hx-post="/messages"
hx-swap="none"
hx-on::after-request="if(event.detail.successful)document.getElementById('message-input').value = ''">
<div class="flex flex-col md:flex-row gap-3">
<!-- Username input -->
<div class="flex-1 md:flex-none md:w-48">
<div class="relative">
<input id="username-input"
type="text"
name="author"
placeholder="Name (optional)"
class="w-full bg-neutral-800 border border-neutral-700 rounded-lg py-3 px-4 text-neutral-100 placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition">
</div>
</div>
<!-- Message input -->
<div class="flex-1">
<div class="flex flex-row gap-3">
<div class="relative flex-1">
<input id="message-input"
type="text"
name="message"
placeholder="Your message..."
required
autocomplete="off"
class="w-full bg-neutral-800 border border-neutral-700 rounded-lg py-3 px-4 text-neutral-100 placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition">
</div>
<!-- Send button -->
<button type="submit"
class="bg-rose-200 hover:bg-rose-300 text-black font-semibold py-3 px-6 rounded-lg transition duration-200 flex items-center justify-center gap-2">
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="Communication / Paper_Plane">
<path id="Vector" d="M10.3078 13.6923L15.1539 8.84619M20.1113 5.88867L16.0207 19.1833C15.6541 20.3747 15.4706 20.9707 15.1544 21.1683C14.8802 21.3396 14.5406 21.3683 14.2419 21.2443C13.8975 21.1014 13.618 20.5433 13.0603 19.428L10.4694 14.2461C10.3809 14.0691 10.3366 13.981 10.2775 13.9043C10.225 13.8363 10.1645 13.7749 10.0965 13.7225C10.0215 13.6647 9.93486 13.6214 9.76577 13.5369L4.57192 10.9399C3.45662 10.3823 2.89892 10.1032 2.75601 9.75879C2.63207 9.4601 2.66033 9.12023 2.83169 8.84597C3.02928 8.52974 3.62523 8.34603 4.81704 7.97932L18.1116 3.88867C19.0486 3.60038 19.5173 3.45635 19.8337 3.57253C20.1094 3.67373 20.3267 3.89084 20.4279 4.16651C20.544 4.48283 20.3999 4.95126 20.1119 5.88729L20.1113 5.88867Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</g>
</svg>
</button>
</div>
</div>
</div>
</form>
<!-- Footer -->
<footer class="border-t border-neutral-800 py-4 shrink-0">
<p class="text-sm text-neutral-500 text-center">
No auth — anyone can post. Open source at
<a href="https://github.com/dokkae6949/homepage"
target="_blank"
rel="noopener noreferrer"
class="text-blue-400 hover:text-blue-300 hover:underline transition">
dokkae6949/homepage
</a>
</p>
</footer>
</main>
</body>
</html>