Skip to content

Commit 52a7aa3

Browse files
committed
chore: relationship modals
1 parent ac70d0a commit 52a7aa3

File tree

4 files changed

+101
-9
lines changed

4 files changed

+101
-9
lines changed

apps/web/src/app/(profile)/profile/[handle]/(user)/(overview)/panels/InformationPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default function InformationPanel({ user }: { user: UserType }) {
77
return (
88
<Group
99
title={`About ${user.displayName ? user.displayName : user.handle}`}
10-
potentialActions={<Button size="small">Edit</Button>}
10+
potentialActions={<Button size="small" href="/settings/profile">Edit</Button>}
1111
containerStyle="border-padding"
1212
>
1313
<Field
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import Image from "next/image"
2+
import React, { useState } from "react"
3+
import { cn } from "@mav/shared/utils"
4+
import { InputField } from "@mav/ui/components/fields"
5+
import type { Variant } from "@/types/characters"
6+
import Checkbox from "../layouts/Forms/Checkbox"
7+
import { Button } from "@headlessui/react"
8+
import { LuFolderPlus, LuXCircle, LuCheckCircle } from "react-icons/lu"
9+
import colors from "tailwindcss/colors"
10+
import Modal from "../layouts/Modal"
11+
import { start } from "repl"
12+
import { UserType } from "@/types/users"
13+
import { USER_DEFAULT_AVATAR } from "@/utils/constants"
14+
15+
export default function RelationModal({
16+
followers,
17+
following,
18+
displayRelationsModal,
19+
toggleRelationsModal,
20+
startingTab
21+
}: {
22+
followers: UserType[]
23+
following: UserType[]
24+
displayRelationsModal: boolean
25+
toggleRelationsModal: (type?: string) => void,
26+
startingTab: string
27+
}) {
28+
const [tab, setTab] = useState(startingTab)
29+
return (
30+
<Modal
31+
state={displayRelationsModal}
32+
toggler={toggleRelationsModal}
33+
className="w-full md:w-[600px] h-full md:h-[500px] p-5"
34+
>
35+
<Modal.Body>
36+
<div className="flex flex-row gap-x-4 ">
37+
<span className={cn(tab == 'follower' && 'border border-b-2 border-500 text-500', ' text-lg cursor-pointer')} onClick={() => setTab("follower")}>Followers</span>
38+
<span className={cn(tab == 'following' && 'border border-b-2 border-500 text-500', 'text-lg cursor-pointer')} onClick={() => setTab("following")}>Following</span>
39+
</div>
40+
<div className="flex flex-col gap-y-2 mt-5">
41+
{tab == "follower" && (
42+
<div className="flex flex-col gap-y-2">
43+
{followers.map((follower, index) => (
44+
<div key={index} className="flex flex-row items-center gap-x-2">
45+
<Image
46+
src={follower.avatarUrl || USER_DEFAULT_AVATAR}
47+
alt={follower.handle}
48+
width={40}
49+
height={40}
50+
className="rounded-full"
51+
/>
52+
<span>{follower.displayName}</span>
53+
</div>
54+
))}
55+
</div>
56+
)}
57+
{tab == "following" && (
58+
<div className="flex flex-col gap-y-2">
59+
{following.map((followee, index) => (
60+
<div key={index} className="flex flex-row items-center gap-x-2">
61+
<Image
62+
src={followee.avatarUrl || USER_DEFAULT_AVATAR}
63+
alt={followee.handle}
64+
width={40}
65+
height={40}
66+
className="rounded-full"
67+
/>
68+
<span>{followee.displayName}</span>
69+
</div>
70+
))}
71+
</div>
72+
)}
73+
</div>
74+
</Modal.Body>
75+
76+
</Modal>
77+
)
78+
}

apps/web/src/components/layouts/Mastheads/ProfileMasthead.tsx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import Image from "next/image"
44
import { Button } from "@mav/ui/components/buttons"
55
import { Masthead, type MastheadTabItems } from "@mav/ui/components/layouts"
66
import { LuCat, LuFileEdit, LuHeart, LuHome } from "react-icons/lu"
7+
import { useState } from "react"
8+
import RelationModal from "@/components/Modals/RelationsModal"
79

810
interface ProfileMastheadProps {
911
handle: string
@@ -13,6 +15,7 @@ interface ProfileMastheadProps {
1315
profileBio: string
1416
followerCount: number
1517
followingCount: number
18+
isOwnProfile?: boolean
1619
}
1720

1821
const profileTabs = [
@@ -35,6 +38,13 @@ const profileTabs = [
3538
] satisfies MastheadTabItems
3639

3740
export function ProfileMasthead(props: Partial<ProfileMastheadProps>) {
41+
const [displayRelationsModal, setDisplayRelationsModal] = useState(false)
42+
const toggleRelationsModal = (type?: string) => {
43+
setStartingRelationTab(type || "follower")
44+
setDisplayRelationsModal(!displayRelationsModal)
45+
}
46+
47+
const [startingRelationTab, setStartingRelationTab] = useState("follower")
3848
return (
3949
<Masthead>
4050
<Masthead.Banner src={props.bannerUrl} />
@@ -49,27 +59,31 @@ export function ProfileMasthead(props: Partial<ProfileMastheadProps>) {
4959
<span className="text-4xl">
5060
{props.displayName || props.handle}
5161
</span>
52-
<Button href="/settings/profile" icon={<LuFileEdit size={18} />}>
53-
Edit Profile
54-
</Button>
62+
{props.isOwnProfile ?? (
63+
64+
<Button href="/settings/profile">
65+
Edit Profile
66+
</Button>
67+
)}
5568
</Masthead.Layer>
5669
<Masthead.Layer>
5770
<div className="flex gap-x-4">
5871
<span className="text-lg">
5972
{props.handle ? `@${props.handle}` : ""}
6073
</span>
61-
<span className="text-lg">
62-
{props.followerCount || "???"} followers
74+
<span className="text-lg" onClick={() => toggleRelationsModal("followers")}>
75+
{props.followerCount} followers
6376
</span>
64-
<span className="text-lg">
65-
{props.followingCount || "???"} following
77+
<span className="text-lg" onClick={() => toggleRelationsModal("following")}>
78+
{props.followingCount} following
6679
</span>
6780
</div>
6881
</Masthead.Layer>
6982
<Masthead.Layer>{props.profileBio}</Masthead.Layer>
7083
</Masthead.Details>
7184
</Masthead.Wrapper>
7285
<Masthead.Tabs baseURL={`/@${props.handle}/`} items={profileTabs} />
86+
<RelationModal followers={[]} following={[]} displayRelationsModal={displayRelationsModal} toggleRelationsModal={toggleRelationsModal} startingTab={startingRelationTab} />
7387
</Masthead>
7488
)
7589
}

packages/ui/components/comments/UserComment.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export function UserComment(props: React.PropsWithChildren<CommentProps>) {
9090
size="small"
9191
className="absolute right-2 top-2 rounded-full p-0 transition-none"
9292
variant="tritery"
93-
icon={<LuMoreVertical size={14} />}
93+
icon={<LuMoreVertical size={14} />}
9494
/>
9595
{/* Comment contents */}
9696
<div data-mav-comment-contents="" className="mt-1 font-normal">

0 commit comments

Comments
 (0)