GitHub Sponsors
Self-drawing Sponsors heart that docks to a header, every sponsor avatar blur-staggering into a grid, then a thank-you headline and a CTA. Single seek-safe timeline, 270 frames at 30fps.
Source
components/kuchi/github-sponsors.tsx
1"use client";23import { loadFont as loadSans } from "@remotion/google-fonts/Manrope";4import { memo, useMemo, useState } from "react";5import {6 AbsoluteFill,7 Easing,8 Img,9 interpolate,10 Sequence,11 useCurrentFrame,12 useVideoConfig,13} from "remotion";14import { BlurOutUp } from "@/components/kuchi/blur-out-up";15import { SoftBlurIn } from "@/components/kuchi/soft-blur-in";1617export interface Sponsor {18 login: string;19 avatarUrl: string;20}2122export interface GitHubSponsorsProps {23 account?: string;24 sponsors?: Sponsor[];25 accentColor?: string;26 speed?: number;27 theme?: "light" | "dark";28}2930export const SAMPLE_SPONSORS: Sponsor[] = [31 {32 login: "mojombo",33 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-01.svg",34 },35 {36 login: "defunkt",37 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-02.svg",38 },39 {40 login: "pjhyett",41 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-03.svg",42 },43 {44 login: "wycats",45 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-04.svg",46 },47 {48 login: "schacon",49 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-05.svg",50 },51 {52 login: "rtomayko",53 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-06.svg",54 },55 {56 login: "bmizerany",57 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-07.svg",58 },59 {60 login: "atmos",61 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-08.svg",62 },63 {64 login: "ezmobius",65 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-09.svg",66 },67 {68 login: "macournoyer",69 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-10.svg",70 },71 {72 login: "ivey",73 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-11.svg",74 },75 {76 login: "uggedal",77 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-12.svg",78 },79 {80 login: "anotherjesse",81 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-13.svg",82 },83 {84 login: "technoweenie",85 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-14.svg",86 },87 {88 login: "takeo",89 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-15.svg",90 },91 {92 login: "evanphx",93 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-16.svg",94 },95 {96 login: "vanpelt",97 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-17.svg",98 },99 {100 login: "wayneeseguin",101 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-18.svg",102 },103 {104 login: "brynary",105 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-01.svg",106 },107 {108 login: "kevinclark",109 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-02.svg",110 },111 {112 login: "kballard",113 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-03.svg",114 },115 {116 login: "jnewland",117 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-04.svg",118 },119 {120 login: "caged",121 avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-05.svg",122 },123 { login: "sr", avatarUrl: "https://kuchi-media.kalarislabs.com/components/art/avatar-06.svg" },124];125126const { fontFamily: SANS_FAMILY } = loadSans();127const FONT_FAMILY = SANS_FAMILY;128129const HEART_PATH =130 "M12.0001 4.52853C14.2745 2.23823 17.9866 2.23823 20.2611 4.52853C22.5784 6.86156 22.5784 10.667 20.2611 13.0001L12.0001 21.3199L3.73907 13.0001C1.42175 10.667 1.42175 6.86156 3.73907 4.52853C6.01353 2.23823 9.72563 2.23823 12.0001 4.52853Z";131132const REF_W = 1280;133const REF_H = 720;134const GRID_CX = 640;135const GRID_CY = 304;136const GRID_BOX_W = 900;137const GRID_BOX_H = 236;138const HEART_START_Y = 286;139const HEART_HEADER_Y = 120;140141const DRAW_END = 40;142const PULSE_END = 62;143const HEART_DOCK_START = 52;144const HEART_DOCK_END = 84;145const AVATAR_START = 70;146const AVATAR_STEP = 3;147const AVATAR_DUR = 22;148const AVATAR_WINDOW = 56;149const THANK_START = 150;150const SUB_START = 166;151const CTA_START = 182;152const CTA_DUR = 22;153154interface Theme {155 bg: string;156 bgSubtle: string;157 fg: string;158 fgMuted: string;159 border: string;160}161162const THEMES: Record<"light" | "dark", Theme> = {163 light: {164 bg: "#ffffff",165 bgSubtle: "#fafafa",166 fg: "#171717",167 fgMuted: "#737373",168 border: "#ededed",169 },170 dark: {171 bg: "#0a0a0a",172 bgSubtle: "#161618",173 fg: "#fafafa",174 fgMuted: "#a1a1aa",175 border: "#262626",176 },177};178179export interface Point {180 x: number;181 y: number;182}183184export function gridColumns(185 count: number,186 boxW = GRID_BOX_W,187 boxH = GRID_BOX_H,188): number {189 if (count <= 0) return 0;190 return Math.max(191 1,192 Math.min(count, Math.round(Math.sqrt((count * boxW) / boxH))),193 );194}195196export function gridLayout(197 count: number,198 cols: number,199 cellW: number,200 cellH: number,201 cx = GRID_CX,202 cy = GRID_CY,203): Point[] {204 if (count <= 0 || cols <= 0) return [];205 const rows = Math.ceil(count / cols);206 const out: Point[] = [];207 for (let i = 0; i < count; i++) {208 const r = Math.floor(i / cols);209 const c = i % cols;210 const rowCount = Math.min(cols, count - r * cols);211 const rowW = (rowCount - 1) * cellW;212 const x = cx - rowW / 2 + c * cellW;213 const totalH = (rows - 1) * cellH;214 const y = cy - totalH / 2 + r * cellH;215 out.push({ x, y });216 }217 return out;218}219220export function heartDrawProgress(frame: number, speed = 1): number {221 return interpolate(frame * speed, [0, DRAW_END], [0, 1], {222 extrapolateLeft: "clamp",223 extrapolateRight: "clamp",224 easing: Easing.bezier(0.22, 1, 0.36, 1),225 });226}227228export function heartPulseScale(frame: number, speed = 1): number {229 return interpolate(230 frame * speed,231 [DRAW_END - 2, DRAW_END + 6, DRAW_END + 17, PULSE_END],232 [1, 0.9, 1.06, 1],233 {234 extrapolateLeft: "clamp",235 extrapolateRight: "clamp",236 easing: Easing.inOut(Easing.ease),237 },238 );239}240241function ramp(242 frame: number,243 speed: number,244 start: number,245 end: number,246 easing = Easing.bezier(0.22, 1, 0.36, 1),247): number {248 return interpolate(frame * speed, [start, end], [0, 1], {249 extrapolateLeft: "clamp",250 extrapolateRight: "clamp",251 easing,252 });253}254255function Avatar({256 login,257 avatarUrl,258 size,259 theme,260 grayscale,261}: {262 login: string;263 avatarUrl: string;264 size: number;265 theme: Theme;266 grayscale: number;267}) {268 const [errored, setErrored] = useState(false);269 const base = {270 width: size,271 height: size,272 borderRadius: 9999,273 border: `1px solid ${theme.border}`,274 flexShrink: 0,275 filter: `grayscale(${grayscale})`,276 } as const;277278 if (errored || !avatarUrl) {279 return (280 <div281 style={{282 ...base,283 background: theme.bgSubtle,284 display: "flex",285 alignItems: "center",286 justifyContent: "center",287 color: theme.fgMuted,288 fontSize: size * 0.42,289 fontWeight: 600,290 fontFamily: FONT_FAMILY,291 }}292 >293 {login.charAt(0).toUpperCase()}294 </div>295 );296 }297298 return (299 <Img300 src={avatarUrl}301 onError={() => setErrored(true)}302 style={{ ...base, objectFit: "cover" }}303 />304 );305}306307const SponsorNode = memo(function SponsorNode({308 sponsor,309 cell,310 progress,311 size,312 theme,313}: {314 sponsor: Sponsor;315 cell: Point;316 progress: number;317 size: number;318 theme: Theme;319}) {320 const y = (1 - progress) * 14;321 const blur = (1 - progress) * 10;322323 return (324 <div325 style={{326 position: "absolute",327 left: cell.x,328 top: cell.y,329 translate: `-50% calc(-50% + ${y}px)`,330 opacity: progress,331 filter: `blur(${blur}px)`,332 willChange: "transform, opacity, filter",333 }}334 >335 <Avatar336 login={sponsor.login}337 avatarUrl={sponsor.avatarUrl}338 size={size}339 theme={theme}340 grayscale={1 - progress}341 />342 </div>343 );344});345346function HeartGlyph({347 size,348 accent,349 draw,350 fill,351}: {352 size: number;353 accent: string;354 draw: number;355 fill: number;356}) {357 return (358 <svg359 xmlns="http://www.w3.org/2000/svg"360 viewBox="0 0 24 24"361 width={size}362 height={size}363 >364 <title>GitHub Sponsors</title>365 <path366 d={HEART_PATH}367 pathLength={1}368 fill={accent}369 fillOpacity={fill}370 stroke={accent}371 strokeWidth={1.4}372 strokeLinejoin="round"373 strokeLinecap="round"374 strokeDasharray={1}375 strokeDashoffset={1 - draw}376 />377 </svg>378 );379}380381export function GitHubSponsors({382 account = "acme",383 sponsors = SAMPLE_SPONSORS,384 accentColor = "#db61a2",385 speed = 1,386 theme = "light",387}: GitHubSponsorsProps) {388 const frame = useCurrentFrame();389 const { width, height } = useVideoConfig();390 const t = THEMES[theme] ?? THEMES.light;391 const stageScale = Math.min(width / REF_W, height / REF_H);392393 const count = sponsors.length;394 const avatarStep =395 count > 1 ? Math.min(AVATAR_STEP, AVATAR_WINDOW / (count - 1)) : 0;396 const cols = gridColumns(count);397 const rows = Math.max(1, Math.ceil(count / Math.max(1, cols)));398 const cellW = GRID_BOX_W / Math.max(1, cols);399 const cellH = GRID_BOX_H / rows;400 const avatarSize = Math.min(84, Math.min(cellW, cellH) * 0.76);401402 const cells = useMemo(403 () => gridLayout(count, cols, cellW, cellH),404 [count, cols, cellW, cellH],405 );406407 const draw = heartDrawProgress(frame, speed);408 const fillO = ramp(frame, speed, DRAW_END - 8, PULSE_END, Easing.linear);409 const pulse = heartPulseScale(frame, speed);410 const dock = ramp(frame, speed, HEART_DOCK_START, HEART_DOCK_END);411412 const heartBase = 168;413 const heartScale = (1 - 0.62 * dock) * pulse;414 const heartDy = (HEART_HEADER_Y - HEART_START_Y) * dock;415416 const ctaProgress = ramp(frame, speed, CTA_START, CTA_START + CTA_DUR);417 const ctaBlur = (1 - ctaProgress) * 10;418 const ctaY = (1 - ctaProgress) * 12;419 const accountOpacity = ramp(420 frame,421 speed,422 CTA_START + 8,423 CTA_START + CTA_DUR + 8,424 );425426 return (427 <AbsoluteFill style={{ background: t.bg }}>428 <div429 style={{430 position: "absolute",431 left: "50%",432 top: "50%",433 width: REF_W,434 height: REF_H,435 translate: "-50% -50%",436 scale: `${stageScale}`,437 }}438 >439 {sponsors.map((sponsor, i) => (440 <SponsorNode441 key={`node-${sponsor.login}-${i}`}442 sponsor={sponsor}443 cell={cells[i]}444 progress={ramp(445 frame,446 speed,447 AVATAR_START + i * avatarStep,448 AVATAR_START + i * avatarStep + AVATAR_DUR,449 )}450 size={avatarSize}451 theme={t}452 />453 ))}454455 <div456 style={{457 position: "absolute",458 left: GRID_CX,459 top: HEART_START_Y,460 translate: `-50% calc(-50% + ${heartDy}px)`,461 scale: `${heartScale}`,462 width: heartBase,463 height: heartBase,464 display: "flex",465 alignItems: "center",466 justifyContent: "center",467 willChange: "transform",468 }}469 >470 <HeartGlyph471 size={heartBase}472 accent={accentColor}473 draw={draw}474 fill={fillO}475 />476 </div>477478 <div479 style={{480 position: "absolute",481 left: 0,482 top: 444,483 width: REF_W,484 height: 84,485 }}486 >487 <Sequence from={Math.round(THANK_START / speed)} layout="none">488 <SoftBlurIn489 text="Thank you"490 fontSize={54}491 fontWeight={600}492 color={t.fg}493 speed={speed}494 />495 </Sequence>496 </div>497498 <div499 style={{500 position: "absolute",501 left: 0,502 top: 532,503 width: REF_W,504 height: 36,505 }}506 >507 <Sequence from={Math.round(SUB_START / speed)} layout="none">508 <BlurOutUp509 text={`Powered by ${count} sponsors`}510 fontSize={24}511 fontWeight={500}512 color={t.fgMuted}513 speed={speed}514 />515 </Sequence>516 </div>517518 <div519 style={{520 position: "absolute",521 left: 0,522 top: 584,523 width: REF_W,524 display: "flex",525 flexDirection: "column",526 alignItems: "center",527 gap: 12,528 }}529 >530 <div531 style={{532 translate: `0 ${ctaY}px`,533 opacity: ctaProgress,534 filter: `blur(${ctaBlur}px)`,535 display: "flex",536 alignItems: "center",537 gap: 10,538 padding: "14px 26px",539 borderRadius: 9999,540 background: accentColor,541 color: "#ffffff",542 fontSize: 24,543 fontWeight: 600,544 fontFamily: FONT_FAMILY,545 willChange: "transform, opacity, filter",546 }}547 >548 <HeartGlyph size={22} accent="#ffffff" draw={1} fill={1} />549 Become a sponsor550 </div>551 <div552 style={{553 opacity: accountOpacity * 0.9,554 fontSize: 18,555 fontWeight: 400,556 color: t.fgMuted,557 fontFamily: FONT_FAMILY,558 }}559 >560 github.com/sponsors/{account}561 </div>562 </div>563 </div>564 </AbsoluteFill>565 );566}









