BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/rare-ui/github-activity

GitHub Activity

rare-ui/github-activity
FreeComponent

A contribution heatmap with a footer panel that expands over the grid to rank your top repositories.

Install it

npx shadcn@latest add https://rareui.com/r/github-activity.json

Source

components/ui/github-activity.tsxrareui.com/r/github-activity.json · first 6 KB
1"use client";
2
3import * as React from "react";
4import { createPortal } from "react-dom";
5import {
6 AnimatePresence,
7 motion,
8 useReducedMotion,
9 type Transition,
10} from "motion/react";
11import { cn } from "@/lib/utils";
12
13export type ContributionLevel = 0 | 1 | 2 | 3 | 4;
14
15export type Contribution = {
16 date: string;
17 count: number;
18 level: ContributionLevel;
19};
20
21export type RepoContribution = {
22 name: string;
23 count: number;
24 logo?: React.ReactNode;
25 href?: string;
26};
27
28const DEFAULT_ACCENT = "#39d353";
29const DEFAULT_CELL_SIZE = 11;
30const DEFAULT_LABEL = "Top contributions in:";
31const DEFAULT_MONTHS = 12;
32const WEEKS_PER_MONTH = 365.25 / 12 / 7;
33const STACK_LIMIT = 3;
34const MIN_CARD_WIDTH = 320;
35const MIN_LABEL_WEEKS = 3;
36// the p-4 on the card, both sides; the width math below has to add it back
37const CARD_PADDING = 32;
38
39const gapFor = (cellSize: number) => Math.max(2, Math.round(cellSize / 4));
40// never zero: weeks.slice(-0) would hand back the whole history instead of nothing
41const weeksFor = (months: number) =>
42 Math.max(1, Math.ceil(months * WEEKS_PER_MONTH));
43
44const useIsoLayoutEffect =
45 typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
46
47const EASE_OUT = [0.22, 1, 0.36, 1] as const;
48const SPRING = { type: "spring", bounce: 0.2, duration: 0.62 } as const;
49const HEADER_SPRING = { ...SPRING, bounce: 0.45 } as const;
50const ROW_SPRING = { ...SPRING, bounce: 0.26, delay: 0.08 } as const;
51const ROW_OFFSET = 16;
52const CELL_FADE = { duration: 0.2, ease: EASE_OUT } as const;
53const TOOLTIP_FADE = { duration: 0.14, ease: EASE_OUT } as const;
54const TOOLTIP_EDGE = 8;
55const COLUMN_STAGGER = 0.012;
56const LABEL_BLUR = 6;
57const LABEL_REVEAL = { duration: 0.45, ease: EASE_OUT } as const;
58
59const LEVELS = [0, 1, 2, 3, 4] as const;
60
61const MONTH_NAMES = [
62 "Jan",
63 "Feb",
64 "Mar",
65 "Apr",
66 "May",
67 "Jun",
68 "Jul",
69 "Aug",
70 "Sep",
71 "Oct",
72 "Nov",
73 "Dec",
74];
75
76function toMonthLabels(weeks: Contribution[][]) {
77 const labels: (string | null)[] = weeks.map(() => null);
78 const monthAt = (index: number) => weeks[index]?.[0]?.date.slice(5, 7);
79
80 let start = 0;
81 for (let i = 1; i <= weeks.length; i++) {
82 if (i < weeks.length && monthAt(i) === monthAt(start)) continue;
83 // a shorter run is narrower than the label itself, so it would sit under the next month
84 if (i - start >= MIN_LABEL_WEEKS) {
85 labels[start] = MONTH_NAMES[Number(monthAt(start)) - 1] ?? null;
86 }
87 start = i;
88 }
89
90 return labels;
91}
92
93// … truncated

What it pulls in

npm packages

  • motion

Other registry items

  • utils

Files it writes

  • components/ui/github-activity.tsx

Facts

Registry
rare-ui
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-07
Last confirmed
4 days ago

Go to the source

rareui.com swamimalode07/rare-ui on GitHub Raw registry item This item as JSON

More from rare-ui

All 13 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Bounce Sidebarbounce-sidebarrare-uiComponentsFree1 dep
Code Blockcode-blockrare-uiComponentsFree3 deps
Duration Pickerduration-pickerrare-uiComponentsFree5 deps
Emoji Reactionemoji-reactionrare-uiComponentsFree4 deps
Family Drawerfamily drawerrare-uiComponentsFree2 deps
Fluid Orbfluid-orbrare-uiComponentsFreeno deps
Folder Componentfolder-componentrare-uiComponentsFree1 dep
Gravity Lettersgravity-lettersrare-uiComponentsFreeno deps
BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex