alternative tangled frontend (extremely wip)

feat: backlink counts

+133 -7
+57 -7
src/components/Profile/PinnedRepos.tsx
··· 1 1 import { UnderlineRouterLink } from "@/components/Animated/UnderlineRouterLink"; 2 2 import { Loading } from "@/components/Icons/Loading"; 3 + import { useBacklinkCount } from "@/lib/queries/constellation-backlink-count"; 3 4 import { useMiniDoc } from "@/lib/queries/resolve-minidoc"; 4 5 import { usePinnedReposQuery } from "@/lib/queries/resolve-pinned-repos"; 5 6 import { ShTangledRepo } from "@/lib/types/lexicons/sh/tangled/repo"; 6 - import { LucideBookMarked, LucideGitBranch } from "lucide-react"; 7 + import { 8 + LucideBookMarked, 9 + LucideCircleDot, 10 + LucideGitBranch, 11 + LucideGitBranchPlus, 12 + LucideGitPullRequest, 13 + LucideStar, 14 + } from "lucide-react"; 7 15 8 16 export const PinnedRepos = ({ 9 17 repoUris, ··· 58 66 isOwner: boolean; 59 67 repoUri: string; 60 68 }) => { 61 - const isForked = !!repo.source; 62 69 const did = repoUri.split("/")[2]; 63 70 const { 64 71 isLoading: miniDocLoading, 65 72 error: miniDocError, 66 73 data: miniDocData, 67 74 } = useMiniDoc(did); 75 + const { 76 + isLoading: starsLoading, 77 + error: starsError, 78 + data: starsData, 79 + } = useBacklinkCount({ 80 + subject: repoUri, 81 + source: "sh.tangled.feed.star:subject", 82 + }); 83 + const { 84 + isLoading: issuesLoading, 85 + error: issuesError, 86 + data: issuesData, 87 + } = useBacklinkCount({ 88 + subject: repoUri, 89 + source: "sh.tangled.repo.issue:repo", 90 + }); 91 + const { 92 + isLoading: pullsLoading, 93 + error: pullsError, 94 + data: pullsData, 95 + } = useBacklinkCount({ 96 + subject: repoUri, 97 + source: "sh.tangled.repo.pull:targetRepo", 98 + }); 68 99 69 - if (miniDocError && !miniDocLoading) 70 - return <p>Could not fetch pinned repos data.{miniDocError.message}</p>; 71 - if (miniDocLoading || !miniDocData) return <Loading />; 100 + const error = miniDocError ?? starsError ?? issuesError ?? pullsError; 101 + const isLoading = 102 + miniDocLoading || starsLoading || issuesLoading || pullsLoading; 103 + 104 + if (error && !isLoading) 105 + return <p>Could not fetch pinned repos data.{error.message}</p>; 106 + if (isLoading || !miniDocData || !starsData || !issuesData || !pullsData) 107 + return <Loading />; 72 108 73 109 const { handle: ownerHandle } = miniDocData; 74 110 75 111 return ( 76 - <div className="border-overlay0 flex flex-col gap-1 rounded-sm border p-2 pt-3"> 112 + <div className="border-overlay0 flex flex-col justify-between gap-1 rounded-sm border p-2 py-3"> 77 113 <div className="flex flex-col gap-1"> 78 114 <div className="flex items-center"> 79 115 {isOwner ? ( ··· 92 128 </UnderlineRouterLink> 93 129 </div> 94 130 {repo.description && ( 95 - <p className="text-subtext pl-2 text-sm"> 131 + <p className="text-subtext line-clamp-2 pl-2 text-sm"> 96 132 {repo.description} 97 133 </p> 98 134 )} 135 + </div> 136 + <div className="text-subtext flex gap-2 text-sm"> 137 + <div className="flex items-center"> 138 + <LucideStar height={16} /> 139 + <span>{starsData.total}</span> 140 + </div> 141 + <div className="flex items-center"> 142 + <LucideCircleDot height={16} /> 143 + <span>{issuesData.total}</span> 144 + </div> 145 + <div className="flex items-center"> 146 + <LucideGitPullRequest height={16} /> 147 + <span>{pullsData.total}</span> 148 + </div> 99 149 </div> 100 150 </div> 101 151 );