{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"announce","title":"Announcement pill","description":"The pill above a headline. A line of light runs round it once as you reach for it, and the tag says what pressing it will do.","type":"registry:component","author":"Detent","dependencies":["motion"],"registryDependencies":["https://detentui.com/r/theme.json"],"files":[{"path":"components/detent/components/announce/Announcement.tsx","target":"components/detent/components/announce/Announcement.tsx","type":"registry:component","content":"'use client'\n\nimport { useState } from 'react'\nimport type { ElementType, ReactNode } from 'react'\nimport { AnimatePresence, motion } from 'motion/react'\nimport { Roll } from '@/components/detent/ui/Roll'\n\nconst CSS = `\n@property --announce-spin { syntax: '<angle>'; inherits: false; initial-value: 0deg; }\n.announce-ring { position:absolute; inset:0; border-radius:inherit; padding:1px; pointer-events:none; opacity:0; transition:opacity .3s; background:conic-gradient(from var(--announce-spin), transparent 0 68%, currentColor 88%, transparent 100%); -webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0); -webkit-mask-composite:xor; mask-composite:exclude; }\n.announce:hover .announce-ring, .announce:focus-within .announce-ring { opacity:.75; animation:announce-run 1.8s cubic-bezier(.6,0,.3,1) both; }\n@keyframes announce-run { to { --announce-spin:360deg } }\n@media (prefers-reduced-motion: reduce) { .announce:hover .announce-ring, .announce:focus-within .announce-ring { animation:none; opacity:0 } }\n`\n\nexport type AnnouncementProps = {\n  children: ReactNode\n  href: string\n  tag?: string\n  action?: string\n  dismissible?: boolean\n  onDismiss?: () => void\n  linkAs?: ElementType\n  className?: string\n}\n\nexport function Announcement({ children, href, tag = 'New', action = 'View', dismissible = false, onDismiss, linkAs: Link = 'a', className = '' }: AnnouncementProps) {\n  const [near, setNear] = useState(false)\n  const [gone, setGone] = useState(false)\n  return (\n    <>\n      <style>{CSS}</style>\n      <AnimatePresence initial={false}>\n        {!gone && (\n          <motion.div\n            exit={{ opacity: 0, scale: 0.97, transition: { duration: 0.14 } }}\n            onPointerEnter={() => setNear(true)}\n            onPointerLeave={() => setNear(false)}\n            className={`announce relative inline-flex h-9 max-w-full items-center rounded-full bg-surface pl-1 text-[14px] font-medium text-ink shadow-raised ${dismissible ? '' : 'pr-1'} ${className}`}\n          >\n            <span aria-hidden className=\"announce-ring\" />\n            <Link href={href} onFocus={() => setNear(true)} onBlur={() => setNear(false)} className=\"ring-focus flex min-w-0 items-center gap-2 rounded-full pr-3\">\n              <span className=\"grid h-7 shrink-0 place-items-center rounded-full bg-ink px-2.5 text-[13px] text-surface\">\n                <Roll word={near ? action : tag} />\n              </span>\n              <span className=\"truncate\">{children}</span>\n            </Link>\n            {dismissible && (\n              <button\n                type=\"button\"\n                aria-label=\"Dismiss\"\n                onClick={() => {\n                  setGone(true)\n                  onDismiss?.()\n                }}\n                className=\"ring-focus mr-1 grid size-7 shrink-0 place-items-center rounded-full text-ink-3 transition-colors ease-detent duration-150 hover:bg-surface-2 hover:text-ink\"\n              >\n                <svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" aria-hidden>\n                  <path d=\"M1.5 1.5l7 7M8.5 1.5l-7 7\" />\n                </svg>\n              </button>\n            )}\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </>\n  )\n}\n"},{"path":"components/detent/ui/Roll.tsx","target":"components/detent/ui/Roll.tsx","type":"registry:component","content":"'use client'\n\nimport { useLayoutEffect, useRef, useState } from 'react'\nimport { AnimatePresence, motion, useReducedMotion } from 'motion/react'\n\nconst SMOOTH = { type: 'spring', bounce: 0, duration: 0.42 } as const\n\nexport function Roll({ word, className = '' }: { word: string; className?: string }) {\n  const reduce = useReducedMotion()\n  const probe = useRef<HTMLSpanElement>(null)\n  const [width, setWidth] = useState<number | undefined>(undefined)\n  useLayoutEffect(() => {\n    const read = () => probe.current && setWidth(probe.current.offsetWidth)\n    read()\n    void document.fonts?.ready.then(read)\n  }, [word])\n  return (\n    <motion.span initial={false} animate={{ width }} transition={reduce ? { duration: 0 } : SMOOTH} className={`relative inline-flex overflow-hidden align-bottom ${className}`}>\n      <span ref={probe} aria-hidden className=\"invisible absolute left-0 top-0 whitespace-pre\">\n        {word}\n      </span>\n      <AnimatePresence mode=\"popLayout\" initial={false}>\n        <motion.span key={word} initial={reduce ? false : { y: '70%', opacity: 0 }} animate={{ y: 0, opacity: 1 }} exit={reduce ? undefined : { y: '-70%', opacity: 0 }} transition={SMOOTH} className=\"inline-block whitespace-pre\">\n          {word}\n        </motion.span>\n      </AnimatePresence>\n    </motion.span>\n  )\n}\n"}]}