From dffcfca0ad5b56ca39856e7ad66029a8beb3c720 Mon Sep 17 00:00:00 2001 From: Chneemann Date: Thu, 1 Oct 2026 04:21:29 +0200 Subject: [PATCH] refactor(servers): improve server color picker UI and expand palette --- components/modals/CreateServerModal.tsx | 78 ++++++++++++------------- lib/constants/server.styles.ts | 29 ++++----- 2 files changed, 51 insertions(+), 56 deletions(-) diff --git a/components/modals/CreateServerModal.tsx b/components/modals/CreateServerModal.tsx index d7d7d9d..cab9a20 100644 --- a/components/modals/CreateServerModal.tsx +++ b/components/modals/CreateServerModal.tsx @@ -6,31 +6,20 @@ "use client"; import { useState } from "react"; -import { X, Loader2 } from "lucide-react"; +import { X, Check } from "lucide-react"; import { SERVER_COLOR_CLASSES, SERVER_COLOR_OPTIONS, } from "@/lib/constants/server.styles"; import { ActionButton } from "../ui/ActionButton"; -/** - * Properties for the CreateServerModal component. - * - * @interface CreateServerModalProps - * @property {boolean} isOpen - Indicates whether the modal dialog is currently visible. - * @property {() => void} onClose - Callback function to handle closing the modal dialog. - */ +/** Props for the CreateServerModal component. */ interface CreateServerModalProps { isOpen: boolean; onClose: () => void; } -/** - * Renders the modal dialog for creating a new server with custom properties. - * - * @param {CreateServerModalProps} props - The component props. - * @returns {JSX.Element | null} The rendered modal component or null when hidden. - */ +/** Renders a modal dialog to create a new server with name and accent color selection. */ export function CreateServerModal({ isOpen, onClose }: CreateServerModalProps) { const [name, setName] = useState(""); const [color, setColor] = useState("bg-indigo-500"); @@ -39,16 +28,11 @@ export function CreateServerModal({ isOpen, onClose }: CreateServerModalProps) { if (!isOpen) return null; - const isValid = name.trim().length != 0; + const isValid = name.trim().length !== 0; const canSave = isValid && !isLoading; - /** - * Handles server creation form submission via API POST request. - * - * @param {React.FormEvent} e - The form submission event instance. - * @returns {Promise} Resolves when request is completed or redirects on success. - */ - const handleSubmit = async (e: React.FormEvent) => { + /** Handles server creation form submission and redirects to the created server's channel. */ + const handleSubmit = async (e: React.SubmitEvent) => { e.preventDefault(); if (!name.trim()) return; @@ -85,12 +69,10 @@ export function CreateServerModal({ isOpen, onClose }: CreateServerModalProps) { }; return ( - /* Outer Backdrop */
- {/* Inner Modal Content */}
e.stopPropagation()} className="bg-surface border border-surface/50 rounded-2xl w-full max-w-md p-6 shadow-2xl relative animate-in fade-in zoom-in-95 duration-150" @@ -109,7 +91,7 @@ export function CreateServerModal({ isOpen, onClose }: CreateServerModalProps) { Give your new server a name and choose an accent color.

-
+
- -
- {SERVER_COLOR_OPTIONS.map((c) => ( - + ); + })}
{error &&

{error}

} -
+
= { "bg-indigo-500": "bg-indigo-500", - "bg-emerald-500": "bg-emerald-500", - "bg-rose-500": "bg-rose-500", - "bg-amber-500": "bg-amber-500", - "bg-sky-500": "bg-sky-500", "bg-violet-500": "bg-violet-500", + "bg-purple-500": "bg-purple-500", "bg-fuchsia-500": "bg-fuchsia-500", + "bg-pink-500": "bg-pink-500", + "bg-rose-500": "bg-rose-500", + "bg-red-500": "bg-red-500", + "bg-orange-500": "bg-orange-500", + "bg-amber-500": "bg-amber-500", + "bg-yellow-500": "bg-yellow-500", + "bg-lime-500": "bg-lime-500", + "bg-emerald-500": "bg-emerald-500", + "bg-teal-500": "bg-teal-500", "bg-cyan-500": "bg-cyan-500", + "bg-sky-500": "bg-sky-500", + "bg-blue-500": "bg-blue-500", }; -/** - * List of available color option class names for server icon selection. - * Dynamically generated from SERVER_COLOR_CLASSES to avoid duplicate maintenance. - */ +/** List of available color option class names for server icon selection. */ export const SERVER_COLOR_OPTIONS = Object.keys(SERVER_COLOR_CLASSES); -/** - * Common Tailwind CSS class constants defining base, active, and inactive visual states for server navigation icons. - */ +/** Common Tailwind CSS class constants defining base, active, and inactive visual states for server navigation icons. */ export const BASE_ICON_STYLES = "w-12 h-12 flex items-center justify-center transition-all duration-200 shadow-md shrink-0"; export const ACTIVE_ICON_STYLES =