{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "thumbnail",
  "type": "registry:component",
  "title": "Thumbnail",
  "description": "A small square tile that stands for a thing.",
  "dependencies": [
    "@remixicon/react@^4.9.0",
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "https://wideset.co/r/icon-types.json",
    "https://wideset.co/r/styles.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/components/thumbnail/Thumbnail.logic.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/thumbnail/Thumbnail.logic.ts",
      "content": "import type { ThumbnailFileType } from './Thumbnail.types';\n\nconst EXTENSIONS: Record<ThumbnailFileType, readonly string[]> = {\n  pdf: ['pdf'],\n  spreadsheet: ['xls', 'xlsx', 'xlsm', 'csv', 'tsv', 'ods', 'numbers'],\n  document: ['doc', 'docx', 'odt', 'rtf', 'txt', 'md', 'pages'],\n  video: ['mp4', 'm4v', 'mov', 'webm', 'avi', 'mkv', 'wmv', 'mpg', 'mpeg'],\n  picture: [\n    'png',\n    'jpg',\n    'jpeg',\n    'gif',\n    'webp',\n    'svg',\n    'bmp',\n    'heic',\n    'heif',\n    'avif',\n    'tif',\n    'tiff',\n  ],\n};\n\nconst MIME_TYPES: ReadonlyArray<[test: (mime: string) => boolean, type: ThumbnailFileType]> = [\n  [(m) => m === 'application/pdf', 'pdf'],\n  [(m) => m.startsWith('image/'), 'picture'],\n  [(m) => m.startsWith('video/'), 'video'],\n  [(m) => m.includes('spreadsheet') || m.includes('excel') || m === 'text/csv', 'spreadsheet'],\n  [\n    (m) =>\n      m.startsWith('text/') || m.includes('word') || m.includes('document') || m.includes('rtf'),\n    'document',\n  ],\n];\n\n/**\n * Picks the Thumbnail `type` for a file from its MIME type, then its\n * extension. Anything unrecognised — archives, audio, code — falls back to\n * `document`, the most generic of Figma's file kinds.\n */\nexport const getThumbnailType = (name?: string, mimeType?: string): ThumbnailFileType => {\n  if (mimeType) {\n    const mime = mimeType.toLowerCase();\n    const match = MIME_TYPES.find(([test]) => test(mime));\n    if (match) return match[1];\n  }\n\n  const extension = name?.split('.').pop()?.toLowerCase();\n  if (extension && extension !== name?.toLowerCase()) {\n    const match = (Object.keys(EXTENSIONS) as ThumbnailFileType[]).find((type) =>\n      EXTENSIONS[type].includes(extension),\n    );\n    if (match) return match;\n  }\n\n  return 'document';\n};\n"
    },
    {
      "path": "src/components/thumbnail/Thumbnail.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/thumbnail/Thumbnail.tsx",
      "content": "'use client';\n\nimport {\n  type RemixiconComponentType,\n  RiBarChartFill,\n  RiFilePdf2Fill,\n  RiFileTextFill,\n  RiImageFill,\n  RiTableFill,\n  RiVidiconFill,\n} from '@remixicon/react';\nimport { forwardRef } from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport type {\n  ThumbnailFileType,\n  ThumbnailProps,\n  ThumbnailWithSubComponents,\n} from './Thumbnail.types';\nimport {\n  thumbnailIconVariants,\n  thumbnailTextVariants,\n  thumbnailVariants,\n} from './Thumbnail.variants';\nimport { ThumbnailContext } from './ThumbnailContext';\nimport { ThumbnailIcon } from './ThumbnailIcon';\nimport { ThumbnailImage } from './ThumbnailImage';\n\n/**\n * Figma draws Material glyphs here (`picture_as_pdf`, `table_chart`,\n * `description`, `videocam`, `image`); these are their Remix counterparts.\n */\nconst FILE_TYPE_ICONS: Record<ThumbnailFileType, RemixiconComponentType> = {\n  pdf: RiFilePdf2Fill,\n  spreadsheet: RiTableFill,\n  document: RiFileTextFill,\n  video: RiVidiconFill,\n  picture: RiImageFill,\n};\n\n/**\n * A small square tile that stands for a thing — a document, an image, a brand.\n * The content mode follows the prop you pass: `icon` for a glyph, `src` for a\n * picture, `text` for a letter, or `type` for one of the fixed file kinds.\n */\nexport const Thumbnail = forwardRef<HTMLDivElement, ThumbnailProps>(\n  ({ className, size, children, type, icon: Icon, src, alt, text, ...props }, ref) => {\n    const resolvedType = type ?? (src ? 'image' : text !== undefined ? 'text' : 'icon');\n\n    const renderContent = () => {\n      if (children) return children;\n\n      switch (resolvedType) {\n        case 'image':\n          return <ThumbnailImage src={src as string} alt={alt ?? ''} />;\n        case 'logo':\n          return (\n            <img\n              src={src}\n              alt={alt ?? ''}\n              className={cn(thumbnailIconVariants({ size }), 'object-contain')}\n            />\n          );\n        case 'text':\n          return <span className={thumbnailTextVariants({ size })}>{text}</span>;\n        case 'icon':\n          return <ThumbnailIcon icon={Icon ?? RiBarChartFill} />;\n        default:\n          return <ThumbnailIcon icon={FILE_TYPE_ICONS[resolvedType]} />;\n      }\n    };\n\n    return (\n      <ThumbnailContext.Provider value={{ size }}>\n        <div\n          ref={ref}\n          data-slot=\"thumbnail\"\n          className={cn(thumbnailVariants({ size, type: resolvedType }), className)}\n          {...props}\n        >\n          {renderContent()}\n        </div>\n      </ThumbnailContext.Provider>\n    );\n  },\n) as ThumbnailWithSubComponents;\n\nThumbnail.displayName = 'Thumbnail';\nThumbnail.Icon = ThumbnailIcon;\nThumbnail.Image = ThumbnailImage;\n"
    },
    {
      "path": "src/components/thumbnail/Thumbnail.types.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/thumbnail/Thumbnail.types.ts",
      "content": "import type { RemixiconComponentType } from '@remixicon/react';\nimport type { VariantProps } from 'class-variance-authority';\nimport type {\n  ForwardRefExoticComponent,\n  HTMLAttributes,\n  ImgHTMLAttributes,\n  PropsWithoutRef,\n  RefAttributes,\n} from 'react';\n\nimport type { RemixiconProps } from '@/lib/wideset/icon.types';\nimport type { thumbnailVariants } from './Thumbnail.variants';\nimport type { ThumbnailIcon } from './ThumbnailIcon';\nimport type { ThumbnailImage } from './ThumbnailImage';\n\nexport type ThumbnailSize = NonNullable<VariantProps<typeof thumbnailVariants>['size']>;\n\n/**\n * Figma's `Type` axis. The first four take content from you; the file kinds\n * carry a fixed glyph and hue so a document list reads at a glance.\n */\nexport type ThumbnailType = NonNullable<VariantProps<typeof thumbnailVariants>['type']>;\n\n/** The `Type` values that stand for a kind of file rather than for content you pass in. */\nexport type ThumbnailFileType = Extract<\n  ThumbnailType,\n  'pdf' | 'spreadsheet' | 'document' | 'video' | 'picture'\n>;\n\nexport type ThumbnailContextType = {\n  size?: ThumbnailSize;\n};\n\nexport type ThumbnailCommonProps = {\n  /** Figma's `Size` axis: 16 / 20 / 24 / 32 / 40px. */\n  size?: ThumbnailSize;\n};\n\ntype ThumbnailIconContent = {\n  type?: 'icon';\n  /** Glyph drawn on the purple tile. Defaults to a bar chart, as in Figma. */\n  icon?: RemixiconComponentType;\n  src?: never;\n  alt?: never;\n  text?: never;\n};\n\ntype ThumbnailImageContent = {\n  type?: 'image';\n  /** Picture that fills the tile edge to edge. */\n  src: string;\n  /** Alternative text. Pass `\"\"` when the picture is decorative. */\n  alt: string;\n  icon?: never;\n  text?: never;\n};\n\ntype ThumbnailLogoContent = {\n  type: 'logo';\n  /** Logo drawn at glyph size on a white tile with a subtle border. */\n  src: string;\n  /** Alternative text. Pass `\"\"` when the logo is decorative. */\n  alt: string;\n  icon?: never;\n  text?: never;\n};\n\ntype ThumbnailTextContent = {\n  type?: 'text';\n  /** Short label — a letter or two — drawn on the purple tile. */\n  text: string;\n  icon?: never;\n  src?: never;\n  alt?: never;\n};\n\ntype ThumbnailFileContent = {\n  /** A kind of file. The glyph and hue are fixed per kind. */\n  type: ThumbnailFileType;\n  icon?: never;\n  src?: never;\n  alt?: never;\n  text?: never;\n};\n\nexport type ThumbnailContent =\n  | ThumbnailIconContent\n  | ThumbnailImageContent\n  | ThumbnailLogoContent\n  | ThumbnailTextContent\n  | ThumbnailFileContent;\n\nexport type ThumbnailProps = HTMLAttributes<HTMLDivElement> &\n  ThumbnailCommonProps &\n  ThumbnailContent;\n\nexport type ThumbnailIconProps = RemixiconProps &\n  ThumbnailCommonProps & {\n    icon: RemixiconComponentType;\n  };\n\nexport type ThumbnailImageProps = ImgHTMLAttributes<HTMLImageElement> &\n  ThumbnailCommonProps & {\n    src: string;\n    alt: string;\n  };\n\nexport type ThumbnailWithSubComponents = ForwardRefExoticComponent<\n  PropsWithoutRef<ThumbnailProps> & RefAttributes<HTMLDivElement>\n> & {\n  Icon: typeof ThumbnailIcon;\n  Image: typeof ThumbnailImage;\n};\n"
    },
    {
      "path": "src/components/thumbnail/Thumbnail.variants.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/thumbnail/Thumbnail.variants.ts",
      "content": "import { cva } from 'class-variance-authority';\n\n/**\n * Box per Figma `Type` x `Size`. Sizes are `Size/9..16` with the radius stepping\n * `Control/sm` -> `md` -> `lg`; the hue per file kind is the matching\n * `Non-Semantic/Fill/<hue>/Strong` + `Text/<hue>/OnStrong` pair.\n *\n * `pdf` is `Non-Semantic/Fill/Scarlet/Strong` (#e96949) in Figma — a coral at\n * 12° that no exported hue comes near (`red` is 358°, ΔE 17.8; `orange` 30°,\n * ΔE 29.7). Scarlet has no ramp in the token export and no dark value, so the\n * hex is hard-coded here, the one place it is used, until the hue ships. The\n * glyph keeps the `Purple/OnStrong` white Figma binds on that tile.\n */\nexport const thumbnailVariants = cva(\n  'relative flex shrink-0 items-center justify-center overflow-hidden',\n  {\n    variants: {\n      size: {\n        xs: 'rounded-ws-control-sm size-ws-9',\n        sm: 'rounded-ws-control-md size-ws-11',\n        md: 'rounded-ws-control-md size-ws-12',\n        lg: 'rounded-ws-control-lg size-ws-14',\n        xl: 'rounded-ws-control-lg size-ws-16',\n      },\n      type: {\n        icon: 'bg-ws-non-semantic-purple-strong text-ws-non-semantic-purple-on-strong',\n        text: 'bg-ws-non-semantic-purple-strong text-ws-non-semantic-purple-on-strong',\n        image: '',\n        logo: 'bg-ws-static-highlight-base border-ws-static-subtle border',\n        pdf: 'text-ws-non-semantic-purple-on-strong bg-[#e96949]',\n        spreadsheet: 'bg-ws-non-semantic-green-strong text-ws-non-semantic-green-on-strong',\n        document: 'bg-ws-non-semantic-cyan-strong text-ws-non-semantic-cyan-on-strong',\n        video: 'bg-ws-non-semantic-indigo-strong text-ws-non-semantic-indigo-on-strong',\n        picture: 'bg-ws-non-semantic-yellow-strong text-ws-non-semantic-yellow-on-strong',\n      },\n    },\n    defaultVariants: {\n      size: 'md',\n      type: 'icon',\n    },\n  },\n);\n\n/** Glyph per size: 12 / 12 / 16 / 20 / 24 — Figma's centred icon frame. */\nexport const thumbnailIconVariants = cva('shrink-0', {\n  variants: {\n    size: {\n      xs: 'size-ws-7',\n      sm: 'size-ws-7',\n      md: 'size-ws-9',\n      lg: 'size-ws-11',\n      xl: 'size-ws-12',\n    },\n  },\n  defaultVariants: {\n    size: 'md',\n  },\n});\n\n/** Figma binds `Caption/Strong/Small` up to 24px, `Caption/Strong/Medium` at 32, `Label/Strong/Small` at 40. */\nexport const thumbnailTextVariants = cva('max-w-full truncate text-center', {\n  variants: {\n    size: {\n      xs: 'typography-caption-strong-sm',\n      sm: 'typography-caption-strong-sm',\n      md: 'typography-caption-strong-sm',\n      lg: 'typography-caption-strong-md',\n      xl: 'typography-label-strong-sm',\n    },\n  },\n  defaultVariants: {\n    size: 'md',\n  },\n});\n"
    },
    {
      "path": "src/components/thumbnail/ThumbnailContext.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/thumbnail/ThumbnailContext.ts",
      "content": "'use client';\n\nimport { createContext, useContext } from 'react';\n\nimport type { ThumbnailContextType } from './Thumbnail.types';\n\nexport const ThumbnailContext = createContext<ThumbnailContextType | undefined>(undefined);\n\nexport const useThumbnailContext = () => {\n  const context = useContext(ThumbnailContext);\n\n  if (context === undefined) {\n    throw new Error('useThumbnailContext must be used within a Thumbnail');\n  }\n\n  return context;\n};\n"
    },
    {
      "path": "src/components/thumbnail/ThumbnailIcon.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/thumbnail/ThumbnailIcon.tsx",
      "content": "'use client';\n\nimport { forwardRef } from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport type { ThumbnailIconProps } from './Thumbnail.types';\nimport { thumbnailIconVariants } from './Thumbnail.variants';\nimport { useThumbnailContext } from './ThumbnailContext';\n\nexport const ThumbnailIcon = forwardRef<SVGSVGElement, ThumbnailIconProps>(\n  ({ size, icon: Icon, className, ...props }, ref) => {\n    const context = useThumbnailContext();\n\n    return (\n      <Icon\n        ref={ref}\n        data-slot=\"thumbnail-icon\"\n        aria-hidden=\"true\"\n        focusable=\"false\"\n        className={cn(thumbnailIconVariants({ size: size || context?.size || 'md' }), className)}\n        {...props}\n      />\n    );\n  },\n);\n\nThumbnailIcon.displayName = 'Thumbnail.Icon';\n"
    },
    {
      "path": "src/components/thumbnail/ThumbnailImage.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/thumbnail/ThumbnailImage.tsx",
      "content": "'use client';\n\nimport { forwardRef } from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport type { ThumbnailImageProps } from './Thumbnail.types';\n\nexport const ThumbnailImage = forwardRef<HTMLImageElement, ThumbnailImageProps>(\n  ({ src, alt, className, ...props }, ref) => (\n    <img\n      ref={ref}\n      data-slot=\"thumbnail-image\"\n      src={src}\n      alt={alt}\n      className={cn('size-full object-cover', className)}\n      {...props}\n    />\n  ),\n);\n\nThumbnailImage.displayName = 'Thumbnail.Image';\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "commit": "8bb3627"
  }
}
