Skip to content

Commit 7e7081f

Browse files
committed
chore(proto): 🧪 add throwaway user preview card variants at /proto/user-preview
Four directions for the profile hover card (Current, Compact, Immersive, Badge) behind a variant picker, with local demo cover/avatar images. The whole prototype is deleted once a direction is picked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CnAiFbA6iCLzpJ2F55jPdT
1 parent c267638 commit 7e7081f

12 files changed

Lines changed: 981 additions & 0 deletions

File tree

2.24 KB
Loading
8.5 KB
Loading

‎apps/web/src/page-cache.gen.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export const pageCacheRoutes: PageCacheRouteTable = [
8787
{ path: '/settings/standing' },
8888
{ path: '/admin/core' },
8989
{ path: '/docs/search' },
90+
{ path: '/proto/user-preview' },
9091
{ path: '/letters/:id/edit' },
9192
{ path: '/news/:id/edit' },
9293
{ path: '/blog/:slug' },
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
// Prototype - variant 4: Badge. Axis: symmetric layout + stats + one explicit action.
2+
import { Link } from '@tanstack/react-router'
3+
import { Avatar } from '@vitnode/core/components/avatar'
4+
import { RoleFormat } from '@vitnode/core/components/role-format'
5+
import { buttonVariants } from '@vitnode/core/components/ui/button'
6+
import { Skeleton } from '@vitnode/core/components/ui/skeleton'
7+
import { UserCoverImage } from '@vitnode/core/components/user-cover-image'
8+
import { UserPresenceStatus } from '@vitnode/core/components/user-presence-status'
9+
import { userProfileHref } from '@vitnode/core/components/user-profile-href'
10+
import { userCoverStyle } from '@vitnode/core/views/profile/images/cover-style'
11+
import { cn } from 'cn'
12+
import { UserRoundIcon } from 'lucide-react'
13+
14+
import type { Variant } from './shared'
15+
16+
import {
17+
NameLink,
18+
PendingLabel,
19+
ProfileError,
20+
SignedReputation,
21+
useJoined,
22+
usePresence,
23+
useProfile,
24+
} from './shared'
25+
26+
const Stat = ({
27+
children,
28+
label,
29+
}: {
30+
children: React.ReactNode
31+
label: string
32+
}) => (
33+
<div className="flex min-w-0 flex-col items-center gap-0.5 px-2">
34+
<dd className="text-foreground flex items-center gap-1.5 font-semibold tabular-nums">
35+
{children}
36+
</dd>
37+
<dt className="text-muted-foreground text-sm">{label}</dt>
38+
</div>
39+
)
40+
41+
const BadgeSkeleton = () => (
42+
<div aria-busy="true" className="flex flex-col">
43+
<PendingLabel />
44+
<Skeleton className="h-16 w-full rounded-none" />
45+
<div className="flex flex-col items-center gap-3 px-4 pb-4">
46+
<Skeleton className="border-popover bg-muted -mt-9 size-18 rounded-full border-4" />
47+
<Skeleton className="h-5 w-1/2" />
48+
<Skeleton className="h-4 w-1/3" />
49+
<Skeleton className="h-14 w-full rounded-lg" />
50+
<Skeleton className="h-8 w-full rounded-md" />
51+
</div>
52+
</div>
53+
)
54+
55+
const Body = ({ nameCode }: { nameCode: string }) => {
56+
const query = useProfile(nameCode)
57+
const presence = usePresence(query.data?.id ?? 0)
58+
const joinedYear = useJoined(query.data?.createdAt ?? 0, true)
59+
60+
if (query.isPending) return <BadgeSkeleton />
61+
if (query.isError) return <ProfileError query={query} />
62+
63+
const user = query.data
64+
const online = presence?.status === 'online'
65+
66+
return (
67+
<div className="flex flex-col">
68+
<div
69+
className="bg-muted h-16 overflow-hidden"
70+
style={userCoverStyle(user.avatarColor)}
71+
>
72+
<UserCoverImage url={user.coverUrl} />
73+
</div>
74+
75+
<div className="flex flex-col items-center gap-3 px-4 pb-4 text-center">
76+
<Avatar
77+
alt=""
78+
className="border-popover -mt-9 size-18 border-4"
79+
size={72}
80+
user={user}
81+
/>
82+
83+
<div className="flex max-w-full min-w-0 flex-col items-center gap-0.5">
84+
<NameLink
85+
className="text-foreground line-clamp-2 text-base font-semibold text-balance"
86+
name={user.name}
87+
nameCode={user.nameCode}
88+
/>
89+
<p className="text-muted-foreground max-w-full truncate text-sm">
90+
@{user.nameCode}
91+
</p>
92+
</div>
93+
94+
<p className="flex max-w-full items-center gap-1.5 text-sm">
95+
<RoleFormat className="min-w-0" role={user.role} />
96+
{user.secondaryRoles.length > 0 ? (
97+
<span className="text-muted-foreground shrink-0">
98+
+{user.secondaryRoles.length}
99+
</span>
100+
) : null}
101+
</p>
102+
103+
{user.headline ? (
104+
<p className="text-muted-foreground line-clamp-2 text-sm leading-relaxed text-pretty">
105+
{user.headline}
106+
</p>
107+
) : null}
108+
109+
<dl className="bg-muted/60 grid w-full grid-cols-3 divide-x rounded-lg py-2.5">
110+
<Stat label="Reputation">
111+
<SignedReputation value={user.reputation ?? 0} />
112+
</Stat>
113+
<Stat label="Joined">{joinedYear}</Stat>
114+
<Stat label="Status">
115+
{presence ? (
116+
<>
117+
<UserPresenceStatus presence={presence} variant="dot" />
118+
{presence.status === 'hidden'
119+
? 'Hidden'
120+
: online
121+
? 'Online'
122+
: 'Offline'}
123+
</>
124+
) : (
125+
'-'
126+
)}
127+
</Stat>
128+
</dl>
129+
130+
<Link
131+
className={cn(
132+
buttonVariants({ size: 'sm', variant: 'outline' }),
133+
'w-full',
134+
)}
135+
to={userProfileHref(user.nameCode)}
136+
>
137+
<UserRoundIcon aria-hidden="true" />
138+
View profile
139+
</Link>
140+
</div>
141+
</div>
142+
)
143+
}
144+
145+
export const centered: Variant = {
146+
name: 'Badge',
147+
contentClassName: 'w-72 overflow-hidden p-0',
148+
Content: Body,
149+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
// Prototype - variant 2: Compact. Axis: density - one identity row, cover as a framed band.
2+
import { Avatar } from '@vitnode/core/components/avatar'
3+
import { RoleFormat } from '@vitnode/core/components/role-format'
4+
import { Skeleton } from '@vitnode/core/components/ui/skeleton'
5+
import { UserCoverImage } from '@vitnode/core/components/user-cover-image'
6+
import { UserPresenceStatus } from '@vitnode/core/components/user-presence-status'
7+
import { userCoverStyle } from '@vitnode/core/views/profile/images/cover-style'
8+
9+
import type { Variant } from './shared'
10+
11+
import {
12+
NameLink,
13+
PendingLabel,
14+
ProfileError,
15+
SignedReputation,
16+
useJoined,
17+
usePresence,
18+
useProfile,
19+
} from './shared'
20+
21+
const CompactSkeleton = () => (
22+
<div aria-busy="true" className="flex flex-col gap-3">
23+
<PendingLabel />
24+
<Skeleton className="h-14 w-full rounded-md" />
25+
<div className="flex items-center gap-3">
26+
<Skeleton className="size-11 shrink-0 rounded-full" />
27+
<div className="flex flex-1 flex-col gap-1.5">
28+
<Skeleton className="h-4 w-2/5" />
29+
<Skeleton className="h-4 w-3/5" />
30+
</div>
31+
</div>
32+
<Skeleton className="h-4 w-4/5" />
33+
</div>
34+
)
35+
36+
const Body = ({ nameCode }: { nameCode: string }) => {
37+
const query = useProfile(nameCode)
38+
const presence = usePresence(query.data?.id ?? 0)
39+
const joined = useJoined(query.data?.createdAt ?? 0)
40+
41+
if (query.isPending) return <CompactSkeleton />
42+
if (query.isError) return <ProfileError query={query} />
43+
44+
const user = query.data
45+
46+
return (
47+
<div className="flex flex-col gap-3">
48+
<div
49+
className="bg-muted h-14 overflow-hidden rounded-md"
50+
style={userCoverStyle(user.avatarColor)}
51+
>
52+
<UserCoverImage url={user.coverUrl} />
53+
</div>
54+
55+
<div className="flex items-center gap-3">
56+
<span className="relative shrink-0">
57+
<Avatar alt="" className="size-11" size={44} user={user} />
58+
{presence ? (
59+
<span className="ring-popover bg-popover absolute -end-0.5 -bottom-0.5 flex rounded-full ring-2">
60+
<UserPresenceStatus presence={presence} variant="dot" />
61+
</span>
62+
) : null}
63+
</span>
64+
<div className="flex min-w-0 flex-1 flex-col">
65+
<NameLink
66+
className="text-foreground truncate font-semibold"
67+
name={user.name}
68+
nameCode={user.nameCode}
69+
/>
70+
<p className="text-muted-foreground flex min-w-0 items-center gap-1.5 text-sm">
71+
<span className="truncate">@{user.nameCode}</span>
72+
<span aria-hidden="true">·</span>
73+
<RoleFormat className="max-w-3/5 shrink-0" role={user.role} />
74+
</p>
75+
</div>
76+
</div>
77+
78+
{user.headline ? (
79+
<p className="truncate text-sm leading-relaxed" title={user.headline}>
80+
{user.headline}
81+
</p>
82+
) : null}
83+
84+
<p className="text-muted-foreground flex flex-wrap items-center gap-x-1.5 border-t pt-2.5 text-sm">
85+
<span>Joined {joined}</span>
86+
{typeof user.reputation === 'number' ? (
87+
<>
88+
<span aria-hidden="true">·</span>
89+
<span>
90+
<SignedReputation
91+
className="font-medium"
92+
value={user.reputation}
93+
/>{' '}
94+
rep
95+
</span>
96+
</>
97+
) : null}
98+
{user.secondaryRoles.length > 0 ? (
99+
<>
100+
<span aria-hidden="true">·</span>
101+
<span>+{user.secondaryRoles.length} roles</span>
102+
</>
103+
) : null}
104+
</p>
105+
</div>
106+
)
107+
}
108+
109+
export const compact: Variant = {
110+
name: 'Compact',
111+
contentClassName: 'w-80 p-3',
112+
Content: Body,
113+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Prototype - variant 1: the shipped card, unchanged.
2+
import { UserPreviewCard } from '@vitnode/core/components/user-preview-card'
3+
4+
import type { Variant } from './shared'
5+
6+
export const current: Variant = {
7+
name: 'Current',
8+
contentClassName: 'w-72 overflow-hidden p-0 sm:w-80',
9+
Content: ({ nameCode }) => <UserPreviewCard nameCode={nameCode} />,
10+
}

0 commit comments

Comments
 (0)