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": "cart-add",
"title": "Cart Add",
"description": "A shop page picks a color and size, then a cart drawer slides in with Checkout.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"registryDependencies": ["@remocn/gsh"],
"files": [
{
"path": "registry/remocn/cart-add/index.tsx",
"content": "\"use client\";\n\nimport { loadFont as loadSans } from \"@remotion/google-fonts/InstrumentSans\";\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/InstrumentSerif\";\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 sans = loadSans(\"normal\", { weights: [\"400\"], subsets: [\"latin\"] });\nconst serif = loadSerif(\"normal\", { weights: [\"400\"], subsets: [\"latin\"] });\n\nexport interface CartColor {\n name: string;\n swatch: string;\n}\n\nexport interface CartSize {\n label: string;\n price: number;\n}\n\nexport interface CartAddProps {\n brand?: string;\n url?: string;\n product?: string;\n category?: string;\n description?: string;\n rating?: number;\n reviews?: string;\n colors?: CartColor[];\n sizes?: CartSize[];\n startColor?: number;\n pickColor?: number;\n startSize?: number;\n pickSize?: number;\n images?: string[];\n currency?: string;\n freeShippingAt?: number;\n theme?: \"light\" | \"dark\";\n accent?: string;\n speed?: number;\n ground?: GshPresetId;\n groundParams?: Partial<GradientParams>;\n}\n\nconst DEFAULT_COLORS: CartColor[] = [\n { name: \"Sage\", swatch: \"#8E9B82\" },\n { name: \"Clay\", swatch: \"#C07A5E\" },\n { name: \"Ink\", swatch: \"#2E3644\" },\n { name: \"Sand\", swatch: \"#D6C6AA\" },\n];\nconst DEFAULT_SIZES: CartSize[] = [\n { label: \"18 oz\", price: 36 },\n { label: \"24 oz\", price: 42 },\n { label: \"32 oz\", price: 48 },\n];\n\nconst ENTER = Easing.bezier(0.32, 0.72, 0, 1);\nconst SOFT = Easing.bezier(0.22, 1, 0.36, 1);\nconst MOVE = Easing.bezier(0.65, 0, 0.35, 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 };\nconst CL = { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" } as const;\n\nconst B = {\n win: 0,\n cursor: 6,\n swatch: 34,\n toSize: 40,\n size: 60,\n toBtn: 66,\n add: 84,\n fly: 92,\n land: 114,\n drawer: 120,\n toCheckout: 142,\n checkout: 166,\n};\n\nconst lerp = (a: number, b: number, t: number) => a + (b - a) * t;\nconst clamp01 = (v: number) => Math.min(1, Math.max(0, v));\nconst tw = (f: number, a: number, b: number, e = ENTER) =>\n interpolate(f, [a, b], [0, 1], { ...CL, easing: e });\n\nfunction rgb(hex: string): [number, number, number] {\n const h = hex.replace(\"#\", \"\");\n const full = h.length === 3 ? h.replace(/./g, (c) => c + c) : 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 return `#${x\n .map((v, i) =>\n Math.round(lerp(v, y[i], t))\n .toString(16)\n .padStart(2, \"0\"),\n )\n .join(\"\")}`;\n}\nconst money = (n: number, cur: string, cents = false) =>\n `${cur}${n.toLocaleString(\"en-US\", {\n minimumFractionDigits: cents ? 2 : 0,\n maximumFractionDigits: cents ? 2 : 0,\n })}`;\n\nconst LIGHT = {\n dark: false,\n win: \"#FFFFFF\",\n text: \"#1D1D1F\",\n muted: \"#6E6E73\",\n faint: \"#A1A1A6\",\n line: \"rgba(0,0,0,0.08)\",\n ring: \"rgba(0,0,0,0.12)\",\n fill: \"#F5F5F7\",\n btn: \"#1D1D1F\",\n btnText: \"#FFFFFF\",\n shadow:\n \"0 0 0 1px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04), 0 32px 80px -24px rgba(60,30,10,0.3)\",\n outline: \"rgba(0,0,0,0.1)\",\n};\nconst DARK: typeof LIGHT = {\n dark: true,\n win: \"#161617\",\n text: \"#F5F5F7\",\n muted: \"#A1A1A6\",\n faint: \"#6E6E73\",\n line: \"rgba(255,255,255,0.09)\",\n ring: \"rgba(255,255,255,0.14)\",\n fill: \"#1F1F21\",\n btn: \"#F5F5F7\",\n btnText: \"#161617\",\n shadow:\n \"0 0 0 1px rgba(255,255,255,0.08), inset 0 1px 0 rgba(255,255,255,0.06), 0 48px 120px -24px rgba(0,0,0,0.85)\",\n outline: \"rgba(255,255,255,0.1)\",\n};\ntype Pal = typeof LIGHT;\n\nconst ICONS = {\n bag: \"M3.4 5.25h9.2l-.65 8.25H4.05zM5.75 5.25v-.75a2.25 2.25 0 0 1 4.5 0v.75\",\n plus: \"M8 3.5v9M3.5 8h9\",\n minus: \"M3.5 8h9\",\n x: \"M4.25 4.25l7.5 7.5M11.75 4.25l-7.5 7.5\",\n lock: \"M4.25 7.25h7.5v6h-7.5zM5.75 7.25V5.5a2.25 2.25 0 0 1 4.5 0v1.75\",\n check: \"M3.5 8.5l3 3 6-6.5\",\n star: \"M8 1.6l1.9 4 4.3.5-3.2 3 .9 4.3L8 11.3l-3.9 2.1.9-4.3-3.2-3 4.3-.5z\",\n} as const;\n\nfunction Icon({\n name,\n color,\n size = 16,\n}: {\n name: keyof typeof ICONS;\n color: string;\n size?: number;\n}) {\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 16 16\"\n style={{ display: \"block\", flexShrink: 0 }}\n >\n <path\n d={ICONS[name]}\n fill=\"none\"\n stroke={color}\n strokeWidth={1.3}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\nfunction Cursor({ x, y, press }: { x: number; y: number; press: number }) {\n return (\n <svg\n width={26}\n height={30}\n viewBox=\"0 0 20 24\"\n style={{\n position: \"absolute\",\n left: x - 2,\n top: y - 2,\n transformOrigin: \"2px 2px\",\n transform: `scale(${1 - 0.04 * press})`,\n filter:\n \"drop-shadow(0 1px 1px rgba(0,0,0,0.25)) drop-shadow(0 6px 10px rgba(0,0,0,0.2))\",\n overflow: \"visible\",\n zIndex: 20,\n }}\n >\n <path\n d=\"M2 2 L2 19.5 L6.6 15.4 L9.8 22.4 L12.9 21 L9.8 14.2 L16 14.2 Z\"\n fill=\"#FFFFFF\"\n stroke=\"#1D1D1F\"\n strokeWidth={1.1}\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\nfunction Bottle({ swatch, brand }: { swatch: string; brand: string }) {\n const id = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n const cap = mix(swatch, \"#1A1A1A\", 0.38);\n return (\n <g>\n <defs>\n <linearGradient id={`${id}b`} x1=\"0\" x2=\"1\" y1=\"0\" y2=\"0\">\n <stop offset=\"0\" stopColor={mix(swatch, \"#000000\", 0.3)} />\n <stop offset=\"0.14\" stopColor={swatch} />\n <stop offset=\"0.3\" stopColor={mix(swatch, \"#FFFFFF\", 0.22)} />\n <stop offset=\"0.48\" stopColor={swatch} />\n <stop offset=\"0.82\" stopColor={mix(swatch, \"#000000\", 0.14)} />\n <stop offset=\"1\" stopColor={mix(swatch, \"#000000\", 0.36)} />\n </linearGradient>\n <linearGradient id={`${id}v`} x1=\"0\" x2=\"0\" y1=\"0\" y2=\"1\">\n <stop offset=\"0\" stopColor=\"#FFFFFF\" stopOpacity={0.12} />\n <stop offset=\"0.12\" stopColor=\"#FFFFFF\" stopOpacity={0} />\n <stop offset=\"0.85\" stopColor=\"#000000\" stopOpacity={0} />\n <stop offset=\"1\" stopColor=\"#000000\" stopOpacity={0.14} />\n </linearGradient>\n <linearGradient id={`${id}c`} x1=\"0\" x2=\"1\" y1=\"0\" y2=\"0\">\n <stop offset=\"0\" stopColor={mix(cap, \"#000000\", 0.2)} />\n <stop offset=\"0.28\" stopColor={mix(cap, \"#FFFFFF\", 0.14)} />\n <stop offset=\"0.62\" stopColor={cap} />\n <stop offset=\"1\" stopColor={mix(cap, \"#000000\", 0.28)} />\n </linearGradient>\n <linearGradient id={`${id}s`} x1=\"0\" x2=\"1\" y1=\"0\" y2=\"0\">\n <stop offset=\"0\" stopColor=\"#8E9399\" />\n <stop offset=\"0.3\" stopColor=\"#F2F3F4\" />\n <stop offset=\"0.65\" stopColor=\"#C4C8CC\" />\n <stop offset=\"1\" stopColor=\"#7E838A\" />\n </linearGradient>\n <filter id={`${id}f`} x=\"-50%\" y=\"-200%\" width=\"200%\" height=\"500%\">\n <feGaussianBlur stdDeviation=\"7\" />\n </filter>\n <filter id={`${id}h`}>\n <feGaussianBlur stdDeviation=\"2.5\" />\n </filter>\n </defs>\n <ellipse\n cx={276}\n cy={434}\n rx={96}\n ry={11}\n fill=\"rgba(0,0,0,0.22)\"\n filter={`url(#${id}f)`}\n />\n <path\n d=\"M256 76 C256 40 296 40 296 76\"\n fill=\"none\"\n stroke={cap}\n strokeWidth={9}\n strokeLinecap=\"round\"\n />\n <rect\n x={232}\n y={72}\n width={88}\n height={50}\n rx={9}\n fill={`url(#${id}c)`}\n />\n <rect x={228} y={120} width={96} height={12} fill={`url(#${id}s)`} />\n <path\n d=\"M228 132 L324 132 C332 142 346 150 346 174 L346 412 Q346 432 326 432 L226 432 Q206 432 206 412 L206 174 C206 150 220 142 228 132 Z\"\n fill={`url(#${id}b)`}\n />\n <path\n d=\"M228 132 L324 132 C332 142 346 150 346 174 L346 412 Q346 432 326 432 L226 432 Q206 432 206 412 L206 174 C206 150 220 142 228 132 Z\"\n fill={`url(#${id}v)`}\n />\n <rect\n x={232}\n y={176}\n width={9}\n height={232}\n rx={4.5}\n fill=\"#FFFFFF\"\n opacity={0.2}\n filter={`url(#${id}h)`}\n />\n <text\n x={276}\n y={226}\n textAnchor=\"middle\"\n fontSize={14}\n fontWeight={400}\n fill=\"#FFFFFF\"\n opacity={0.55}\n style={{ fontFamily: serif.fontFamily }}\n >\n {brand}\n </text>\n </g>\n );\n}\n\nfunction Photo({\n swatch,\n pal,\n src,\n brand,\n}: {\n swatch: string;\n pal: Pal;\n src?: string;\n brand: string;\n}) {\n const gid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n if (src) {\n return (\n <Img\n src={src}\n style={{ width: \"100%\", height: \"100%\", objectFit: \"cover\" }}\n />\n );\n }\n const backdrop = mix(\n swatch,\n pal.dark ? \"#1C1C1E\" : \"#F3F1ED\",\n pal.dark ? 0.84 : 0.82,\n );\n const floor = mix(\n swatch,\n pal.dark ? \"#141416\" : \"#E6E2DB\",\n pal.dark ? 0.86 : 0.8,\n );\n return (\n <svg\n viewBox=\"0 0 552 480\"\n preserveAspectRatio=\"xMidYMid slice\"\n style={{ width: \"100%\", height: \"100%\", display: \"block\" }}\n >\n <defs>\n <linearGradient id={`${gid}g`} x1=\"0\" x2=\"0\" y1=\"0\" y2=\"1\">\n <stop offset=\"0\" stopColor={backdrop} />\n <stop offset=\"0.68\" stopColor={backdrop} />\n <stop offset=\"0.8\" stopColor={floor} />\n <stop offset=\"1\" stopColor={floor} />\n </linearGradient>\n <radialGradient id={`${gid}r`} cx=\"0.5\" cy=\"0.38\" r=\"0.55\">\n <stop\n offset=\"0\"\n stopColor=\"#FFFFFF\"\n stopOpacity={pal.dark ? 0.07 : 0.45}\n />\n <stop offset=\"1\" stopColor=\"#FFFFFF\" stopOpacity={0} />\n </radialGradient>\n </defs>\n <rect width={552} height={480} fill={`url(#${gid}g)`} />\n <rect width={552} height={480} fill={`url(#${gid}r)`} />\n <Bottle swatch={swatch} brand={brand} />\n </svg>\n );\n}\n\nfunction layoutFor(portrait: boolean) {\n if (portrait) {\n const win = { x: 32, y: 56, w: 656, h: 1168 };\n return {\n stageW: 720,\n stageH: 1280,\n win,\n navH: 80,\n photo: { x: 24, y: 80, w: 608, h: 500 },\n box: { x: 40, y: 612, w: 576 },\n nameSize: 54,\n drawer: { x: 24, y: 1280 - 24 - 500, w: 672, h: 500 },\n drawerFrom: { x: 0, y: 620 },\n winShift: { x: 0, y: -60, s: 0.94 },\n };\n }\n const win = { x: 64, y: 44, w: 1152, h: 632 };\n return {\n stageW: 1280,\n stageH: 720,\n win,\n navH: 72,\n photo: { x: 24, y: 72, w: 540, h: 536 },\n box: { x: 612, y: 92, w: 500 },\n nameSize: 56,\n drawer: { x: 820, y: 100, w: 420, h: 520 },\n drawerFrom: { x: 500, y: 0 },\n winShift: { x: -120, y: 0, s: 0.96 },\n };\n}\n\nexport function CartAdd({\n brand = \"fernway\",\n product = \"Summit Bottle\",\n category = \"Drinkware\",\n description = \"Double-wall steel keeps drinks cold for 24 hours. Leak-proof cap, powder-coat finish that never sweats.\",\n rating = 4.8,\n reviews = \"2,184\",\n colors = DEFAULT_COLORS,\n sizes = DEFAULT_SIZES,\n startColor = 0,\n pickColor = 1,\n startSize = 1,\n pickSize = 2,\n images,\n currency = \"$\",\n freeShippingAt = 75,\n theme = \"light\",\n accent = \"#3B5BFD\",\n speed = 1,\n ground,\n groundParams,\n}: CartAddProps) {\n const frame = useCurrentFrame() * speed;\n const { width: W, height: H, fps } = useVideoConfig();\n const portrait = H > W;\n const L = layoutFor(portrait);\n const u = Math.min(W / L.stageW, H / L.stageH);\n const pal = theme === \"dark\" ? DARK : LIGHT;\n const sp = (at: number, config: typeof CARD | typeof MORPH = CARD) =>\n spring({ frame: frame - at, fps, config });\n\n const c0 = colors[startColor] ?? colors[0];\n const c1 = colors[pickColor] ?? c0;\n const s0 = sizes[startSize] ?? sizes[0];\n const s1 = sizes[pickSize] ?? s0;\n const img0 = images?.[colors.indexOf(c0)];\n const img1 = images?.[colors.indexOf(c1)];\n\n const box = L.box;\n const descLines = 2;\n const y = {\n cat: box.y,\n name: box.y + 30,\n price: box.y + 30 + L.nameSize + 16,\n desc: box.y + 30 + L.nameSize + 64,\n };\n const colorY = y.desc + descLines * 26 + 30;\n const swY = colorY + 30;\n const sizeY = swY + 66;\n const chipY = sizeY + 30;\n const btnY = chipY + 84;\n const chipGap = 12;\n const chipW = (box.w - chipGap * 2) / 3;\n\n const winAbs = (p: { x: number; y: number }) => ({\n x: L.win.x + p.x,\n y: L.win.y + p.y,\n });\n const swatchPt = (i: number) =>\n winAbs({ x: box.x + 20 + i * 56, y: swY + 22 });\n const chipPt = (j: number) =>\n winAbs({ x: box.x + j * (chipW + chipGap) + chipW * 0.62, y: chipY + 36 });\n const btnPt = winAbs({ x: box.x + box.w * 0.6, y: btnY + 36 });\n const bagPt = winAbs({ x: L.win.w - 52, y: L.navH / 2 });\n\n const drawerIn = sp(B.drawer, HEAVY);\n const shift = sp(B.drawer, MORPH);\n const winX = L.winShift.x * shift;\n const winY = L.winShift.y * shift;\n const winS = lerp(1, L.winShift.s, shift);\n const D = L.drawer;\n const dX = D.x + L.drawerFrom.x * (1 - drawerIn);\n const dY = D.y + L.drawerFrom.y * (1 - drawerIn);\n const checkoutPt = { x: D.x + D.w * 0.62, y: D.y + D.h - 28 - 32 + 6 };\n\n const arc = (\n a: { x: number; y: number },\n b: { x: number; y: number },\n p: number,\n bend: number,\n ) => {\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n const d = Math.hypot(dx, dy) || 1;\n const k = Math.sin(clamp01(p) * Math.PI) * Math.min(bend, d * 0.16);\n return {\n x: lerp(a.x, b.x, p) - (dy / d) * k,\n y: lerp(a.y, b.y, p) + (dx / d) * k,\n };\n };\n const winToScreen = (p: { x: number; y: number }) => ({\n x: L.stageW / 2 + (p.x - L.stageW / 2) * winS + winX,\n y: L.stageH / 2 + (p.y - L.stageH / 2) * winS + winY,\n });\n const segs: { at: number; to: { x: number; y: number } }[] = [\n { at: B.cursor, to: swatchPt(pickColor) },\n { at: B.toSize, to: chipPt(pickSize) },\n { at: B.toBtn, to: btnPt },\n { at: B.toCheckout, to: checkoutPt },\n ];\n let cur = { x: L.stageW * 0.82, y: L.stageH * 1.04 };\n for (const sg of segs) {\n if (frame < sg.at) break;\n const to =\n sg.at === B.toBtn && frame > B.drawer ? winToScreen(btnPt) : sg.to;\n cur = arc(\n cur,\n to,\n spring({ frame: frame - sg.at, fps, config: GLIDE }),\n 60,\n );\n }\n const click = (at: number) =>\n spring({ frame: frame - at + 3, fps, config: CHIP }) -\n spring({ frame: frame - at, fps, config: CHIP });\n const press = Math.max(0, click(B.swatch), click(B.size), click(B.add));\n const cursorO = tw(frame, B.cursor, B.cursor + 8);\n\n const winIn = sp(B.win, HEAVY);\n const winO = tw(frame, B.win, B.win + 12);\n const colorP = tw(frame, B.swatch + 1, B.swatch + 14, MOVE);\n const ring = sp(B.swatch + 1, MORPH);\n const sizeSel = sp(B.size + 1, MORPH);\n const priceP = tw(frame, B.size + 2, B.size + 12, SOFT);\n const btnPress = click(B.add);\n const loadP = tw(frame, B.add + 2, B.add + 8);\n const doneP = tw(frame, B.land - 6, B.land + 2, SOFT);\n const checkDraw = tw(frame, B.land - 4, B.land + 6, SOFT);\n\n const flyP = sp(B.fly, { mass: 0.9, damping: 22, stiffness: 120 });\n const flyO =\n tw(frame, B.fly, B.fly + 4) * (1 - tw(frame, B.land - 3, B.land + 1, EXIT));\n const fromPt = winAbs({\n x: L.photo.x + L.photo.w / 2,\n y: L.photo.y + L.photo.h / 2,\n });\n const ctrl = {\n x: lerp(fromPt.x, bagPt.x, 0.6),\n y: Math.min(fromPt.y, bagPt.y) - 140,\n };\n const q = (a: number, c: number, b: number, t: number) =>\n (1 - t) * (1 - t) * a + 2 * (1 - t) * t * c + t * t * b;\n const fly = {\n x: q(fromPt.x, ctrl.x, bagPt.x, clamp01(flyP)),\n y: q(fromPt.y, ctrl.y, bagPt.y, clamp01(flyP)),\n s: lerp(1, 0.16, clamp01(flyP)),\n };\n const bump = 1 + 0.16 * Math.max(0, click(B.land + 2));\n const badge = sp(B.land, CHIP);\n\n const item = (k: number) =>\n tw(frame, B.drawer + 6 + k * 3, B.drawer + 18 + k * 3);\n const shipFill = tw(frame, B.drawer + 16, B.drawer + 40, MOVE);\n const checkoutHover = tw(frame, B.checkout - 6, B.checkout, SOFT);\n const remaining = Math.max(0, freeShippingAt - s1.price);\n const shipRatio = Math.min(1, s1.price / freeShippingAt);\n\n const resolvedGround: GshPresetId =\n ground ?? (pal.dark ? \"ember\" : \"paper-crease\");\n const resolvedParams =\n groundParams ??\n (pal.dark\n ? { grain: 0.06 }\n : {\n kind: \"mist\" as const,\n colors: [\"#e9b79c\", \"#f4dfd0\", \"#f7f2eb\", \"#cf8d6c\"],\n background: \"#f4efe8\",\n });\n\n const swap = (\n a: React.ReactNode,\n b: React.ReactNode,\n p: number,\n lift = 10,\n ) => (\n <span style={{ position: \"relative\", display: \"inline-grid\" }}>\n <span\n style={{\n gridArea: \"1/1\",\n opacity: 1 - clamp01(p * 2),\n transform: `translateY(${-p * lift}px)`,\n }}\n >\n {a}\n </span>\n <span\n style={{\n gridArea: \"1/1\",\n opacity: clamp01(p * 2 - 1),\n transform: `translateY(${(1 - p) * lift}px)`,\n }}\n >\n {b}\n </span>\n </span>\n );\n\n const label16: React.CSSProperties = { fontSize: 16, color: pal.muted };\n\n return (\n <AbsoluteFill style={{ fontFamily: sans.fontFamily, overflow: \"hidden\" }}>\n <GshGround\n preset={resolvedGround}\n params={resolvedParams}\n timeOffset={4}\n timeScale={0.4}\n />\n <div\n style={{\n position: \"absolute\",\n left: (W - L.stageW * u) / 2,\n top: (H - L.stageH * u) / 2,\n width: L.stageW,\n height: L.stageH,\n transformOrigin: \"0 0\",\n transform: `scale(${u})`,\n WebkitFontSmoothing: \"antialiased\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n transformOrigin: \"50% 50%\",\n transform: `translate(${winX}px, ${winY}px) scale(${winS * (1 + 0.015 * (frame / 200))})`,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: L.win.x,\n top: L.win.y,\n width: L.win.w,\n height: L.win.h,\n borderRadius: 28,\n overflow: \"hidden\",\n background: pal.win,\n color: pal.text,\n boxShadow: pal.shadow,\n opacity: winO,\n transform: `translateY(${(1 - winIn) * 56}px) scale(${0.96 + 0.04 * winIn})`,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: 36,\n right: 36,\n top: 0,\n height: L.navH,\n display: \"flex\",\n alignItems: \"center\",\n }}\n >\n <span\n style={{\n fontFamily: serif.fontFamily,\n fontSize: 30,\n letterSpacing: \"-0.01em\",\n }}\n >\n {brand}\n </span>\n <div style={{ flex: 1 }} />\n <div\n style={{ position: \"relative\", transform: `scale(${bump})` }}\n >\n <Icon name=\"bag\" color={pal.text} size={26} />\n {frame >= B.land ? (\n <div\n style={{\n position: \"absolute\",\n right: -10,\n top: -8,\n minWidth: 20,\n height: 20,\n borderRadius: 10,\n background: accent,\n color: \"#fff\",\n fontSize: 13,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n fontVariantNumeric: \"tabular-nums\",\n boxShadow: `0 0 0 2px ${pal.win}`,\n transform: `scale(${Math.max(0, badge)})`,\n }}\n >\n 1\n </div>\n ) : null}\n </div>\n </div>\n\n <div\n style={{\n position: \"absolute\",\n left: L.photo.x,\n top: L.photo.y,\n width: L.photo.w,\n height: L.photo.h,\n borderRadius: 18,\n overflow: \"hidden\",\n outline: `1px solid ${pal.outline}`,\n outlineOffset: -1,\n }}\n >\n <div style={{ position: \"absolute\", inset: 0 }}>\n <Photo swatch={c0.swatch} pal={pal} src={img0} brand={brand} />\n </div>\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n opacity: colorP,\n transform: `scale(${1.03 - 0.03 * colorP})`,\n }}\n >\n <Photo swatch={c1.swatch} pal={pal} src={img1} brand={brand} />\n </div>\n </div>\n\n <div\n style={{\n position: \"absolute\",\n left: box.x,\n top: y.cat,\n width: box.w,\n }}\n >\n <div style={label16}>{category}</div>\n <div\n style={{\n fontFamily: serif.fontFamily,\n fontSize: L.nameSize,\n lineHeight: 1,\n letterSpacing: \"-0.015em\",\n marginTop: 12,\n }}\n >\n {product}\n </div>\n <div\n style={{\n display: \"flex\",\n alignItems: \"baseline\",\n gap: 14,\n marginTop: 18,\n }}\n >\n <span\n style={{ fontSize: 24, fontVariantNumeric: \"tabular-nums\" }}\n >\n {swap(\n money(s0.price, currency),\n money(s1.price, currency),\n priceP,\n )}\n </span>\n <span\n style={{\n ...label16,\n display: \"flex\",\n alignItems: \"center\",\n gap: 6,\n fontVariantNumeric: \"tabular-nums\",\n }}\n >\n <svg width={14} height={14} viewBox=\"0 0 16 16\">\n <path d={ICONS.star} fill={pal.text} />\n </svg>\n {rating.toFixed(1)} · {reviews} reviews\n </span>\n </div>\n <div\n style={{\n fontSize: 17,\n lineHeight: \"26px\",\n color: pal.muted,\n marginTop: 16,\n textWrap: \"pretty\",\n height: descLines * 26,\n overflow: \"hidden\",\n }}\n >\n {description}\n </div>\n </div>\n\n <div\n style={{\n position: \"absolute\",\n left: box.x,\n top: colorY,\n fontSize: 16,\n color: pal.text,\n }}\n >\n Color{\" \"}\n <span style={{ color: pal.muted }}>\n · {swap(c0.name, c1.name, colorP, 8)}\n </span>\n </div>\n {colors.map((c, i) => {\n const sel =\n i === startColor ? 1 - ring : i === pickColor ? ring : 0;\n return (\n <div\n key={c.name}\n style={{\n position: \"absolute\",\n left: box.x + i * 56,\n top: swY,\n width: 44,\n height: 44,\n borderRadius: 22,\n boxShadow: `inset 0 0 0 ${1.5 * Math.max(0, sel)}px ${pal.text}`,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 5,\n borderRadius: 17,\n background: c.swatch,\n boxShadow: `inset 0 0 0 1px ${pal.outline}`,\n }}\n />\n </div>\n );\n })}\n\n <div\n style={{\n position: \"absolute\",\n left: box.x,\n top: sizeY,\n width: box.w,\n display: \"flex\",\n fontSize: 16,\n color: pal.text,\n }}\n >\n Size\n <span\n style={{\n marginLeft: \"auto\",\n color: pal.muted,\n textDecoration: \"underline\",\n textUnderlineOffset: 4,\n textDecorationColor: pal.ring,\n }}\n >\n Size guide\n </span>\n </div>\n {sizes.slice(0, 3).map((sz, j) => {\n const sel =\n j === startSize ? 1 - sizeSel : j === pickSize ? sizeSel : 0;\n return (\n <div\n key={sz.label}\n style={{\n position: \"absolute\",\n left: box.x + j * (chipW + chipGap),\n top: chipY,\n width: chipW,\n height: 64,\n borderRadius: 14,\n boxShadow: `inset 0 0 0 1px ${pal.ring}, inset 0 0 0 ${1.5 * Math.max(0, sel)}px ${pal.text}`,\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: 2,\n }}\n >\n <span style={{ fontSize: 18 }}>{sz.label}</span>\n <span\n style={{\n fontSize: 16,\n color: pal.faint,\n fontVariantNumeric: \"tabular-nums\",\n }}\n >\n {money(sz.price, currency)}\n </span>\n </div>\n );\n })}\n\n <div\n style={{\n position: \"absolute\",\n left: box.x,\n top: btnY,\n width: box.w,\n height: 64,\n borderRadius: 32,\n background: pal.btn,\n color: pal.btnText,\n transform: `scale(${1 - 0.04 * Math.max(0, btnPress)})`,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n fontSize: 18,\n boxShadow: pal.dark\n ? \"none\"\n : \"0 1px 2px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.12)\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n opacity: 1 - loadP,\n transform: `translateY(${-loadP * 8}px)`,\n display: \"flex\",\n gap: 8,\n }}\n >\n Add to bag\n <span style={{ opacity: 0.5 }}>·</span>\n <span style={{ fontVariantNumeric: \"tabular-nums\" }}>\n {swap(\n money(s0.price, currency),\n money(s1.price, currency),\n priceP,\n 8,\n )}\n </span>\n </div>\n <svg\n width={20}\n height={20}\n viewBox=\"0 0 18 18\"\n style={{\n position: \"absolute\",\n opacity: loadP * (1 - doneP),\n transform: `rotate(${frame * 20}deg)`,\n }}\n >\n <circle\n cx={9}\n cy={9}\n r={7}\n fill=\"none\"\n stroke={pal.btnText}\n strokeOpacity={0.25}\n strokeWidth={1.6}\n />\n <path\n d=\"M9 2a7 7 0 0 1 7 7\"\n fill=\"none\"\n stroke={pal.btnText}\n strokeWidth={1.6}\n strokeLinecap=\"round\"\n />\n </svg>\n <div\n style={{\n position: \"absolute\",\n display: \"flex\",\n alignItems: \"center\",\n gap: 10,\n opacity: doneP,\n transform: `translateY(${(1 - doneP) * 8}px)`,\n }}\n >\n <svg width={18} height={18} viewBox=\"0 0 16 16\">\n <path\n d={ICONS.check}\n fill=\"none\"\n stroke={pal.btnText}\n strokeWidth={1.6}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n pathLength={1}\n strokeDasharray={1}\n strokeDashoffset={1 - checkDraw}\n />\n </svg>\n Added to bag\n </div>\n </div>\n\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n background: pal.dark ? \"#000\" : \"#2a1a10\",\n opacity: (pal.dark ? 0.3 : 0.1) * shift,\n }}\n />\n </div>\n\n {frame >= B.fly && frame < B.land + 2 ? (\n <div\n style={{\n position: \"absolute\",\n left: fly.x - 90,\n top: fly.y - 90,\n width: 180,\n height: 180,\n borderRadius: 20,\n overflow: \"hidden\",\n opacity: flyO,\n transform: `scale(${fly.s})`,\n boxShadow:\n \"0 18px 40px -10px rgba(0,0,0,0.4), 0 0 0 1px rgba(0,0,0,0.06)\",\n }}\n >\n <Photo swatch={c1.swatch} pal={pal} src={img1} brand={brand} />\n </div>\n ) : null}\n </div>\n\n {frame >= B.drawer ? (\n <div\n style={{\n position: \"absolute\",\n left: dX,\n top: dY,\n width: D.w,\n height: D.h,\n borderRadius: 28,\n background: pal.win,\n color: pal.text,\n boxShadow: pal.shadow,\n padding: 28,\n boxSizing: \"border-box\",\n display: \"flex\",\n flexDirection: \"column\",\n }}\n >\n <div style={{ display: \"flex\", alignItems: \"center\" }}>\n <span\n style={{\n fontFamily: serif.fontFamily,\n fontSize: 34,\n letterSpacing: \"-0.01em\",\n lineHeight: 1,\n }}\n >\n Your bag\n </span>\n <span style={{ ...label16, marginLeft: 12 }}>1 item</span>\n <div style={{ flex: 1 }} />\n <Icon name=\"x\" color={pal.muted} size={22} />\n </div>\n\n <div\n style={{\n marginTop: 26,\n opacity: item(0),\n transform: `translateY(${(1 - item(0)) * 12}px)`,\n }}\n >\n <div style={{ ...label16, fontVariantNumeric: \"tabular-nums\" }}>\n {remaining > 0 ? (\n <>\n <span style={{ color: pal.text }}>\n {money(remaining, currency, true)}\n </span>{\" \"}\n away from free shipping\n </>\n ) : (\n \"Free shipping unlocked\"\n )}\n </div>\n <div\n style={{\n height: 6,\n borderRadius: 3,\n background: pal.fill,\n marginTop: 12,\n overflow: \"hidden\",\n boxShadow: `inset 0 0 0 1px ${pal.line}`,\n }}\n >\n <div\n style={{\n height: 6,\n borderRadius: 3,\n background: accent,\n transformOrigin: \"0 50%\",\n transform: `scaleX(${shipFill * shipRatio})`,\n }}\n />\n </div>\n </div>\n\n <div\n style={{\n display: \"flex\",\n gap: 18,\n marginTop: 28,\n paddingTop: 24,\n borderTop: `1px solid ${pal.line}`,\n opacity: item(1),\n transform: `translateY(${(1 - item(1)) * 12}px)`,\n }}\n >\n <div\n style={{\n width: 100,\n height: 116,\n borderRadius: 14,\n overflow: \"hidden\",\n flexShrink: 0,\n outline: `1px solid ${pal.outline}`,\n outlineOffset: -1,\n }}\n >\n <Photo swatch={c1.swatch} pal={pal} src={img1} brand={brand} />\n </div>\n <div\n style={{ flex: 1, display: \"flex\", flexDirection: \"column\" }}\n >\n <div style={{ display: \"flex\", fontSize: 18 }}>\n <span>{product}</span>\n <span\n style={{\n marginLeft: \"auto\",\n fontVariantNumeric: \"tabular-nums\",\n }}\n >\n {money(s1.price, currency, true)}\n </span>\n </div>\n <div style={{ ...label16, marginTop: 6 }}>\n {c1.name} · {s1.label}\n </div>\n <div\n style={{\n marginTop: \"auto\",\n alignSelf: \"flex-start\",\n display: \"flex\",\n alignItems: \"center\",\n gap: 16,\n height: 36,\n padding: \"0 12px\",\n borderRadius: 18,\n boxShadow: `inset 0 0 0 1px ${pal.ring}`,\n fontSize: 16,\n fontVariantNumeric: \"tabular-nums\",\n }}\n >\n <Icon name=\"minus\" color={pal.faint} size={16} />1\n <Icon name=\"plus\" color={pal.text} size={16} />\n </div>\n </div>\n </div>\n\n <div\n style={{\n marginTop: \"auto\",\n opacity: item(2),\n transform: `translateY(${(1 - item(2)) * 12}px)`,\n }}\n >\n <div style={{ display: \"flex\", fontSize: 18 }}>\n <span>Subtotal</span>\n <span\n style={{\n marginLeft: \"auto\",\n fontVariantNumeric: \"tabular-nums\",\n }}\n >\n {money(s1.price, currency, true)}\n </span>\n </div>\n <div style={{ ...label16, marginTop: 6 }}>\n Taxes calculated at checkout\n </div>\n <div\n style={{\n marginTop: 20,\n height: 64,\n borderRadius: 32,\n background: pal.btn,\n color: pal.btnText,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: 10,\n fontSize: 18,\n filter: `brightness(${1 + (pal.dark ? -0.08 : 0.3) * checkoutHover})`,\n }}\n >\n <Icon name=\"lock\" color={pal.btnText} size={18} />\n Checkout\n </div>\n </div>\n </div>\n ) : null}\n\n <div style={{ opacity: cursorO }}>\n <Cursor x={cur.x} y={cur.y} press={press} />\n </div>\n </div>\n </AbsoluteFill>\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/cart-add.tsx"
}
],
"type": "registry:component"
}