From 2bc0a508ea7ed4cc98977c5ceeef6abb97e61d72 Mon Sep 17 00:00:00 2001 From: Chneemann Date: Sat, 26 Sep 2026 17:14:40 +0200 Subject: [PATCH] feat(settings): make SettingsProfileCard collapsible --- components/settings/SettingsProfileCard.tsx | 157 +++++++++++--------- 1 file changed, 90 insertions(+), 67 deletions(-) diff --git a/components/settings/SettingsProfileCard.tsx b/components/settings/SettingsProfileCard.tsx index 8d4b953..acc64fb 100644 --- a/components/settings/SettingsProfileCard.tsx +++ b/components/settings/SettingsProfileCard.tsx @@ -1,22 +1,24 @@ /** * @file components/settings/SettingsProfileCard.tsx - * @description Card component managing user profile overview, status picker, and color selection. + * @description Collapsible card component managing user profile overview, status picker, and color selection. */ "use client"; +import { useState } from "react"; import { UserAvatar } from "@/components/ui/UserAvatar"; import { UserStatus } from "@/db/schema"; import { MEMBER_STATUS_COLOR_CLASSES, MEMBER_COLOR_OPTIONS, } from "@/lib/constants/member.styles"; -import { UserRound, Palette } from "lucide-react"; +import { UserRound, Palette, ChevronDown } from "lucide-react"; import { useUser } from "@/lib/context/UserContext"; /** Props for the SettingsProfileCard component. */ interface SettingsProfileCardProps { onUpdate: (fields: Partial<{ status: UserStatus; color: string }>) => void; + defaultOpen?: boolean; } const STATUSES: { label: string; value: UserStatus }[] = [ @@ -26,80 +28,101 @@ const STATUSES: { label: string; value: UserStatus }[] = [ { label: "DND", value: "DND" }, ]; -/** Renders a card for managing user profile details, online status, and theme color preferences. */ -export function SettingsProfileCard({ onUpdate }: SettingsProfileCardProps) { +/** Renders a collapsible card for managing user profile details, status, and theme color. */ +export function SettingsProfileCard({ + onUpdate, + defaultOpen = true, +}: SettingsProfileCardProps) { + const [isOpen, setIsOpen] = useState(defaultOpen); const { currentUser } = useUser(); if (!currentUser) return null; return ( -
- {/* User Info Header */} -
- -
-

- {currentUser.username} -

-

{currentUser.email}

+
+ {/* Clickable Header / Toggle Bar */} +
- {/* Status Selection */} -
-

- Online Status -

-
- {STATUSES.map((status) => { - const isSelected = currentUser.status === status.value; - return ( - - ); - })} -
-
+ + - {/* Color Palette Selection */} -
-

- Profile Color -

-
- {MEMBER_COLOR_OPTIONS.map((colorClass) => { - const isSelected = currentUser.color === colorClass; - return ( - + ); + })} +
+
+ + {/* Color Palette Selection */} +
+

+ Profile Color +

+
+ {MEMBER_COLOR_OPTIONS.map((colorClass) => { + const isSelected = currentUser.color === colorClass; + return ( +
+
-
+ )}
); }