Updated
Open Source
NewCustomize
Stars24817
Forks1342
Contributors186
Full
Faces8
Feed rows3
Interval3.0s
Star colour
Installation
npx shadcn@latest add https://uibrik.com/r/open-source.jsonInstall the packages
npm install @tabler/icons-react motion react-use-measureAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/open-source/open-source.tsx"use client"; import { useEffect, useRef, useState, useSyncExternalStore, type CSSProperties, type ReactNode, type SVGProps } from "react"; import { AnimatePresence, motion, useInView } from "motion/react"; import useMeasure from "react-use-measure"; import { IconBrandGithubFilled, IconStar, IconStarFilled, IconTagFilled } from "@tabler/icons-react"; import { cn } from "@/lib/utils"; // Open source block. A repository at a glance. The first time the card // scrolls into view the star, fork and contributor counts roll up digit by // digit, a sparkline of recent stars draws itself under the counts, the // language bar fills segment by segment, and the contributors' faces slide // into a row that fans open when pointed at. Below, a live feed of commits, // merges and releases moves along one entry at a time, the newest dropping in // at the top. Starring adds one to the count, rolling only the digits that // change, with a small burst from the star. // // Colour is kept for meaning: the languages wear their usual colours, the feed // marks merges and releases, the star turns gold once starred. Everything // else is neutral. Surfaces are set apart by fill alone: no borders, no shadows. // // Every number comes in through props, so the card never calls GitHub from the // browser: fetch the counts on the server (or at build time) and pass them in. // The feed pauses while pointed at, off screen and in a background tab, and
Adds the files to
components/uibrik/open-source and installs @tabler/icons-react, motion and react-use-measure. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/open-source.Usage
import { OpenSource } from "@/components/uibrik/open-source/open-source";const activity = [ { type: "release", title: "Released v2.4.0", meta: "v2.4.0" }, { type: "merge", title: "Faster theme switching", meta: "#412" }, // …6 more];const starHistory = [120, 140, 132, 168, 190, 176, 214, 260, 248, 302, 344, 410];const languages = [ { name: "TypeScript", share: 78.4, color: "#3178c6" }, { name: "CSS", share: 14.2, color: "#663399" }, // …1 more];<OpenSource repo="acme/ui" version="v2.4.0" stars={24817} forks={1342} contributorCount={186} format="full" maxAvatars={8} showLanguages showActivity feedRows={3} interval={3} starLabel="Star on GitHub" starColor="#f5b301" href="#" description="" activity={activity} starHistory={starHistory} languages={languages} locale="en-US" defaultStarred={false} onStarredChange={(starred) => {}} // contributors={[{ name: "…" }]} // starred={false}/>Where to use Open Source
Repo landing pages
Stars, forks and contributors rolling up on view give a project's homepage real numbers.
GitHub stats on a site
A language bar, sparkline and commit feed summarise a repo without leaving the page.
Developer social proof
Contributor faces fanning open show a healthy community behind the tool.
Pairs with Avatar Stack
Props
OpenSource- repo
- Type string
- "acme/ui"
- Repository as owner/name; the name is set in bold.
- version
- Type string
- "v2.4.0"
- Latest release tag. Empty hides it.
- stars
- Type number
- 24817
- Star count.
- forks
- Type number
- 1342
- Fork count.
- contributorCount
- Type number
- 186
- Total contributors; the faces beyond the row are counted in a +N chip.
- format
- Type "full" | "compact"
- "full"
- 24,817 or 24.8k.
- maxAvatars
- Type number
- 8
- Most contributor faces in the row.
- showLanguages
- Type boolean
- true
- A bar of the repository's languages in their usual colours.
- showActivity
- Type boolean
- true
- Recent commits, merges and releases, stepping one entry at a time.
- feedRows
- Type number
- 3
- Entries in view at once.
- interval
- Type number
- 3
- Time between feed steps.
- starLabel
- Type string
- "Star on GitHub"
- Label of the star button. Empty hides it.
- starColor
- Type string
- "#f5b301"
- Colour of the star once starred, and of the sparkline.
- href
- Type string
- "#"
- Link for the repository name.
- description
- Type string
- ""
- One line under the name. Empty hides it.
- contributors
- Type { name: string; src?: string }[]
- 12 people
- Faces in order. Initials stand in when there is no photo.
- activity
- Type { type: "commit" | "merge" | "release"; title: string; meta?: string }[]
- 8 entries
- Recent activity, newest first. meta is the short SHA, pull request number or tag on the right.
- starHistory
- Type number[]
- 12 points
- Stars per period, oldest first, drawn as a sparkline under the counts. Empty hides it.
- languages
- Type { name: string; share: number; color: string }[]
- TypeScript, CSS, MDX
- Languages and their share in percent, with GitHub's colours by default.
- locale
- Type string
- "en-US"
- Locale for number formatting.
- starred / defaultStarred
- Type boolean
- false
- Whether the viewer has starred, controlled or uncontrolled. Starring adds one to the count.
- onStarredChange
- Type (starred: boolean) => void
- –
- Called when the star button is pressed. Wire it to your own GitHub OAuth flow or open the repo.
- className
- Type string
- –
- Classes for the card.