From b08bd1dcaca6dbad03a7e6c88a1648a1cdb96780 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Thu, 8 Jan 2026 20:38:21 +0100 Subject: [PATCH] Profile view #33 --- package-lock.json | 38 +++++++++++++++ package.json | 1 + src/app/chat/page.tsx | 16 ++----- src/components/ProfilePicture.tsx | 67 +++++++++++++++++++++++++-- src/components/app/AppLayout.tsx | 3 +- src/components/app/DMItem.tsx | 29 ++++++------ src/components/app/SidebarDMs.tsx | 3 +- src/components/app/SidebarServers.tsx | 4 +- src/components/channel/MessageBox.tsx | 9 ++-- src/components/settings/Settings.tsx | 2 +- src/components/ui/popover.tsx | 48 +++++++++++++++++++ 11 files changed, 180 insertions(+), 40 deletions(-) create mode 100644 src/components/ui/popover.tsx diff --git a/package-lock.json b/package-lock.json index 2d8a247..181466f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@radix-ui/react-dialog": "^1.1.15", "@radix-ui/react-dropdown-menu": "^2.1.16", "@radix-ui/react-label": "^2.1.7", + "@radix-ui/react-popover": "^1.1.15", "@radix-ui/react-scroll-area": "^1.2.10", "@radix-ui/react-select": "^2.2.6", "@radix-ui/react-separator": "^1.1.7", @@ -1422,6 +1423,43 @@ } } }, + "node_modules/@radix-ui/react-popover": { + "version": "1.1.15", + "resolved": "https://registry.npmjs.org/@radix-ui/react-popover/-/react-popover-1.1.15.tgz", + "integrity": "sha512-kr0X2+6Yy/vJzLYJUPCZEc8SfQcf+1COFoAqauJm74umQhta9M7lNJHP7QQS3vkvcGLQUbWpMzwrXYwrYztHKA==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.3", + "@radix-ui/react-compose-refs": "1.1.2", + "@radix-ui/react-context": "1.1.2", + "@radix-ui/react-dismissable-layer": "1.1.11", + "@radix-ui/react-focus-guards": "1.1.3", + "@radix-ui/react-focus-scope": "1.1.7", + "@radix-ui/react-id": "1.1.1", + "@radix-ui/react-popper": "1.2.8", + "@radix-ui/react-portal": "1.1.9", + "@radix-ui/react-presence": "1.1.5", + "@radix-ui/react-primitive": "2.1.3", + "@radix-ui/react-slot": "1.2.3", + "@radix-ui/react-use-controllable-state": "1.2.2", + "aria-hidden": "^1.2.4", + "react-remove-scroll": "^2.6.3" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-popper": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/@radix-ui/react-popper/-/react-popper-1.2.8.tgz", diff --git a/package.json b/package.json index c2c9bd4..259bdec 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "@radix-ui/react-dialog": "^1.1.15", "@radix-ui/react-dropdown-menu": "^2.1.16", "@radix-ui/react-label": "^2.1.7", + "@radix-ui/react-popover": "^1.1.15", "@radix-ui/react-scroll-area": "^1.2.10", "@radix-ui/react-select": "^2.2.6", "@radix-ui/react-separator": "^1.1.7", diff --git a/src/app/chat/page.tsx b/src/app/chat/page.tsx index b9c640e..b20d949 100644 --- a/src/app/chat/page.tsx +++ b/src/app/chat/page.tsx @@ -1,6 +1,6 @@ "use client"; -import ProfilePicture from "@/components/ProfilePicture"; +import ProfilePreview, { ProfileImage } from "@/components/ProfilePicture"; import SettingsDialog from "@/components/settings/SettingsDialog"; import AppLayout from "@/components/app/AppLayout"; import { Button } from "@/components/ui/button"; @@ -93,10 +93,7 @@ export default function ChatHub() { className="flex justify-between items-center hover:bg-accent hover:text-accent-foreground rounded p-2 transition" > - + {dm.display_name || dm.id} @@ -129,7 +126,7 @@ export default function ChatHub() { className="flex justify-between items-center hover:bg-accent hover:text-accent-foreground rounded p-2 transition" > - @@ -167,10 +164,7 @@ export default function ChatHub() { className="flex items-center justify-between hover:bg-accent rounded p-2 transition" >
- +

{user?.display_name || ""} @@ -233,7 +227,7 @@ export default function ChatHub() { }} > - +

{srv.name}

diff --git a/src/components/ProfilePicture.tsx b/src/components/ProfilePicture.tsx index 7228443..63dd309 100644 --- a/src/components/ProfilePicture.tsx +++ b/src/components/ProfilePicture.tsx @@ -1,19 +1,80 @@ import { cn } from "@/lib/utils"; import { Avatar, AvatarFallback, AvatarImage } from "./ui/avatar"; +import { Popover, PopoverTrigger, PopoverContent } from "./ui/popover"; +import { Button } from "./ui/button"; +import { UserProfile } from "@/hooks/get-user"; -export default function ProfilePicture({ +export function ProfileImage({ name, url, className, }: { name: string; - url: string | undefined; + url: string; className?: string; }) { return ( - + {name[0]} ); } + +export default function ProfilePreview({ + className, + profile, +}: { + profile?: UserProfile; + className?: string; +}) { + if (!profile) + return ( + + Loading + + ); + + return ( + + + + + {profile.display_name[0]} + + + + +
+ + + {profile.display_name[0]} + + +
+ + {profile.display_name} + + + @{profile.username} + +
+
+ +
+ + {/* */} +
+
+
+ ); +} diff --git a/src/components/app/AppLayout.tsx b/src/components/app/AppLayout.tsx index b3a696c..4717a75 100644 --- a/src/components/app/AppLayout.tsx +++ b/src/components/app/AppLayout.tsx @@ -91,9 +91,8 @@ export default function AppLayout({