{
  "name": "section",
  "type": "registry:ui",
  "framework": "react",
  "title": "Section",
  "description": "A block of text with one accessory beside it — a thumbnail, or a button.",
  "files": [
    {
      "path": "ui/section.tsx",
      "content": "import * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/*\n * A block of text with one thing beside it: a thumbnail, or a button. That\n * pairing is the whole component — the text column takes the space that is\n * left, and the accessory keeps its own width whatever the text does.\n */\nconst Section = React.forwardRef<\n  HTMLDivElement,\n  React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n  <div\n    ref={ref}\n    className={cn(\"flex w-full items-start gap-4\", className)}\n    {...props}\n  />\n))\nSection.displayName = \"Section\"\n\nconst SectionContent = React.forwardRef<\n  HTMLDivElement,\n  React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n  <div\n    ref={ref}\n    className={cn(\n      \"flex min-w-0 flex-1 flex-col gap-2 text-[15px] leading-[1.375] text-newt-text-secondary\",\n      className\n    )}\n    {...props}\n  />\n))\nSectionContent.displayName = \"SectionContent\"\n\nconst SectionHeading = React.forwardRef<\n  HTMLParagraphElement,\n  React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => (\n  <p\n    ref={ref}\n    className={cn(\n      \"font-display text-xl font-bold leading-tight text-newt-text-primary\",\n      className\n    )}\n    {...props}\n  />\n))\nSectionHeading.displayName = \"SectionHeading\"\n\n/*\n * The accessory never shrinks and never stretches: it is the fixed side of\n * the pair, which is what keeps a long paragraph from squeezing a thumbnail\n * into a sliver.\n */\nconst SectionAccessory = React.forwardRef<\n  HTMLDivElement,\n  React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n  <div\n    ref={ref}\n    className={cn(\"flex shrink-0 items-start\", className)}\n    {...props}\n  />\n))\nSectionAccessory.displayName = \"SectionAccessory\"\n\n/*\n * The props of the element or component `as` names, so a custom image\n * component's own props type-check.\n */\nexport type SectionThumbnailProps<E extends React.ElementType = \"img\"> = {\n  /**\n   * The image element or component to render. Defaults to `img`; pass your\n   * framework's image component for optimised sources. It receives `src`,\n   * `alt`, `className` and the spoiler attributes and handlers.\n   */\n  as?: E\n  /**\n   * Marks the image as a spoiler: blurred until clicked, the same treatment\n   * a spoilered attachment gets.\n   */\n  spoiler?: boolean\n  /** Accessible name of a hidden spoiler, read in place of the image. */\n  spoilerLabel?: string\n} & Omit<React.ComponentPropsWithRef<E>, \"as\" | \"spoiler\">\n\ntype SectionThumbnailComponent = {\n  <E extends React.ElementType = \"img\">(\n    props: SectionThumbnailProps<E>\n  ): React.ReactNode\n  displayName?: string\n}\n\n/*\n * SAFETY: `forwardRef` drops the generic signature. The render hands every\n * prop it does not set itself to `as` unchanged, so the props of `as` are\n * the props the part receives.\n */\n// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- see SAFETY\nconst SectionThumbnail = React.forwardRef<\n  HTMLImageElement,\n  SectionThumbnailProps\n>(\n  (\n    {\n      as: Tag = \"img\",\n      className,\n      spoiler = false,\n      spoilerLabel = \"Spoiler, click to reveal\",\n      alt = \"\",\n      ...props\n    },\n    ref\n  ) => {\n    const [revealed, setRevealed] = React.useState(false)\n    const hidden = spoiler && !revealed\n\n    return (\n      <Tag\n        ref={ref}\n        alt={alt}\n        data-spoiler={hidden || undefined}\n        /*\n         * A spoilered thumbnail is a button until it is opened: it takes a\n         * click and a key, and says what it is to a screen reader.\n         */\n        role={hidden ? \"button\" : undefined}\n        tabIndex={hidden ? 0 : undefined}\n        aria-label={hidden ? spoilerLabel : undefined}\n        onClick={() => setRevealed(true)}\n        onKeyDown={(event: React.KeyboardEvent<HTMLImageElement>) => {\n          if (!hidden) return\n          if (event.key === \"Enter\" || event.key === \" \") {\n            event.preventDefault()\n            setRevealed(true)\n          }\n        }}\n        className={cn(\n          \"h-[85px] w-[85px] rounded-[var(--newt-radius-lg)] object-cover\",\n          hidden && \"cursor-pointer blur-lg\",\n          className\n        )}\n        {...props}\n      />\n    )\n  }\n) as SectionThumbnailComponent\nSectionThumbnail.displayName = \"SectionThumbnail\"\n\nexport {\n  Section,\n  SectionAccessory,\n  SectionContent,\n  SectionHeading,\n  SectionThumbnail,\n}\n",
      "type": "registry:ui"
    }
  ]
}