Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "now-playing",
"title": "Now Playing",
"description": "A music player with lyrics highlights a line on a colored gradient background.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"registryDependencies": ["@remocn/gsh"],
"files": [
{
"path": "registry/remocn/now-playing/index.tsx",
"content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/Figtree\";\nimport type React from \"react\";\nimport { useId } from \"react\";\nimport {\n AbsoluteFill,\n Easing,\n Img,\n interpolate,\n spring,\n useCurrentFrame,\n useVideoConfig,\n} from \"remotion\";\nimport type { GradientParams } from \"@/lib/remocn/gsh/gradient-engine\";\nimport { GshGround } from \"@/lib/remocn/gsh/gsh-ground\";\nimport type { GshPresetId } from \"@/lib/remocn/gsh/presets\";\n\nconst { fontFamily } = loadFont(\"normal\", {\n weights: [\"300\", \"400\"],\n subsets: [\"latin\"],\n});\n\nexport interface NowPlayingProps {\n title?: string;\n artist?: string;\n playlist?: string;\n src?: string;\n tint?: string;\n lyrics?: string[];\n duration?: number;\n variant?: \"full\" | \"mini\";\n accent?: string;\n speed?: number;\n ground?: GshPresetId;\n groundParams?: Partial<GradientParams>;\n}\n\nconst DEFAULT_LYRICS = [\n \"Shipped it at midnight\",\n \"and the build came green\",\n \"every frame in motion\",\n \"every pixel in line\",\n \"press play on launch day\",\n \"watch the counter climb\",\n \"we wrote it all in React\",\n \"and rendered it in time\",\n];\n\nconst SW = 393;\nconst SH = 852;\nconst BEZEL = 11;\nconst BW = SW + BEZEL * 2;\nconst BH = SH + BEZEL * 2;\nconst ART = { x: 24, y: 122, s: SW - 48 };\nconst PLAY = { x: SW / 2, y: 650 };\nconst HEART = { x: SW - 38, y: 524 };\nconst MINI_Y = SH - 84 - 62;\nconst MINI_ART = { x: 8, y: 8, s: 40 };\n\nconst TAP_PLAY = 28;\nconst TAP_HEART = 64;\nconst LYRICS = 100;\nconst LINE0 = 124;\nconst LINE_LEN = 18;\nconst MINI_TAP = 30;\nconst MINI_OFFSET = 52;\n\nconst clamp = { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" } as const;\nconst lerp = (a: number, b: number, t: number) => a + (b - a) * t;\n\nfunction rgb(hex: string) {\n const h = hex.replace(\"#\", \"\");\n const full =\n h.length === 3\n ? h\n .split(\"\")\n .map((ch) => ch + ch)\n .join(\"\")\n : h.slice(0, 6);\n const n = Number.parseInt(full, 16);\n return [(n >> 16) & 255, (n >> 8) & 255, n & 255];\n}\nfunction mix(a: string, b: string, t: number) {\n const x = rgb(a);\n const y = rgb(b);\n const m = x.map((v, i) => Math.round(v + (y[i] - v) * t));\n return `rgb(${m[0]}, ${m[1]}, ${m[2]})`;\n}\nconst fmt = (sec: number) => {\n const s = Math.max(0, Math.floor(sec));\n return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, \"0\")}`;\n};\n\nconst ICON = {\n down: \"M6 9l6 6 6-6\",\n shuffle: \"M16 4h4v4M4 20L20 4M16 20h4v-4M14.5 14.5L20 20M4 4l5 5\",\n prev: \"M7 5v14M19 5L9 12l10 7z\",\n next: \"M17 5v14M5 5l10 7-10 7z\",\n repeat:\n \"M17 2l3 3-3 3M4 11V9a4 4 0 014-4h12M7 22l-3-3 3-3M20 13v2a4 4 0 01-4 4H4\",\n devices: \"M4 5h11v10H4zM8 19h3M18 8h2.5v11H18z\",\n share: \"M12 3v12M7 8l5-5 5 5M5 13v7h14v-7\",\n queue: \"M4 6h12M4 12h12M4 18h8M19 15v6M16 18h6\",\n heart:\n \"M12 20.5s-8-4.9-8-10.6A4.6 4.6 0 0112 7a4.6 4.6 0 018 2.9c0 5.7-8 10.6-8 10.6z\",\n home: \"M4 11l8-7 8 7v9h-5v-6H9v6H4z\",\n search: \"M11 4a7 7 0 100 14 7 7 0 000-14zM20 20l-4-4\",\n library: \"M5 4v16M10 4v16M15 5l4 15\",\n plus: \"M12 5v14M5 12h14\",\n expand: \"M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7\",\n};\n\nfunction Glyph({\n d,\n size = 24,\n color = \"#fff\",\n sw = 2,\n fill = \"none\",\n}: {\n d: string;\n size?: number;\n color?: string;\n sw?: number;\n fill?: string;\n}) {\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill={fill}\n style={{ flexShrink: 0 }}\n >\n <path\n d={d}\n stroke={color}\n strokeWidth={sw}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\nfunction PlayPause({\n m,\n size,\n color,\n}: {\n m: number;\n size: number;\n color: string;\n}) {\n const L: number[][][] = [\n [\n [-6, -10],\n [-7, -9],\n ],\n [\n [2, -5.5],\n [-2, -9],\n ],\n [\n [2, 5.5],\n [-2, 9],\n ],\n [\n [-6, 10],\n [-7, 9],\n ],\n ];\n const R: number[][][] = [\n [\n [2, -5.5],\n [2, -9],\n ],\n [\n [10, 0],\n [7, -9],\n ],\n [\n [10, 0],\n [7, 9],\n ],\n [\n [2, 5.5],\n [2, 9],\n ],\n ];\n const path = (pts: number[][][]) =>\n `M${pts.map(([a, b]) => `${lerp(a[0], b[0], m) + 12} ${lerp(a[1], b[1], m) + 12}`).join(\"L\")}Z`;\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\">\n <path\n d={path(L)}\n fill={color}\n stroke={color}\n strokeWidth={1.2}\n strokeLinejoin=\"round\"\n />\n <path\n d={path(R)}\n fill={color}\n stroke={color}\n strokeWidth={1.2}\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\nfunction ridge(seed: number, base: number, amp: number, freq: number) {\n let d = \"M0 100\";\n for (let x = 0; x <= 100; x += 2) {\n const y =\n base -\n amp *\n (0.55 * Math.sin(x * freq + seed) +\n 0.3 * Math.sin(x * freq * 2.3 + seed * 1.7) +\n 0.15 * Math.sin(x * freq * 5.9 + seed * 3.1));\n d += `L${x} ${y.toFixed(2)}`;\n }\n return `${d}L100 100Z`;\n}\n\nfunction Artwork({\n size,\n tint,\n src,\n radius,\n title,\n artist,\n seed = 0,\n}: {\n size: number;\n tint: string;\n src?: string;\n radius: number;\n title?: string;\n artist?: string;\n seed?: number;\n}) {\n const id = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n if (src) {\n return (\n <Img\n src={src}\n style={{\n width: size,\n height: size,\n borderRadius: radius,\n objectFit: \"cover\",\n display: \"block\",\n }}\n />\n );\n }\n const sunX = 58 + ((seed * 23) % 30) - 15;\n const sunY = 52 + ((seed * 11) % 10);\n const far = mix(tint, \"#F6B48A\", 0.55);\n const mid = mix(tint, \"#3A1E2A\", 0.45);\n const near = mix(tint, \"#0E0A12\", 0.82);\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 100 100\"\n style={{ display: \"block\", borderRadius: radius }}\n >\n <defs>\n <linearGradient id={`${id}sky`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n <stop offset=\"0\" stopColor={mix(tint, \"#120E24\", 0.72)} />\n <stop offset=\"0.38\" stopColor={mix(tint, \"#5A3A6E\", 0.35)} />\n <stop offset=\"0.62\" stopColor={mix(tint, \"#F49A6C\", 0.6)} />\n <stop offset=\"0.78\" stopColor=\"#FFD3A1\" />\n </linearGradient>\n <radialGradient\n id={`${id}sun`}\n cx={sunX}\n cy={sunY}\n r=\"34\"\n gradientUnits=\"userSpaceOnUse\"\n >\n <stop offset=\"0\" stopColor=\"#FFF4DE\" />\n <stop offset=\"0.12\" stopColor=\"#FFE2B0\" stopOpacity={0.95} />\n <stop offset=\"0.4\" stopColor=\"#FFB27A\" stopOpacity={0.35} />\n <stop offset=\"1\" stopColor=\"#FF8A5C\" stopOpacity={0} />\n </radialGradient>\n <linearGradient id={`${id}haze`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n <stop offset=\"0.45\" stopColor=\"#FFC896\" stopOpacity={0} />\n <stop offset=\"0.72\" stopColor=\"#FFC896\" stopOpacity={0.28} />\n <stop offset=\"1\" stopColor={near} stopOpacity={0} />\n </linearGradient>\n <radialGradient\n id={`${id}vig`}\n cx=\"50\"\n cy=\"48\"\n r=\"72\"\n gradientUnits=\"userSpaceOnUse\"\n >\n <stop offset=\"0.55\" stopColor=\"#000\" stopOpacity={0} />\n <stop offset=\"1\" stopColor=\"#000\" stopOpacity={0.45} />\n </radialGradient>\n <filter id={`${id}grain`} x=\"0\" y=\"0\" width=\"100%\" height=\"100%\">\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"1.6\"\n numOctaves={2}\n seed={seed + 3}\n stitchTiles=\"stitch\"\n />\n <feColorMatrix values=\"0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 1.6 -0.55\" />\n </filter>\n </defs>\n <rect width=\"100\" height=\"100\" fill={`url(#${id}sky)`} />\n <rect width=\"100\" height=\"100\" fill={`url(#${id}sun)`} />\n <path d={ridge(seed + 1, 66, 7, 0.07)} fill={far} opacity={0.75} />\n <rect width=\"100\" height=\"100\" fill={`url(#${id}haze)`} />\n <path d={ridge(seed + 4, 76, 8, 0.05)} fill={mid} />\n <path d={ridge(seed + 9, 88, 6, 0.09)} fill={near} />\n <rect width=\"100\" height=\"100\" fill={`url(#${id}vig)`} />\n <rect\n width=\"100\"\n height=\"100\"\n filter={`url(#${id}grain)`}\n opacity={0.16}\n style={{ mixBlendMode: \"overlay\" }}\n />\n {artist ? (\n <text\n x=\"7\"\n y=\"11\"\n fill=\"#FFF7EC\"\n fontFamily={fontFamily}\n fontSize=\"4.4\"\n fontWeight={400}\n letterSpacing=\"0.05\"\n >\n {artist}\n </text>\n ) : null}\n {title ? (\n <text\n x=\"7\"\n y=\"94\"\n fill=\"#FFF7EC\"\n fillOpacity={0.82}\n fontFamily={fontFamily}\n fontSize=\"3.6\"\n fontWeight={400}\n letterSpacing=\"0.6\"\n >\n {title.toUpperCase()}\n </text>\n ) : null}\n </svg>\n );\n}\n\nfunction StatusBar() {\n return (\n <div\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n height: 54,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n padding: \"6px 34px 0 52px\",\n boxSizing: \"border-box\",\n zIndex: 30,\n color: \"#fff\",\n }}\n >\n <span style={{ fontSize: 17, fontWeight: 400 }}>9:41</span>\n <div style={{ display: \"flex\", gap: 6, alignItems: \"center\" }}>\n <svg width=\"18\" height=\"12\" viewBox=\"0 0 18 12\">\n {[0, 1, 2, 3].map((i) => (\n <rect\n key={i}\n x={i * 4.6}\n y={9 - i * 3}\n width={3.2}\n height={3 + i * 3}\n rx={0.8}\n fill=\"#fff\"\n />\n ))}\n </svg>\n <div\n style={{\n width: 25,\n height: 12,\n borderRadius: 3.5,\n border: \"1px solid rgba(255,255,255,0.8)\",\n padding: 1.5,\n boxSizing: \"border-box\",\n }}\n >\n <div\n style={{\n width: \"80%\",\n height: \"100%\",\n borderRadius: 2,\n background: \"#fff\",\n }}\n />\n </div>\n </div>\n </div>\n );\n}\n\nfunction Phone({ children }: { children: React.ReactNode }) {\n const btn = (side: \"left\" | \"right\", top: number, h: number) => (\n <div\n style={{\n position: \"absolute\",\n [side]: -3,\n top,\n width: 4,\n height: h,\n borderRadius: 2,\n background: \"linear-gradient(90deg,#8E8E93,#C7C7CC,#8E8E93)\",\n }}\n />\n );\n return (\n <div style={{ position: \"relative\", width: BW, height: BH }}>\n {btn(\"left\", 150, 32)}\n {btn(\"left\", 210, 62)}\n {btn(\"left\", 284, 62)}\n {btn(\"right\", 236, 98)}\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n borderRadius: 66,\n background: \"#0B0B0C\",\n boxShadow:\n \"inset 0 0 0 2.5px #A1A1A6, inset 0 0 0 4px #2A2A2D, 0 60px 120px rgba(0,0,0,0.6)\",\n }}\n />\n <div\n style={{\n position: \"absolute\",\n left: BEZEL,\n top: BEZEL,\n width: SW,\n height: SH,\n borderRadius: 55,\n overflow: \"hidden\",\n background: \"#121212\",\n }}\n >\n {children}\n <div\n style={{\n position: \"absolute\",\n top: 11,\n left: (SW - 126) / 2,\n width: 126,\n height: 37,\n borderRadius: 19,\n background: \"#000\",\n zIndex: 40,\n }}\n />\n <div\n style={{\n position: \"absolute\",\n bottom: 8,\n left: (SW - 134) / 2,\n width: 134,\n height: 5,\n borderRadius: 3,\n background: \"#fff\",\n zIndex: 40,\n }}\n />\n </div>\n </div>\n );\n}\n\nfunction HeartBurst({ t, accent }: { t: number; accent: string }) {\n if (t <= 0 || t > 20) return null;\n const p = Easing.bezier(0.22, 1, 0.36, 1)(Math.min(1, t / 16));\n return (\n <svg\n width={80}\n height={80}\n viewBox=\"-40 -40 80 80\"\n style={{ position: \"absolute\", left: -26, top: -26, overflow: \"visible\" }}\n >\n {Array.from({ length: 8 }, (_, i) => {\n const a = (i / 8) * Math.PI * 2 - Math.PI / 2;\n const r0 = 12 + p * 10;\n const r1 = 14 + p * 17;\n return (\n <line\n key={i}\n x1={Math.cos(a) * r0}\n y1={Math.sin(a) * r0}\n x2={Math.cos(a) * r1}\n y2={Math.sin(a) * r1}\n stroke={i % 2 ? \"#fff\" : accent}\n strokeWidth={2.4 * (1 - p) + 0.4}\n strokeLinecap=\"round\"\n opacity={1 - p * 0.9}\n />\n );\n })}\n <circle\n r={10 + p * 16}\n fill=\"none\"\n stroke={accent}\n strokeWidth={2 * (1 - p)}\n opacity={1 - p}\n />\n </svg>\n );\n}\n\nconst TILE_TINTS = [\n \"#3E6E8E\",\n \"#8C4A6B\",\n \"#B8553A\",\n \"#4F7A55\",\n \"#6B5B95\",\n \"#A8743A\",\n];\n\nfunction MiniHome({ tint, artist }: { tint: string; artist: string }) {\n const tiles = [\n \"Launch Week Mix\",\n \"Deep Focus\",\n \"Saved Tracks\",\n \"Shipping Hours\",\n \"Lo-fi Builds\",\n \"New This Week\",\n ];\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n background: `linear-gradient(${mix(tint, \"#121212\", 0.75)}, #121212 38%)`,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n top: 70,\n left: 16,\n display: \"flex\",\n gap: 8,\n }}\n >\n <div\n style={{\n width: 32,\n height: 32,\n borderRadius: 16,\n background:\n \"radial-gradient(circle at 30% 30%, #FFC9A8, #E2763F 70%)\",\n color: \"#fff\",\n fontSize: 13,\n fontWeight: 400,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n M\n </div>\n {[\"All\", \"Music\", \"Podcasts\"].map((t, i) => (\n <div\n key={t}\n style={{\n height: 32,\n padding: \"0 14px\",\n borderRadius: 16,\n background: i === 0 ? \"#fff\" : \"rgba(255,255,255,0.1)\",\n color: i === 0 ? \"#000\" : \"#fff\",\n fontSize: 13,\n fontWeight: 400,\n display: \"flex\",\n alignItems: \"center\",\n }}\n >\n {t}\n </div>\n ))}\n </div>\n <div\n style={{\n position: \"absolute\",\n top: 118,\n left: 16,\n right: 16,\n display: \"flex\",\n flexWrap: \"wrap\",\n gap: 8,\n }}\n >\n {tiles.map((t, i) => (\n <div\n key={t}\n style={{\n width: (SW - 40) / 2,\n height: 56,\n borderRadius: 5,\n background: \"rgba(255,255,255,0.08)\",\n display: \"flex\",\n alignItems: \"center\",\n gap: 10,\n overflow: \"hidden\",\n color: \"#fff\",\n fontSize: 12.5,\n fontWeight: 400,\n }}\n >\n <Artwork\n size={56}\n radius={0}\n tint={TILE_TINTS[i % TILE_TINTS.length]}\n seed={i + 2}\n />\n {t}\n </div>\n ))}\n </div>\n <div\n style={{\n position: \"absolute\",\n top: 342,\n left: 16,\n color: \"#fff\",\n fontSize: 22,\n fontWeight: 400,\n letterSpacing: \"-0.02em\",\n }}\n >\n Made for Maya\n </div>\n <div\n style={{\n position: \"absolute\",\n top: 384,\n left: 16,\n display: \"flex\",\n gap: 14,\n }}\n >\n {[\"Morning Mix\", \"Weekly Picks\", \"Studio Mix\"].map((t, i) => (\n <div key={t} style={{ width: 150 }}>\n <Artwork\n size={150}\n radius={6}\n tint={TILE_TINTS[(i + 3) % TILE_TINTS.length]}\n seed={i + 7}\n artist={t}\n />\n <div\n style={{\n color: \"#fff\",\n fontSize: 13,\n fontWeight: 400,\n marginTop: 8,\n }}\n >\n {t}\n </div>\n <div\n style={{\n color: \"rgba(255,255,255,0.6)\",\n fontSize: 12,\n marginTop: 3,\n }}\n >\n {i === 1\n ? `${artist}, Halcyon and more`\n : \"Kitebase, Lumen and more\"}\n </div>\n </div>\n ))}\n </div>\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n bottom: 0,\n height: 84,\n background: \"linear-gradient(transparent, rgba(0,0,0,0.92) 40%)\",\n display: \"flex\",\n justifyContent: \"space-around\",\n paddingTop: 18,\n boxSizing: \"border-box\",\n }}\n >\n {(\n [\n [\"Home\", ICON.home],\n [\"Search\", ICON.search],\n [\"Library\", ICON.library],\n [\"Create\", ICON.plus],\n ] as const\n ).map(([label, d], i) => (\n <div\n key={label}\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n gap: 4,\n width: 80,\n }}\n >\n <Glyph\n d={d}\n size={24}\n color={i === 0 ? \"#fff\" : \"rgba(255,255,255,0.65)\"}\n fill={i === 0 ? \"#fff\" : \"none\"}\n />\n <span\n style={{\n fontSize: 10,\n color: i === 0 ? \"#fff\" : \"rgba(255,255,255,0.65)\",\n }}\n >\n {label}\n </span>\n </div>\n ))}\n </div>\n </div>\n );\n}\n\nconst ENTER = Easing.bezier(0.32, 0.72, 0, 1);\nconst EXIT = Easing.bezier(0.55, 0, 1, 0.45);\nconst HEAVY = { mass: 1, damping: 26, stiffness: 120 };\nconst CARD = { mass: 0.8, damping: 18, stiffness: 160 };\nconst CHIP = { mass: 0.5, damping: 12, stiffness: 200 };\nconst MORPH = { damping: 200 };\nconst GLIDE = { mass: 0.9, damping: 24, stiffness: 140 };\n\nexport function NowPlaying({\n title = \"Launch Day\",\n artist = \"remocn\",\n playlist = \"Launch Week Mix\",\n src,\n tint = \"#B8553A\",\n lyrics = DEFAULT_LYRICS,\n duration = 165,\n variant = \"full\",\n accent = \"#3B5BFD\",\n speed = 1,\n ground,\n groundParams,\n}: NowPlayingProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n const f = frame * speed;\n const mini = variant === \"mini\";\n const t = f - (mini ? MINI_OFFSET : 0);\n const portrait = height > width;\n const stageW = portrait ? 720 : 1280;\n const stageH = portrait ? 1280 : 720;\n const u = Math.min(width / stageW, height / stageH);\n const phoneH = portrait ? 800 : 668;\n const k = phoneH / BH;\n const phoneC = portrait ? { x: 360, y: 60 + phoneH / 2 } : { x: 392, y: 360 };\n const sp = (at: number, config: typeof CARD | typeof MORPH = CARD) =>\n spring({ frame: t - at, fps, config });\n\n const rise = spring({ frame: f, fps, config: HEAVY });\n const playing = sp(TAP_PLAY, MORPH);\n const elapsed = 24 + Math.max(0, t - TAP_PLAY) / 30;\n const progress = Math.min(1, elapsed / duration);\n const liked = sp(TAP_HEART, CHIP);\n const artScale = 0.94 + 0.06 * sp(TAP_PLAY, CARD);\n const heartPop =\n t < TAP_HEART\n ? 1\n : 1 +\n 0.3 *\n (1 - spring({ frame: t - TAP_HEART, fps, config: CHIP })) *\n Math.min(1, (t - TAP_HEART) / 2);\n\n const scroll = 430 * sp(LYRICS, { mass: 1, damping: 24, stiffness: 90 });\n const lineT = (t - LINE0) / LINE_LEN;\n const maxShift = Math.max(0, lyrics.length * 42 - 340);\n let listShift = 0;\n for (let i = 4; i < lyrics.length; i++) {\n listShift +=\n 42 * spring({ frame: t - (LINE0 + i * LINE_LEN), fps, config: MORPH });\n }\n listShift = Math.min(maxShift, listShift);\n\n const ex = mini ? spring({ frame: f - MINI_TAP - 2, fps, config: HEAVY }) : 1;\n const sheet = {\n top: lerp(MINI_Y, 0, ex),\n left: lerp(8, 0, ex),\n w: lerp(SW - 16, SW, ex),\n h: lerp(56, SH, ex),\n r: lerp(8, 55, ex),\n };\n const art = {\n x: lerp(MINI_ART.x, ART.x, ex),\n y: lerp(MINI_ART.y, ART.y, ex),\n s: lerp(MINI_ART.s, ART.s, ex),\n };\n const fullIn = interpolate(ex, [0.35, 0.85], [0, 1], {\n ...clamp,\n easing: ENTER,\n });\n\n const off = mini ? MINI_OFFSET : 0;\n const keys = mini\n ? [\n { at: 8, x: 300, y: 760 },\n { at: MINI_TAP - 14, x: 170, y: MINI_Y + 28 },\n { at: MINI_OFFSET - 4, x: 250, y: 760 },\n ]\n : [{ at: 4, x: 270, y: 770 }];\n keys.push(\n { at: TAP_PLAY - 16 + off, x: PLAY.x, y: PLAY.y },\n { at: TAP_HEART - 16 + off, x: HEART.x, y: HEART.y },\n );\n let tap = { x: keys[0].x, y: keys[0].y };\n for (let i = 1; i < keys.length; i++) {\n const b = keys[i];\n if (f < b.at) break;\n const e = spring({ frame: f - b.at, fps, config: GLIDE });\n const a = tap;\n const bow = Math.sin(Math.min(1, e) * Math.PI) * 0.16;\n tap = {\n x: lerp(a.x, b.x, e) - (b.y - a.y) * bow,\n y: lerp(a.y, b.y, e) + (b.x - a.x) * bow,\n };\n }\n const lastTap = TAP_HEART + off;\n const tapOpacity = interpolate(\n f,\n [keys[0].at, keys[0].at + 6, lastTap + 6, lastTap + 14],\n [0, 0.9, 0.9, 0],\n { ...clamp, easing: ENTER },\n );\n const click = (at: number) =>\n Math.max(\n 0,\n spring({ frame: f - at + 3, fps, config: CHIP }) -\n spring({ frame: f - at, fps, config: CHIP }),\n );\n const tapPress = Math.max(\n click(TAP_PLAY + off),\n click(TAP_HEART + off),\n mini ? click(MINI_TAP) : 0,\n );\n const playPress = click(TAP_PLAY + off);\n\n const bg = mix(tint, \"#000000\", 0.42);\n const card = mix(tint, \"#000000\", 0.12);\n const muted = \"rgba(255,255,255,0.7)\";\n\n const items = [\n { at: -999, text: title, sub: artist },\n ...lyrics.map((l, i) => ({ at: LINE0 + i * LINE_LEN, text: l, sub: \"\" })),\n ];\n let cur = 0;\n for (let i = 0; i < items.length; i++) if (t >= items[i].at) cur = i;\n const textX = portrait ? 64 : 724;\n const textW = portrait ? 592 : 500;\n const textTop = portrait ? 960 : 250;\n const bigSize = portrait ? 58 : 60;\n\n const resolvedGround: GshPresetId = ground ?? \"static-sunset\";\n\n const player = (\n <div\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n width: SW,\n height: SH + 440,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n background: `linear-gradient(${bg} 0px, ${mix(tint, \"#121212\", 0.78)} 620px, #121212 900px)`,\n }}\n />\n <div style={{ position: \"absolute\", inset: 0, opacity: fullIn }}>\n <div\n style={{\n position: \"absolute\",\n top: 62,\n left: 18,\n right: 18,\n display: \"flex\",\n alignItems: \"center\",\n color: \"#fff\",\n }}\n >\n <Glyph d={ICON.down} size={26} sw={1.8} />\n <div style={{ flex: 1, textAlign: \"center\" }}>\n <div style={{ fontSize: 12, color: muted }}>\n Playing from playlist\n </div>\n <div style={{ fontSize: 14, marginTop: 2 }}>{playlist}</div>\n </div>\n <Glyph d=\"M5 12h.01M12 12h.01M19 12h.01\" size={26} sw={3} />\n </div>\n <div\n style={{\n position: \"absolute\",\n top: 494,\n left: 24,\n right: 24,\n display: \"flex\",\n alignItems: \"center\",\n }}\n >\n <div style={{ flex: 1 }}>\n <div\n style={{ color: \"#fff\", fontSize: 25, letterSpacing: \"-0.02em\" }}\n >\n {title}\n </div>\n <div style={{ color: muted, fontSize: 17, marginTop: 4 }}>\n {artist}\n </div>\n </div>\n <div style={{ position: \"relative\", width: 28, height: 28 }}>\n <HeartBurst t={t - TAP_HEART} accent={accent} />\n <div style={{ transform: `scale(${heartPop})` }}>\n <Glyph\n d={ICON.heart}\n size={28}\n color={liked > 0.5 ? accent : \"rgba(255,255,255,0.85)\"}\n fill={liked > 0.5 ? accent : \"none\"}\n sw={liked > 0.5 ? 1.2 : 1.8}\n />\n </div>\n </div>\n </div>\n <div style={{ position: \"absolute\", top: 570, left: 24, right: 24 }}>\n <div\n style={{\n height: 4,\n borderRadius: 2,\n background: \"rgba(255,255,255,0.24)\",\n position: \"relative\",\n }}\n >\n <div\n style={{\n width: `${progress * 100}%`,\n height: 4,\n borderRadius: 2,\n background: \"#fff\",\n }}\n />\n <div\n style={{\n position: \"absolute\",\n left: `${progress * 100}%`,\n top: -4,\n width: 12,\n height: 12,\n marginLeft: -6,\n borderRadius: 6,\n background: \"#fff\",\n boxShadow: \"0 1px 4px rgba(0,0,0,0.3)\",\n }}\n />\n </div>\n <div\n style={{\n display: \"flex\",\n justifyContent: \"space-between\",\n marginTop: 9,\n fontSize: 12,\n color: muted,\n fontVariantNumeric: \"tabular-nums\",\n }}\n >\n <span>{fmt(elapsed)}</span>\n <span>−{fmt(duration - elapsed)}</span>\n </div>\n </div>\n <div\n style={{\n position: \"absolute\",\n top: PLAY.y - 33,\n left: 20,\n right: 20,\n height: 66,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n }}\n >\n <div style={{ position: \"relative\" }}>\n <Glyph d={ICON.shuffle} size={24} color={accent} sw={1.8} />\n <div\n style={{\n position: \"absolute\",\n left: 10,\n bottom: -8,\n width: 4,\n height: 4,\n borderRadius: 2,\n background: accent,\n }}\n />\n </div>\n <Glyph d={ICON.prev} size={34} fill=\"#fff\" sw={1.6} />\n <div\n style={{\n width: 66,\n height: 66,\n borderRadius: 33,\n background: \"#fff\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n transform: `scale(${1 - 0.06 * playPress})`,\n boxShadow: \"0 8px 20px -6px rgba(0,0,0,0.4)\",\n }}\n >\n <PlayPause m={Math.min(1, playing)} size={30} color=\"#000\" />\n </div>\n <Glyph d={ICON.next} size={34} fill=\"#fff\" sw={1.6} />\n <Glyph\n d={ICON.repeat}\n size={24}\n color=\"rgba(255,255,255,0.85)\"\n sw={1.8}\n />\n </div>\n <div\n style={{\n position: \"absolute\",\n top: 730,\n left: 24,\n right: 24,\n display: \"flex\",\n alignItems: \"center\",\n gap: 22,\n }}\n >\n <Glyph d={ICON.devices} size={20} color={muted} sw={1.8} />\n <div style={{ flex: 1 }} />\n <Glyph d={ICON.share} size={20} color={muted} sw={1.8} />\n <Glyph d={ICON.queue} size={20} color={muted} sw={1.8} />\n </div>\n <div\n style={{\n position: \"absolute\",\n top: 782,\n left: 12,\n right: 12,\n height: 452,\n borderRadius: 16,\n background: card,\n overflow: \"hidden\",\n padding: \"18px 18px 0\",\n boxSizing: \"border-box\",\n }}\n >\n <div style={{ display: \"flex\", alignItems: \"center\", color: \"#fff\" }}>\n <span style={{ flex: 1, fontSize: 17 }}>Lyrics</span>\n {[ICON.share, ICON.expand].map((d) => (\n <div\n key={d}\n style={{\n width: 32,\n height: 32,\n borderRadius: 16,\n marginLeft: 8,\n background: \"rgba(0,0,0,0.22)\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <Glyph d={d} size={15} sw={1.8} />\n </div>\n ))}\n </div>\n <div style={{ marginTop: 18, height: 352, overflow: \"hidden\" }}>\n <div\n style={{\n paddingTop: 4,\n transform: `translateY(${-listShift}px)`,\n }}\n >\n {lyrics.map((line, i) => {\n const on = interpolate(lineT, [i - 0.05, i + 0.2], [0, 1], {\n ...clamp,\n easing: ENTER,\n });\n const past = interpolate(lineT, [i + 1, i + 1.25], [0, 1], {\n ...clamp,\n easing: EXIT,\n });\n const v = Math.round(255 * on);\n return (\n <div\n key={`${i}-${line}`}\n style={{\n fontSize: 25,\n lineHeight: \"42px\",\n letterSpacing: \"-0.02em\",\n color: `rgba(${v}, ${v}, ${v}, ${lerp(0.5, 1, on) - 0.3 * past})`,\n }}\n >\n {line}\n </div>\n );\n })}\n </div>\n </div>\n </div>\n </div>\n {mini && ex < 0.5 ? (\n <div\n style={{\n position: \"absolute\",\n left: 56,\n right: 12,\n top: 0,\n height: 56,\n display: \"flex\",\n alignItems: \"center\",\n gap: 14,\n opacity: 1 - ex * 2.5,\n color: \"#fff\",\n }}\n >\n <div style={{ flex: 1 }}>\n <div style={{ fontSize: 14 }}>{title}</div>\n <div style={{ fontSize: 13, color: muted, marginTop: 1 }}>\n {artist}\n </div>\n </div>\n <Glyph d={ICON.devices} size={20} color={muted} sw={1.8} />\n <Glyph d={ICON.heart} size={22} color={muted} sw={1.8} />\n <PlayPause m={1} size={24} color=\"#fff\" />\n </div>\n ) : null}\n {mini && ex < 0.5 ? (\n <div\n style={{\n position: \"absolute\",\n left: 8,\n right: 8,\n top: 54,\n height: 2,\n borderRadius: 1,\n background: \"rgba(255,255,255,0.25)\",\n opacity: 1 - ex * 2.5,\n }}\n >\n <div style={{ width: \"15%\", height: 2, background: \"#fff\" }} />\n </div>\n ) : null}\n <div\n style={{\n position: \"absolute\",\n left: art.x,\n top: art.y,\n width: art.s,\n height: art.s,\n borderRadius: lerp(4, 8, ex),\n boxShadow: `0 ${24 * ex}px ${56 * ex}px rgba(0,0,0,0.45)`,\n transform: `scale(${lerp(1, artScale, ex)})`,\n }}\n >\n <Artwork\n size={art.s}\n tint={tint}\n src={src}\n radius={lerp(4, 8, ex)}\n title={title}\n artist={artist}\n />\n </div>\n </div>\n );\n\n return (\n <AbsoluteFill style={{ fontFamily, overflow: \"hidden\" }}>\n <GshGround\n preset={resolvedGround}\n params={groundParams}\n timeOffset={3}\n timeScale={0.35}\n />\n <AbsoluteFill\n style={{\n background: portrait\n ? \"linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,0.55) 100%)\"\n : \"linear-gradient(90deg, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0) 40%, rgba(0,0,0,0.45) 100%)\",\n }}\n />\n <div\n style={{\n position: \"absolute\",\n left: (width - stageW * u) / 2,\n top: (height - stageH * u) / 2,\n width: stageW,\n height: stageH,\n transform: `scale(${u})`,\n transformOrigin: \"0 0\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: phoneC.x - BW / 2,\n top: phoneC.y - BH / 2,\n width: BW,\n height: BH,\n transform: `translateY(${(1 - rise) * stageH * 0.7}px) scale(${k * (1 + 0.015 * (f / 300))})`,\n }}\n >\n <Phone>\n {mini ? <MiniHome tint={tint} artist={artist} /> : null}\n <div\n style={{\n position: \"absolute\",\n left: sheet.left,\n top: sheet.top,\n width: sheet.w,\n height: sheet.h,\n borderRadius: sheet.r,\n overflow: \"hidden\",\n background: bg,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n transform: `translateY(${-scroll}px)`,\n }}\n >\n {player}\n </div>\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: 0,\n height: 96,\n background: `linear-gradient(${mix(tint, \"#121212\", 0.72)} 58%, transparent)`,\n opacity: interpolate(scroll, [200, 380], [0, 1], clamp),\n }}\n />\n </div>\n <StatusBar />\n <div\n style={{\n position: \"absolute\",\n left: tap.x - 22,\n top: tap.y - 22,\n width: 44,\n height: 44,\n borderRadius: 22,\n background: \"rgba(255,255,255,0.3)\",\n boxShadow: \"inset 0 0 0 1.5px rgba(255,255,255,0.7)\",\n opacity: tapOpacity,\n transform: `scale(${1 - 0.2 * tapPress})`,\n zIndex: 35,\n }}\n />\n </Phone>\n </div>\n\n <div\n style={{\n position: \"absolute\",\n left: textX,\n top: textTop,\n width: textW,\n color: \"#fff\",\n opacity: interpolate(f, [10, 24], [0, 1], {\n ...clamp,\n easing: ENTER,\n }),\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 10,\n fontSize: 18,\n color: \"rgba(255,255,255,0.62)\",\n }}\n >\n <span\n style={{\n width: 8,\n height: 8,\n borderRadius: 4,\n background: accent,\n transform: `scale(${Math.min(1, playing)})`,\n }}\n />\n {t < TAP_PLAY ? \"Paused\" : \"Now playing\"} · {playlist}\n </div>\n <div\n style={{\n position: \"relative\",\n height: bigSize * 1.08 * 2 + 60,\n marginTop: 22,\n overflow: \"hidden\",\n }}\n >\n {[cur - 1, cur].map((idx) => {\n if (idx < 0) return null;\n const it = items[idx];\n const isCur = idx === cur;\n const inP = isCur\n ? idx === 0\n ? 1\n : interpolate(t, [it.at + 4, it.at + 15], [0, 1], {\n ...clamp,\n easing: ENTER,\n })\n : 1;\n const outP = isCur\n ? 0\n : interpolate(t, [items[cur].at, items[cur].at + 6], [0, 1], {\n ...clamp,\n easing: EXIT,\n });\n if (outP >= 1) return null;\n return (\n <div\n key={idx}\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n width: textW,\n opacity: inP * (1 - outP),\n transform: `translateY(${(1 - inP) * bigSize * 1.6 - outP * bigSize * 1.2}px)`,\n }}\n >\n <div\n style={{\n fontSize: bigSize,\n fontWeight: 300,\n lineHeight: 1.08,\n letterSpacing: \"-0.035em\",\n textWrap: \"balance\",\n }}\n >\n {it.text}\n </div>\n {it.sub ? (\n <div\n style={{\n fontSize: 26,\n fontWeight: 300,\n marginTop: 14,\n color: \"rgba(255,255,255,0.62)\",\n }}\n >\n {it.sub}\n </div>\n ) : null}\n </div>\n );\n })}\n </div>\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 14,\n fontSize: 18,\n color: \"rgba(255,255,255,0.62)\",\n fontVariantNumeric: \"tabular-nums\",\n }}\n >\n <span>{fmt(elapsed)}</span>\n <div\n style={{\n flex: 1,\n height: 2,\n borderRadius: 1,\n background: \"rgba(255,255,255,0.18)\",\n }}\n >\n <div\n style={{\n width: `${progress * 100}%`,\n height: 2,\n borderRadius: 1,\n background: \"#fff\",\n }}\n />\n </div>\n <span>{fmt(duration)}</span>\n </div>\n </div>\n </div>\n </AbsoluteFill>\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/now-playing.tsx"
}
],
"type": "registry:component"
}