Updated conversations/communities list ui
This commit is contained in:
parent
294205e873
commit
50e88045b9
3 changed files with 21 additions and 59 deletions
|
|
@ -4,14 +4,9 @@ import { reduceDisplay } from "./utils";
|
||||||
import { Card, CardHeader } from "@tensamin/ui/cmp/card";
|
import { Card, CardHeader } from "@tensamin/ui/cmp/card";
|
||||||
import { Skeleton } from "@tensamin/ui/cmp/skeleton";
|
import { Skeleton } from "@tensamin/ui/cmp/skeleton";
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes Basic.
|
|
||||||
* @param props Parameter props.
|
|
||||||
* @returns unknown.
|
|
||||||
*/
|
|
||||||
export function Basic(props: { user: User }) {
|
export function Basic(props: { user: User }) {
|
||||||
return (
|
return (
|
||||||
<Card className="animate-in fade-in duration-300 rounded-2xl py-0">
|
<Card className="animate-in fade-in duration-300 rounded-xl py-0 m-px">
|
||||||
<CardHeader className="flex flex-row gap-2.5 items-center justify-start p-2">
|
<CardHeader className="flex flex-row gap-2.5 items-center justify-start p-2">
|
||||||
<Avatar>
|
<Avatar>
|
||||||
<AvatarImage src={props.user.avatar} />
|
<AvatarImage src={props.user.avatar} />
|
||||||
|
|
@ -25,10 +20,6 @@ export function Basic(props: { user: User }) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes Loading.
|
|
||||||
* @returns unknown.
|
|
||||||
*/
|
|
||||||
export function Loading() {
|
export function Loading() {
|
||||||
return <Skeleton className="h-12 rounded-xl" />;
|
return <Skeleton className="h-12.5 rounded-xl" />;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,20 +23,20 @@ export default function List() {
|
||||||
const virtualizer = useVirtualizer({
|
const virtualizer = useVirtualizer({
|
||||||
count:
|
count:
|
||||||
category === "conversations" ? conversations.length : communities.length,
|
category === "conversations" ? conversations.length : communities.length,
|
||||||
estimateSize: () => 80,
|
estimateSize: () => 60,
|
||||||
getScrollElement: () => scrollRef.current,
|
getScrollElement: () => scrollRef.current,
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3 h-full">
|
||||||
<Switch category={category} setCategory={setCategory} />
|
<Switch category={category} setCategory={setCategory} />
|
||||||
<div
|
<div
|
||||||
ref={scrollRef}
|
ref={scrollRef}
|
||||||
id="conversation-list"
|
id="conversation-list"
|
||||||
className="overflow-y-auto flex-1"
|
className="overflow-y-auto flex-1 h-full"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className="relative w-full flex flex-col gap-2"
|
className="relative w-full flex flex-col"
|
||||||
style={{
|
style={{
|
||||||
height: `${virtualizer.getTotalSize()}px`,
|
height: `${virtualizer.getTotalSize()}px`,
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -8,55 +8,26 @@ import {
|
||||||
ContextMenuTrigger,
|
ContextMenuTrigger,
|
||||||
} from "@tensamin/ui/cmp/context-menu";
|
} from "@tensamin/ui/cmp/context-menu";
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import { type User } from "@tensamin/user/context";
|
|
||||||
|
|
||||||
/**
|
export default function ConversationModal({ userId }: { userId: number }) {
|
||||||
* Renders the conversation modal user preview card.
|
|
||||||
* @param user Loaded user data.
|
|
||||||
* @returns Conversation preview card JSX.
|
|
||||||
*/
|
|
||||||
function renderConversationUser(user: User) {
|
|
||||||
return <Basic user={user} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders the conversation modal user preview card skeleton while loading user data.
|
|
||||||
* @returns Conversation preview card skeleton JSX.
|
|
||||||
*/
|
|
||||||
function renderConversationUserLoading() {
|
|
||||||
return <Loading />;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders a conversation context-menu entry for a specific user.
|
|
||||||
* @param props Component props with selected user id.
|
|
||||||
* @returns Conversation modal trigger and menu JSX.
|
|
||||||
*/
|
|
||||||
export default function ConversationModal(props: { userId: number }) {
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
/**
|
|
||||||
* Navigates to the selected conversation in chat view.
|
|
||||||
* @returns Void.
|
|
||||||
*/
|
|
||||||
const onConversationClick = () => {
|
|
||||||
void navigate({ to: "/chat", search: { id: props.userId } });
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<ContextMenuTrigger>
|
<ContextMenuTrigger
|
||||||
<div
|
render={
|
||||||
className="select-none cursor-pointer"
|
<div
|
||||||
onClick={onConversationClick}
|
className="select-none cursor-pointer"
|
||||||
>
|
onClick={() => navigate({ to: "/chat", search: { id: userId } })}
|
||||||
<Wrapper
|
>
|
||||||
loading={renderConversationUserLoading()}
|
<Wrapper
|
||||||
userId={props.userId}
|
loading={<Loading />}
|
||||||
component={renderConversationUser}
|
userId={userId}
|
||||||
/>
|
component={(user) => <Basic user={user} />}
|
||||||
</div>
|
/>
|
||||||
</ContextMenuTrigger>
|
</div>
|
||||||
|
}
|
||||||
|
></ContextMenuTrigger>
|
||||||
<ContextMenuContent>
|
<ContextMenuContent>
|
||||||
<ContextMenuGroup>
|
<ContextMenuGroup>
|
||||||
<ContextMenuItem>Test</ContextMenuItem>
|
<ContextMenuItem>Test</ContextMenuItem>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue