GitHub Pull Requests
ui-components/github-prFreeBlock
Displays the count of open pull requests.
Install it
npx shadcn@latest add https://ui.raulcarini.dev/r/github-pr.jsonSource
1import * as React from "react";23import { Button } from "@/components/ui/button";4import { Skeleton } from "@/components/ui/skeleton";5import { GitPullRequestArrowIcon } from "lucide-react";67export function GithubPR({ repo }: { repo: string }) {8 return (9 <Button10 nativeButton={false}11 size="sm"12 variant="ghost"13 className="h-8 shadow-none group"14 render={15 <a16 href={`https://github.com/${repo}`}17 target="_blank"18 rel="noreferrer"19 />20 }21 >22 <GitPullRequestArrowIcon className="group-hover:scale-110 transition-transform duration-200 ease-out" />23 <React.Suspense fallback={<Skeleton className="h-4 w-20" />}>24 <PRCount repo={repo} />25 </React.Suspense>26 </Button>27 );28}2930export async function PRCount({ repo }: { repo: string }) {31 const data = await fetch(32 `https://api.github.com/search/issues?q=repo:${repo}+is:pr+is:open`,33 {34 next: { revalidate: 86400 }, // Cache for 1 day (86400 seconds)35 },36 );37 const json: { total_count: number } = await data.json();3839 return (40 <p className="text-xs text-muted-foreground/70 group-hover:text-muted-foreground transition-colors duration-200 ease-out">41 <span className="tabular-nums">42 {json.total_count >= 100043 ? `${(json.total_count / 1000).toFixed(1)}k`44 : json.total_count.toLocaleString()}45 </span>{" "}46 pull requests47 </p>48 );49}
What it pulls in
npm packages
Other registry items
Files it writes
More from UI Components
All 25 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| GitHub Contributionsgithub-contributions | UI Components | Blocks | Free | no deps | |
| GitHub Contributions Advancedgithub-contributions-advanced | UI Components | Blocks | Free | no deps | |
| GitHub Contributions Advanced Fetchergithub-contributions-advanced-fetcher | UI Components | Blocks | Free | no deps | |
| GitHub Contributions Fetchergithub-contributions-fetcher | UI Components | Blocks | Free | no deps | |
| GitHub Forksgithub-forks | UI Components | Blocks | Free | 1 dep | |
| GitHub Issuesgithub-issues | UI Components | Blocks | Free | 1 dep | |
| GitHub Starsgithub-stars | UI Components | Blocks | Free | 1 dep | |
| GitHub Stars Progressgithub-stars-progress | UI Components | Blocks | Free | 1 dep |
