{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "cookie-consent-island",
  "title": "Cookie consent island",
  "description": "A pill at the foot of the page that asks about cookies in one line, with Reject all as easy as Accept all; Customise opens it into a panel with a switch for each category.",
  "dependencies": [],
  "registryDependencies": [
    "https://kinoui.com/r/badge.json",
    "https://kinoui.com/r/button.json",
    "https://kinoui.com/r/consent.json",
    "https://kinoui.com/r/cookie-consent-parts.json",
    "https://kinoui.com/r/island.json",
    "https://kinoui.com/r/panel.json",
    "https://kinoui.com/r/scroll.json",
    "https://kinoui.com/r/swap.json",
    "https://kinoui.com/r/skeleton.json",
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/components/kino/cookie-consent-island/cookie-consent-island.tsx",
      "content": "'use client'\n\nimport { Button } from '@/registry/components/kino/button'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport type { Consent } from '@/registry/lib/consent'\nimport {\n  CookieConsentCategory,\n  CookieConsentDescription,\n  cookieConsentFocusClassName,\n  cookieConsentStatesClassName,\n  type CookieConsentText,\n  defaultText,\n  useCookieConsent,\n} from '@/registry/lib/cookie-consent-parts'\nimport {\n  islandPlaceClassName,\n  islandMotionClassName,\n  islandSurfaceClassName,\n} from '@/registry/lib/island'\nimport { panelTitleClassName } from '@/registry/lib/panel'\nimport { edgeFadeClassName, useEdgeFades } from '@/registry/lib/scroll'\nimport { Swap } from '@/registry/lib/swap'\nimport { type ComponentProps, type ReactNode, useId, useRef } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * A pill at the foot of the page that asks about cookies in one line:\n * Customise, Reject all and Accept all, as easy as each other. Customise\n * opens the pill into a panel with a switch for each category, on the\n * `layout` role; Escape closes it back. In a column too narrow for one line,\n * the pill is a card. The page places it with its className, pinned across\n * the foot of the window above everything else: it centres itself there.\n *\n *   <CookieConsentIsland\n *     consent={consent}\n *     summary='Kino uses cookies for analytics and ads, with your OK.'\n *     policyHref='/cookies'\n *     className={foot}\n *   />\n */\n\ninterface CookieConsentIslandProps<Id extends string>\n  extends Omit<ComponentProps<'div'>, 'title'>, CookieConsentText {\n  consent: Consent<Id>\n  /** The pill's one line: what the cookies are for, as the first thing a visitor reads. */\n  summary?: ReactNode\n}\n\nfunction CookieConsentIsland<Id extends string>({\n  consent,\n  title = defaultText.title,\n  description = defaultText.description,\n  policyHref,\n  summary = 'We use cookies for analytics and ads, with your OK.',\n  className,\n  ...props\n}: CookieConsentIslandProps<Id>) {\n  const surfaceRef = useRef<HTMLElement>(null)\n  const model = useCookieConsent(consent, surfaceRef)\n  const titleId = useId()\n  // Reject all and Accept all weigh the same; once the switches show, Save choices leads.\n  const answerVariant = model.customising ? 'outline' : 'default'\n  const fades = useEdgeFades<HTMLDivElement>()\n  if (!model.ready) return null\n\n  const buttons = (\n    <>\n      <Button\n        variant={model.customising ? 'default' : 'ghost'}\n        onClick={model.customiseOrSave}\n      >\n        {model.customising ? 'Save choices' : 'Customise'}\n      </Button>\n      <Button variant={answerVariant} onClick={model.rejectAll}>\n        Reject all\n      </Button>\n      <Button variant={answerVariant} onClick={model.acceptAll}>\n        Accept all\n      </Button>\n    </>\n  )\n\n  return (\n    <div\n      data-slot='cookie-consent'\n      className={cn(islandPlaceClassName, className)}\n      {...props}\n    >\n      <section\n        ref={surfaceRef}\n        aria-labelledby={titleId}\n        tabIndex={-1}\n        data-closed={model.shown ? undefined : ''}\n        data-customising={model.customising ? '' : undefined}\n        inert={!model.shown}\n        className={cn(\n          islandSurfaceClassName,\n          cookieConsentStatesClassName,\n          islandMotionClassName,\n          cookieConsentFocusClassName,\n          // One line: its corner wraps the buttons' at its padding, a pill when they are. A card once it opens or wraps.\n          'rounded-(--surface-radius) @2xl/island:rounded-(--island-pill) @2xl/island:data-customising:rounded-(--surface-radius)',\n        )}\n      >\n        <Swap block id={model.customising ? 'panel' : 'pill'}>\n          {/* As wide as a card, or the column less the border on each side. */}\n          {model.customising ? (\n            <div className='flex w-[min(28rem,calc(100cqw-2px))] flex-col p-(--surface-padding)'>\n              <h2 id={titleId} className={panelTitleClassName}>\n                {title}\n              </h2>\n              <CookieConsentDescription\n                className='mt-1'\n                description={description}\n                policyHref={policyHref}\n              />\n              <div\n                ref={fades}\n                className={cn(\n                  edgeFadeClassName,\n                  'scrollbar-thin -mx-(--surface-padding) mt-(--surface-gap) max-h-72 overflow-y-auto border-t px-(--surface-padding) pt-(--surface-gap)',\n                )}\n              >\n                <div className='flex flex-col gap-4 pb-1'>\n                  {model.categories.map((category) => (\n                    <CookieConsentCategory\n                      key={category.id}\n                      category={category}\n                      model={model}\n                    />\n                  ))}\n                </div>\n              </div>\n              <div className='mt-(--surface-gap) flex flex-col gap-2 @xs/island:flex-row @xs/island:[&>:first-child]:me-auto'>\n                {buttons}\n              </div>\n            </div>\n          ) : (\n            <div className='flex w-[min(28rem,calc(100cqw-2px))] flex-col gap-3 p-(--surface-padding) @2xl/island:w-auto @2xl/island:flex-row @2xl/island:items-center @2xl/island:gap-4 @2xl/island:py-(--island-padding) @2xl/island:ps-5 @2xl/island:pe-(--island-padding)'>\n              <p className='flex min-w-0 items-center gap-2.5 text-sm'>\n                <IconPlaceholder\n                  lucide='CookieIcon'\n                  tabler='IconCookie'\n                  hugeicons='CookieIcon'\n                  phosphor='CookieIcon'\n                  remixicon='RiCookieLine'\n                  aria-hidden\n                  className='text-muted-foreground size-4 shrink-0'\n                />\n                <span>\n                  <span id={titleId}>{summary}</span>\n                  {policyHref ? (\n                    <>\n                      {' '}\n                      <a\n                        href={policyHref}\n                        className='text-muted-foreground hover:text-foreground underline underline-offset-3'\n                      >\n                        Cookie policy\n                      </a>\n                    </>\n                  ) : null}\n                </span>\n              </p>\n              <div className='flex flex-col gap-2 @xs/island:flex-row @xs/island:[&>:first-child]:me-auto @2xl/island:[&>:first-child]:me-0'>\n                {buttons}\n              </div>\n            </div>\n          )}\n        </Swap>\n      </section>\n    </div>\n  )\n}\n\nexport { CookieConsentIsland }\n\nexport type { CookieConsentIslandProps }\n",
      "type": "registry:component",
      "target": "@components/kino/cookie-consent-island/cookie-consent-island.tsx"
    }
  ],
  "type": "registry:block"
}