X Followers Overview
X follow notifications cycle through as 3D flipping text — '<name> followed you · 7h' — then the total follower count pops in with a confetti burst. Hardcoded sample list (X API ready). Light/dark, horizontal or vertical.
Source
components/kuchi/x-followers-overview.tsx
1"use client";23import { loadFont as loadSans } from "@remotion/google-fonts/Manrope";4import { useState } from "react";5import {6 AbsoluteFill,7 Img,8 interpolate,9 spring,10 useCurrentFrame,11 useVideoConfig,12} from "remotion";13import { Confetti } from "@/components/kuchi/confetti";1415export interface FollowerNotification {16 name: string;17 verified: boolean;18 /** Relative time label, e.g. "7h", "1d". */19 time: string;20}2122export interface XFollowersOverviewProps {23 notifications?: FollowerNotification[];24 totalFollowers?: number;25 handle?: string;26 avatarUrl?: string;27 accentColor?: string;28 orientation?: "horizontal" | "vertical";29 speed?: number;30}3132const { fontFamily: SANS_FAMILY } = loadSans();33const FONT_FAMILY = SANS_FAMILY;3435interface Theme {36 bg: string;37 fg: string;38 fgMuted: string;39 border: string;40}4142const THEMES: Record<"light" | "dark", Theme> = {43 light: {44 bg: "#ffffff",45 fg: "#0f1419",46 fgMuted: "#536471",47 border: "#eff3f4",48 },49 dark: {50 bg: "#0a0a0a",51 fg: "#e7e9ea",52 fgMuted: "#71767b",53 border: "#2f3336",54 },55};5657/**58 * Hardcoded sample notifications so the composition renders immediately from59 * defaults. A future revision swaps this for live X API data.60 */61export const SAMPLE_FOLLOWERS: FollowerNotification[] = [62 { name: "Andre Vitorio", verified: true, time: "7h" },63 { name: "Sarah Chen", verified: true, time: "7h" },64 { name: "marcus", verified: false, time: "8h" },65 { name: "Lena Powell", verified: true, time: "9h" },66 { name: "dev_jay", verified: false, time: "10h" },67 { name: "Priya Nair", verified: true, time: "11h" },68 { name: "Tomás Rivera", verified: true, time: "13h" },69 { name: "hana.eth", verified: false, time: "15h" },70 { name: "Will Carter", verified: true, time: "18h" },71 { name: "Yuki Tanaka", verified: true, time: "21h" },72 { name: "benoit", verified: false, time: "23h" },73 { name: "Amara Okafor", verified: true, time: "1d" },74 { name: "Leo Martins", verified: true, time: "1d" },75 { name: "sol", verified: false, time: "2d" },76];7778// --- Pure helpers (unit-tested) -------------------------------------------7980/** Map an effective frame to the active notification index + in-slot fraction. */81export function slotProgress(82 fc: number,83 slotFrames: number,84 count: number,85): { idx: number; frac: number } {86 if (slotFrames <= 0 || count <= 0) return { idx: 0, frac: 0 };87 const pos = fc / slotFrames;88 const idx = Math.max(0, Math.min(Math.floor(pos), count - 1));89 const frac = Math.max(0, Math.min(pos - idx, 1));90 return { idx, frac };91}9293/** Smoothstep flip ramp: rest for `hold` of the slot, then flip 0→1. */94export function flipEase(frac: number, hold: number): number {95 if (hold >= 1) return 0;96 const raw = (frac - hold) / (1 - hold);97 const c = Math.max(0, Math.min(raw, 1));98 return c * c * (3 - 2 * c);99}100101export function blurIn(102 frame: number,103 start: number,104 end: number,105): { blur: number; opacity: number; translateY: number } {106 const range: [number, number] = [start, end];107 const opts = {108 extrapolateLeft: "clamp" as const,109 extrapolateRight: "clamp" as const,110 };111 return {112 blur: interpolate(frame, range, [10, 0], opts),113 opacity: interpolate(frame, range, [0, 1], opts),114 translateY: interpolate(frame, range, [12, 0], opts),115 };116}117118// --- Sub-components --------------------------------------------------------119120function VerifiedBadge({ accent, size }: { accent: string; size: number }) {121 return (122 <svg123 xmlns="http://www.w3.org/2000/svg"124 viewBox="0 0 22 22"125 width={size}126 height={size}127 fill={accent}128 style={{ flexShrink: 0 }}129 >130 <title>Verified</title>131 <path d="M20.396 11c-.018-.646-.215-1.275-.57-1.816-.354-.54-.852-.972-1.438-1.246.223-.607.27-1.264.14-1.897-.131-.634-.437-1.218-.882-1.687-.47-.445-1.053-.75-1.687-.882-.633-.13-1.29-.083-1.897.14-.273-.587-.704-1.086-1.245-1.44S11.647 1.62 11 1.604c-.646.017-1.273.213-1.813.568s-.969.854-1.24 1.44c-.608-.223-1.267-.272-1.902-.14-.635.13-1.22.436-1.69.882-.445.47-.749 1.055-.878 1.688-.13.633-.08 1.29.144 1.896-.587.274-1.087.705-1.443 1.245-.356.54-.555 1.17-.574 1.817.02.647.218 1.276.574 1.817.356.54.856.972 1.443 1.245-.224.606-.274 1.263-.144 1.896.13.634.433 1.218.877 1.688.47.443 1.054.747 1.687.878.633.132 1.29.084 1.897-.136.274.586.705 1.084 1.246 1.439.54.354 1.17.551 1.816.569.647-.016 1.276-.213 1.817-.567s.972-.854 1.245-1.44c.604.239 1.266.296 1.903.164.636-.132 1.22-.447 1.68-.907.46-.46.776-1.044.908-1.681s.075-1.299-.165-1.903c.586-.274 1.084-.705 1.439-1.246.354-.54.551-1.17.569-1.816zM9.662 14.85l-3.429-3.428 1.293-1.302 2.072 2.072 4.4-4.794 1.347 1.246z" />132 </svg>133 );134}135136function Avatar({137 avatarUrl,138 handle,139 size,140 theme,141}: {142 avatarUrl: string;143 handle: string;144 size: number;145 theme: Theme;146}) {147 const [errored, setErrored] = useState(false);148 const ringStyle = {149 width: size,150 height: size,151 borderRadius: 9999,152 border: `1px solid ${theme.border}`,153 flexShrink: 0,154 } as const;155156 if (errored || !avatarUrl) {157 return (158 <div159 style={{160 ...ringStyle,161 background: theme.border,162 display: "flex",163 alignItems: "center",164 justifyContent: "center",165 color: theme.fgMuted,166 fontSize: size * 0.42,167 fontWeight: 700,168 fontFamily: FONT_FAMILY,169 }}170 >171 {handle.charAt(0).toUpperCase()}172 </div>173 );174 }175176 return (177 <Img178 src={avatarUrl}179 onError={() => setErrored(true)}180 style={{ ...ringStyle, objectFit: "cover" }}181 />182 );183}184185/** Username + verified badge — the only part that flips. Absolutely overlaid186 * and centered inside a slot sized to the active name, so the line as a whole187 * stays centered while names swap. */188function NameBlock({189 item,190 fontSize,191 height,192 theme,193 accent,194 deg,195 opacity,196}: {197 item: FollowerNotification;198 fontSize: number;199 height: number;200 theme: Theme;201 accent: string;202 deg: number;203 opacity: number;204}) {205 return (206 <div207 style={{208 position: "absolute",209 left: 0,210 right: 0,211 top: 0,212 height,213 display: "flex",214 alignItems: "center",215 justifyContent: "center",216 gap: fontSize * 0.2,217 whiteSpace: "nowrap",218 transformOrigin: "center",219 backfaceVisibility: "hidden",220 transform: `rotateX(${deg}deg)`,221 opacity,222 }}223 >224 <span225 style={{226 fontFamily: FONT_FAMILY,227 fontSize,228 fontWeight: 800,229 color: theme.fg,230 lineHeight: 1,231 }}232 >233 {item.name}234 </span>235 {item.verified && (236 <VerifiedBadge accent={accent} size={fontSize * 0.66} />237 )}238 </div>239 );240}241242// --- Main composition ------------------------------------------------------243244export function XFollowersOverview({245 notifications = SAMPLE_FOLLOWERS,246 totalFollowers = 1709,247 handle = "acme",248 avatarUrl = "https://kuchi-media.kalarislabs.com/components/art/avatar-03.svg",249 accentColor = "#1d9bf0",250 orientation = "horizontal",251 speed = 1,252}: XFollowersOverviewProps) {253 const frame = useCurrentFrame();254 const { durationInFrames, width, height, fps } = useVideoConfig();255 const t = THEMES.light;256 const isVertical = orientation === "vertical";257258 const refW = isVertical ? 720 : 1280;259 const refH = isVertical ? 1280 : 720;260 const stageScale = Math.min(width / refW, height / refH);261262 const notifSize = isVertical ? 38 : 46;263 const countNum = isVertical ? 92 : 110;264 const countLabel = isVertical ? 40 : 46;265 const perspective = isVertical ? 1000 : 1200;266 const stageH = isVertical ? 160 : 180;267 const lineH = notifSize * 1.4;268 // Fast cadence: ~0.43s per username at speed 1; flip occupies the back half.269 const SLOT = 13;270 const HOLD = 0.45;271272 const fc = frame * speed;273 const items = notifications.length > 0 ? notifications : SAMPLE_FOLLOWERS;274 const count = items.length;275276 // Notifications cycle first, then the total blurs in. The reveal starts once277 // the list is exhausted, capped so it always fits before the timeline ends.278 const revealStart = Math.min(279 count * SLOT,280 Math.round(durationInFrames * 0.82),281 );282283 const { idx, frac } = slotProgress(fc, SLOT, count);284 const flipP = flipEase(frac, HOLD);285 const hasNext = idx + 1 < count;286287 const current = items[idx];288 const next = hasNext ? items[idx + 1] : undefined;289 const activeItem = flipP >= 0.5 && next ? next : current;290291 const currentDeg = hasNext ? -90 * flipP : 0;292 const currentOpacity = hasNext293 ? interpolate(flipP, [0, 0.55], [1, 0], {294 extrapolateLeft: "clamp",295 extrapolateRight: "clamp",296 })297 : 1;298 const nextDeg = 90 * (1 - flipP);299 const nextOpacity = interpolate(flipP, [0.45, 1], [0, 1], {300 extrapolateLeft: "clamp",301 extrapolateRight: "clamp",302 });303304 const notifOpacity = interpolate(305 fc,306 [revealStart - 4, revealStart + 8],307 [1, 0],308 { extrapolateLeft: "clamp", extrapolateRight: "clamp" },309 );310 const countIn = blurIn(fc, revealStart + 4, revealStart + 28);311 // Dynamic pop: spring overshoot on the total as it blurs in.312 const revealSpring = spring({313 fps,314 frame: fc - (revealStart + 2),315 config: { damping: 10, stiffness: 170, mass: 0.8 },316 });317 const revealScale = interpolate(revealSpring, [0, 1], [0.5, 1]);318319 // Avatar + handle reveal in sync with the total: same window as countIn,320 // avatar sliding in from the left, handle from the right.321 const avatarSize = isVertical ? 72 : 64;322 const handleSize = isVertical ? 30 : 34;323 const avatarIn = blurIn(fc, revealStart + 4, revealStart + 28);324 const handleIn = avatarIn;325 const slideOpts = {326 extrapolateLeft: "clamp" as const,327 extrapolateRight: "clamp" as const,328 };329 const avatarX = interpolate(330 fc,331 [revealStart + 4, revealStart + 28],332 [-36, 0],333 slideOpts,334 );335 const handleX = interpolate(336 fc,337 [revealStart + 4, revealStart + 28],338 [36, 0],339 slideOpts,340 );341342 // Confetti fires on the real frame the reveal begins (sync across speeds),343 // centered on the canvas.344 const confettiStart = Math.round((revealStart + 2) / speed);345 const confettiColors = [346 accentColor,347 "#ff5da2",348 "#ffd23f",349 "#22c55e",350 "#a855f7",351 ];352353 return (354 <AbsoluteFill style={{ background: "transparent" }}>355 <div356 style={{357 position: "absolute",358 left: "50%",359 top: "50%",360 width: refW,361 height: refH,362 translate: "-50% -50%",363 scale: `${stageScale}`,364 }}365 >366 <div367 style={{368 position: "absolute",369 inset: 0,370 display: "flex",371 alignItems: "center",372 justifyContent: "center",373 }}374 >375 <div style={{ position: "relative", width: refW, height: stageH }}>376 {/* Cycling notifications — only the username flips in 3D, the377 "followed you · <time>" suffix stays put. */}378 <div379 style={{380 position: "absolute",381 inset: 0,382 display: "flex",383 alignItems: "center",384 justifyContent: "center",385 gap: notifSize * 0.28,386 opacity: notifOpacity,387 }}388 >389 <div390 style={{391 position: "relative",392 height: lineH,393 perspective,394 display: "inline-flex",395 }}396 >397 {/* Invisible spacer sizes the slot to the active name so the398 whole line stays centered; flips overlay it absolutely. */}399 <div400 aria-hidden="true"401 style={{402 visibility: "hidden",403 display: "flex",404 alignItems: "center",405 gap: notifSize * 0.2,406 whiteSpace: "nowrap",407 fontFamily: FONT_FAMILY,408 fontSize: notifSize,409 fontWeight: 800,410 }}411 >412 {activeItem.name}413 {activeItem.verified && (414 <span style={{ width: notifSize * 0.66 }} />415 )}416 </div>417 <NameBlock418 item={current}419 fontSize={notifSize}420 height={lineH}421 theme={t}422 accent={accentColor}423 deg={currentDeg}424 opacity={currentOpacity}425 />426 {next && (427 <NameBlock428 item={next}429 fontSize={notifSize}430 height={lineH}431 theme={t}432 accent={accentColor}433 deg={nextDeg}434 opacity={nextOpacity}435 />436 )}437 </div>438 <span439 style={{440 fontFamily: FONT_FAMILY,441 fontSize: notifSize,442 fontWeight: 500,443 color: t.fgMuted,444 whiteSpace: "nowrap",445 lineHeight: 1,446 }}447 >448 followed you · {activeItem.time}449 </span>450 </div>451452 {/* Total reveal: avatar + handle above the count */}453 <div454 style={{455 position: "absolute",456 inset: 0,457 display: "flex",458 flexDirection: "column",459 alignItems: "center",460 justifyContent: "center",461 gap: isVertical ? 26 : 22,462 }}463 >464 <div465 style={{466 display: "flex",467 alignItems: "center",468 gap: 14,469 }}470 >471 <div472 style={{473 opacity: avatarIn.opacity,474 filter:475 avatarIn.blur > 0 ? `blur(${avatarIn.blur}px)` : "none",476 translate: `${avatarX}px`,477 }}478 >479 <Avatar480 avatarUrl={avatarUrl}481 handle={handle}482 size={avatarSize}483 theme={t}484 />485 </div>486 <span487 style={{488 fontFamily: FONT_FAMILY,489 fontSize: handleSize,490 fontWeight: 700,491 color: t.fg,492 whiteSpace: "nowrap",493 opacity: handleIn.opacity,494 filter:495 handleIn.blur > 0 ? `blur(${handleIn.blur}px)` : "none",496 translate: `${handleX}px`,497 }}498 >499 @{handle}500 </span>501 </div>502503 <div504 style={{505 display: "flex",506 alignItems: "baseline",507 justifyContent: "center",508 gap: 18,509 opacity: countIn.opacity,510 filter: countIn.blur > 0 ? `blur(${countIn.blur}px)` : "none",511 translate: `0 ${countIn.translateY}px`,512 scale: `${revealScale}`,513 }}514 >515 <span516 style={{517 fontFamily: FONT_FAMILY,518 fontSize: countNum,519 fontWeight: 800,520 color: t.fg,521 letterSpacing: "-0.03em",522 fontVariantNumeric: "tabular-nums",523 lineHeight: 1,524 }}525 >526 {totalFollowers.toLocaleString("en-US")}527 </span>528 <span529 style={{530 fontFamily: FONT_FAMILY,531 fontSize: countLabel,532 fontWeight: 500,533 color: t.fgMuted,534 lineHeight: 1,535 }}536 >537 Followers538 </span>539 </div>540 </div>541 </div>542 </div>543 </div>544545 <Confetti546 startFrame={confettiStart}547 originX={0.5}548 originY={0.5}549 colors={confettiColors}550 particleCount={160}551 />552 </AbsoluteFill>553 );554}









