From abe10922ebb87fe7a3a32d658504d773ad5a1b78 Mon Sep 17 00:00:00 2001 From: qdust41 Date: Thu, 2 Apr 2026 21:46:15 -0400 Subject: [PATCH] claude fixed up the ui --- assets/css/app.css | 24 ++++++++++++++++++ assets/js/index.tsx | 62 +++++++++++++++++++++++++++------------------ 2 files changed, 61 insertions(+), 25 deletions(-) diff --git a/assets/css/app.css b/assets/css/app.css index a8e1812..672a92d 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -466,6 +466,30 @@ html, body { .mx-action-delete:hover { color: var(--mx-red); background: color-mix(in oklch, var(--mx-red) 10%, transparent); } .mx-action-confirm { color: var(--mx-red) !important; background: color-mix(in oklch, var(--mx-red) 15%, transparent) !important; } +.mx-follow-btn { + padding: 0.25rem 0.875rem; + border-radius: 9999px; + border: 1.5px solid var(--mx-border2); + background: none; + color: var(--mx-fg); + font-size: 0.8125rem; + font-weight: 600; + cursor: pointer; + white-space: nowrap; + transition: background 0.15s, border-color 0.15s, color 0.15s; +} +.mx-follow-btn:hover:not(:disabled) { background: var(--mx-surface2); } +.mx-follow-btn--following { + background: var(--mx-surface); + color: var(--mx-muted); +} +.mx-follow-btn--following:hover:not(:disabled) { + background: color-mix(in oklch, var(--mx-red) 10%, transparent); + border-color: var(--mx-red); + color: var(--mx-red); +} +.mx-follow-btn:disabled { opacity: 0.5; cursor: not-allowed; } + .mx-tweet-text { font-size: 1rem; line-height: 1.6; diff --git a/assets/js/index.tsx b/assets/js/index.tsx index 7199808..286bae1 100644 --- a/assets/js/index.tsx +++ b/assets/js/index.tsx @@ -896,8 +896,7 @@ function RefreshButton() { ); } -function FollowButton({ targetUserId, amIFollowing }: { targetUserId: string; amIFollowing: boolean }) { - const { userId: currentUserId } = useContext(AuthCtx); +function useFollowUser(targetUserId: string) { const qc = useQueryClient(); const followMutation = useMutation({ @@ -928,35 +927,42 @@ function FollowButton({ targetUserId, amIFollowing }: { targetUserId: string; am }, }); - if (!currentUserId || currentUserId === targetUserId) return null; - - const isPending = followMutation.isPending || unfollowMutation.isPending; + return { + follow: () => followMutation.mutate(), + unfollow: () => unfollowMutation.mutate(), + isPending: followMutation.isPending || unfollowMutation.isPending, + }; +} +function FollowButton({ amIFollowing, isPending, onToggle }: { amIFollowing: boolean; isPending: boolean; onToggle: () => void }) { return ( ); } function UserCard({ user }: { user: User }) { + const { userId: currentUserId } = useContext(AuthCtx); const [ctxMenu, setCtxMenu] = useState<{ x: number; y: number } | null>(null); + const { follow, unfollow, isPending } = useFollowUser(user.id); const userUrl = `${window.location.origin}/users/${user.id}`; + const canFollow = !!currentUserId && currentUserId !== user.id; + const amIFollowing = user.amIFollowing ?? false; const ctxItems: ContextMenuItem[] = [ - { - type: "item", - label: "Share", - onClick: () => navigator.clipboard.writeText(userUrl), - }, + { type: "item", label: "Share", onClick: () => navigator.clipboard.writeText(userUrl) }, + ...(canFollow ? [ + { type: "separator" as const }, + amIFollowing + ? { type: "item" as const, label: "Unfollow", onClick: unfollow } + : { type: "item" as const, label: "Follow", onClick: follow }, + ] : []), ]; return ( @@ -972,7 +978,6 @@ function UserCard({ user }: { user: User }) {
{user.email} -
{(user.followerCount !== undefined || user.followingCount !== undefined) && (
@@ -981,13 +986,13 @@ function UserCard({ user }: { user: User }) {
)}
+ {canFollow && ( +
+ +
+ )} {ctxMenu && ( - setCtxMenu(null)} - /> + setCtxMenu(null)} /> )} ); @@ -1032,6 +1037,8 @@ function UserList() { } function UserDetail({ userId }: { userId: string }) { + const { userId: currentUserId } = useContext(AuthCtx); + const { follow, unfollow, isPending } = useFollowUser(userId); const { data: user, isLoading, isError } = useQuery({ queryKey: ["user", userId], queryFn: async () => { @@ -1049,6 +1056,9 @@ function UserDetail({ userId }: { userId: string }) { if (isLoading) return ; if (isError || !user) return ; + const canFollow = !!currentUserId && currentUserId !== userId; + const amIFollowing = user.amIFollowing ?? false; + return (
@@ -1064,10 +1074,12 @@ function UserDetail({ userId }: { userId: string }) {
M
-
+
{user.email} - + {canFollow && ( + + )}
{user.followerCount ?? 0} followers