github-star
jolyui-ui/github-starFreeComponent
jolyui/ui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by jolyui/ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://jolyui.dev/r/github-star.jsonSource
1"use client";23import { AnimatePresence, motion } from "motion/react";4import * as React from "react";5import { cn } from "@/lib/utils";67export interface GitHubStarButtonProps {8 /**9 * The owner of the GitHub repository10 * @example "johuniq"11 */12 owner: string;13 /**14 * The name of the GitHub repository15 * @example "jolyui"16 */17 repo: string;18 /**19 * Manual star count override. If provided, the component will not fetch from GitHub API.20 */21 stars?: number;22 /**23 * Additional CSS classes for the button24 */25 className?: string;26}2728interface Particle {29 id: number;30 x: number;31 y: number;32 angle: number;33 scale: number;34}3536const StarIcon = ({37 className,38 filled,39}: {40 className?: string;41 filled?: boolean;42}) => (43 <svg44 viewBox="0 0 16 16"45 className={className}46 fill={filled ? "currentColor" : "none"}47 stroke="currentColor"48 strokeWidth={filled ? 0 : 1.5}49 strokeLinecap="round"50 strokeLinejoin="round"51 >52 <path d="M8 1.5l1.85 4.1 4.65.55-3.5 3.15.95 4.6L8 11.7l-4 2.2.95-4.6-3.5-3.15 4.65-.55L8 1.5z" />53 </svg>54);5556const GitHubIcon = ({ className }: { className?: string }) => (57 <svg viewBox="0 0 16 16" className={className} fill="currentColor">58 <path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z" />59 </svg>60);6162function formatNumber(num: number): string {63 if (num >= 1000000) {64 return `${(num / 1000000).toFixed(1).replace(/\.0$/, "")}M`;65 }66 if (num >= 1000) {67 return `${(num / 1000).toFixed(1).replace(/\.0$/, "")}k`;68 }69 return num.toLocaleString();70}7172function useGitHubStars(owner: string, repo: string, manualStars?: number) {73 const [stars, setStars] = React.useState<number>(manualStars ?? 0);74 const [loading, setLoading] = React.useState(!manualStars);7576 React.useEffect(() => {77 if (manualStars !== undefined) {78 setStars(manualStars);79 setLoading(false);80 return;81 }8283 fetch(`https://api.github.com/repos/${owner}/${repo}`)84// … truncated
What it pulls in
npm packages
Files it writes
More from jolyui/ui
All 199 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ai-prompt-boxai-prompt-box | jolyui/ui | Components | Free | 4 deps | |
| animated-beamanimated-beam | jolyui/ui | Components | Free | 1 dep | |
| animated-tableanimated-table | jolyui/ui | Components | Free | 2 deps | |
| animated-theme-toggleanimated-theme-toggle | jolyui/ui | Components | Free | 2 deps | |
| animated-toastanimated-toast | jolyui/ui | Components | Free | 2 deps | |
| animated-tooltipanimated-tooltip | jolyui/ui | Components | Free | 1 dep | |
| bento-gridbento-grid | jolyui/ui | Components | Free | no deps | |
| buttonbutton | jolyui/ui | Components | Free | 3 deps |
