{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "floating-promo-pill",
  "title": "Floating Promo Pill",
  "description": "A small offer that floats near the bottom of the page and opens on hover or focus to show the details and a button, without covering the content.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/new-york/floating-promo-pill/floating-promo-pill.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface FloatingPromoPillProps extends Omit<\n  React.ComponentPropsWithoutRef<\"div\">,\n  \"title\"\n> {\n  theme?: \"dark\" | \"light\";\n  /** Short line, always visible. */\n  title?: string;\n  /** Extra line shown when it opens. */\n  detail?: string;\n  action?: { label: string; href?: string; onClick?: () => void } | null;\n  /** Where it floats. */\n  position?: \"bottom-center\" | \"bottom-right\" | \"bottom-left\";\n  /** Keep it inside the nearest positioned parent instead of the window. */\n  contained?: boolean;\n  /** Milliseconds before it arrives. */\n  delay?: number;\n  dismissible?: boolean;\n  onDismiss?: () => void;\n}\n\nconst PALETTES = {\n  dark: {\n    bar: \"#0F1011\",\n    surface: \"#161718\",\n    border: \"rgba(255,255,255,0.08)\",\n    text: \"#F7F8F8\",\n    soft: \"#D0D6E0\",\n    sub: \"#8A8F98\",\n    faint: \"#62666D\",\n    chip: \"rgba(255,255,255,0.06)\",\n    btn: \"#E5E5E6\",\n    btnText: \"#08090A\",\n    accent: \"#5E6AD2\",\n    shadow: \"0 8px 32px rgba(0,0,0,0.45)\",\n  },\n  light: {\n    bar: \"#FFFFFF\",\n    surface: \"#FFFFFF\",\n    border: \"rgba(8,9,10,0.1)\",\n    text: \"#08090A\",\n    soft: \"#3C3F44\",\n    sub: \"#62666D\",\n    faint: \"#8A8F98\",\n    chip: \"rgba(8,9,10,0.05)\",\n    btn: \"#08090A\",\n    btnText: \"#F7F8F8\",\n    accent: \"#5E6AD2\",\n    shadow: \"0 8px 28px rgba(8,9,10,0.12)\",\n  },\n};\n\ntype Palette = (typeof PALETTES)[\"dark\"];\n\nconst FONT =\n  '\"Inter Variable\", Inter, \"SF Pro Display\", -apple-system, BlinkMacSystemFont, sans-serif';\n\nfunction CloseButton({\n  label,\n  pal,\n  onClick,\n}: {\n  label: string;\n  pal: Palette;\n  onClick: () => void;\n}) {\n  return (\n    <button\n      type=\"button\"\n      aria-label={label}\n      onClick={onClick}\n      className=\"grid size-7 shrink-0 cursor-pointer place-items-center rounded-full transition-colors outline-none hover:bg-[var(--chip)] focus-visible:ring-2\"\n      style={{ \"--chip\": pal.chip, color: pal.sub } as React.CSSProperties}\n    >\n      <svg\n        width=\"10\"\n        height=\"10\"\n        viewBox=\"0 0 10 10\"\n        fill=\"none\"\n        stroke=\"currentColor\"\n        strokeWidth=\"1.6\"\n        strokeLinecap=\"round\"\n        aria-hidden=\"true\"\n      >\n        <path d=\"m1 1 8 8M9 1 1 9\" />\n      </svg>\n    </button>\n  );\n}\n\nconst SPOT = {\n  \"bottom-center\": \"bottom-5 left-1/2 -translate-x-1/2\",\n  \"bottom-right\": \"right-5 bottom-5\",\n  \"bottom-left\": \"bottom-5 left-5\",\n};\n\nexport function FloatingPromoPill({\n  theme = \"dark\",\n  title = \"20% off annual plans\",\n  detail = \"Ends Sunday. No code needed.\",\n  action = { label: \"See plans\" },\n  position = \"bottom-center\",\n  contained = false,\n  delay = 600,\n  dismissible = true,\n  onDismiss,\n  className,\n  style,\n  ...props\n}: FloatingPromoPillProps) {\n  const pal = PALETTES[theme];\n  const [shown, setShown] = React.useState(false);\n  const [gone, setGone] = React.useState(false);\n  const [expanded, setExpanded] = React.useState(false);\n\n  React.useEffect(() => {\n    const timer = window.setTimeout(() => setShown(true), delay);\n    return () => window.clearTimeout(timer);\n  }, [delay]);\n\n  if (gone) return null;\n  const button =\n    \"inline-flex h-7 shrink-0 cursor-pointer items-center rounded-full px-3 text-[12px] font-[510] no-underline transition-opacity hover:opacity-90\";\n\n  return (\n    <div\n      role=\"complementary\"\n      aria-label={title}\n      onPointerEnter={() => setExpanded(true)}\n      onPointerLeave={() => setExpanded(false)}\n      onFocus={() => setExpanded(true)}\n      onBlur={(e) => {\n        if (!e.currentTarget.contains(e.relatedTarget)) setExpanded(false);\n      }}\n      onTransitionEnd={(e) => {\n        if (!shown && e.propertyName === \"opacity\") {\n          setGone(true);\n          onDismiss?.();\n        }\n      }}\n      className={`${contained ? \"absolute\" : \"fixed\"} ${SPOT[position]} z-40 max-w-[calc(100%-24px)] motion-safe:transition-[opacity,transform] motion-safe:duration-300 ${className ?? \"\"}`}\n      style={{\n        opacity: shown ? 1 : 0,\n        transform: shown ? \"none\" : \"translateY(16px)\",\n        color: pal.text,\n        fontFamily: FONT,\n        ...style,\n      }}\n      {...props}\n    >\n      <div\n        className=\"flex items-center gap-2.5 rounded-full py-1.5 pr-1.5 pl-4\"\n        style={{\n          background: pal.surface,\n          boxShadow: `inset 0 0 0 1px ${pal.border}, ${pal.shadow}`,\n        }}\n      >\n        <span\n          aria-hidden=\"true\"\n          className=\"size-2 shrink-0 rounded-full\"\n          style={{ background: pal.accent }}\n        />\n        <span className=\"shrink-0 text-[13px] font-[510] tracking-[-0.011em] whitespace-nowrap\">\n          {title}\n        </span>\n        {/* Opens by growing a grid column, so the pill needs no measured width. */}\n        <span\n          className=\"grid min-w-0 motion-safe:transition-[grid-template-columns] motion-safe:duration-300 motion-safe:ease-[cubic-bezier(0.22,1,0.36,1)]\"\n          style={{ gridTemplateColumns: expanded ? \"1fr\" : \"0fr\" }}\n        >\n          <span className=\"flex min-w-0 items-center gap-2.5 overflow-hidden\">\n            <span\n              className=\"text-[13px] tracking-[-0.011em] whitespace-nowrap\"\n              style={{ color: pal.sub }}\n            >\n              {detail}\n            </span>\n            {action &&\n              (action.href ? (\n                <a\n                  href={action.href}\n                  tabIndex={expanded ? 0 : -1}\n                  className={button}\n                  style={{ background: pal.btn, color: pal.btnText }}\n                >\n                  {action.label}\n                </a>\n              ) : (\n                <button\n                  type=\"button\"\n                  onClick={action.onClick}\n                  tabIndex={expanded ? 0 : -1}\n                  className={button}\n                  style={{ background: pal.btn, color: pal.btnText }}\n                >\n                  {action.label}\n                </button>\n              ))}\n          </span>\n        </span>\n        {dismissible && (\n          <CloseButton\n            label=\"Dismiss\"\n            pal={pal}\n            onClick={() => setShown(false)}\n          />\n        )}\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}