{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "midnight-features",
  "title": "Midnight product tiles",
  "author": "Vilqor <https://vilqor.com>",
  "description": "A product section built from interface fragments instead of icons: a research list, a sentence with numbered sources in tooltips, and three facts shown as a schedule, a switch and language codes.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "tooltip",
    "utils",
    "https://midnight-lite.vilqor.com/r/midnight-theme.json"
  ],
  "files": [
    {
      "path": "src/components/site/features.tsx",
      "content": "import { Check, FileText, LoaderCircle, Telescope } from \"lucide-react\"\n\nimport { fill } from \"@/lib/fill\"\nimport { cn } from \"@/lib/utils\"\nimport { Cite } from \"./cite\"\nimport { SectionHead } from \"./section-head\"\n\ntype TileText = { eyebrow: string; title: string; text: string }\n\nexport type FeaturesContent = {\n  label: string\n  title: string\n  lead: string\n  research: TileText & {\n    /** the list's label, the \"reading\" chip, and what screen readers hear on each row's icon */\n    label: string\n    status: string\n    reading: string\n    kept: string\n    rows: { title: string; where: string; reading?: boolean }[]\n    footer: { read: string; kept: string }\n  }\n  sources: TileText & {\n    /** what screen readers hear on each number; {n} and {title} are filled in */\n    cite: string\n    /** the sentence in parts; a part with `cite` ends with that source's number */\n    parts: { text: string; cite?: number }[]\n    sources: { n: number; title: string; where: string }[]\n  }\n  schedule: { title: string; text: string; days: string[]; on: number[]; at: string }\n  privacy: { title: string; text: string; setting: string }\n  languages: { title: string; text: string; codes: string[]; more: string }\n}\n\nfunction ResearchArt({ r }: { r: FeaturesContent[\"research\"] }) {\n  return (\n    <div className=\"w-full\">\n      <p className=\"mb-3 flex items-center justify-between\">\n        <span className=\"font-mono text-[11px] tracking-[0.14em] text-ink-3 uppercase\">{r.label}</span>\n        <span className=\"inline-flex items-center gap-1.5 rounded-full bg-brand-soft px-2.5 py-1 text-[11.5px] text-brand-ink\">\n          <Telescope className=\"size-3.5\" strokeWidth={1.75} /> {r.status}\n        </span>\n      </p>\n      <ul className=\"grid gap-2 [mask-image:linear-gradient(to_bottom,black_70%,transparent)]\">\n        {r.rows.map((row) => (\n          <li key={row.title} className=\"flex min-w-0 items-center gap-3 rounded-xl bg-paper/60 px-3.5 py-2.5\">\n            <FileText className=\"size-4 shrink-0 text-ink-3\" strokeWidth={1.75} />\n            <span className=\"min-w-0 flex-1 truncate text-[13.5px] text-ink\">{row.title}</span>\n            <span className=\"num hidden text-[11.5px] text-ink-3 sm:block\">{row.where}</span>\n            {row.reading ? (\n              <LoaderCircle className=\"size-4 text-brand motion-safe:animate-spin\" strokeWidth={1.75} aria-label={r.reading} />\n            ) : (\n              <Check className=\"size-4 text-positive\" strokeWidth={2} aria-label={r.kept} />\n            )}\n          </li>\n        ))}\n      </ul>\n      <p className=\"num mt-3 flex gap-3 text-[12px] text-ink-3\">\n        <span>{r.footer.read}</span>\n        <span className=\"text-brand-ink\">{r.footer.kept}</span>\n      </p>\n    </div>\n  )\n}\n\nfunction SourcesArt({ s }: { s: FeaturesContent[\"sources\"] }) {\n  return (\n    <div className=\"w-full\">\n      <p className=\"text-[17px] leading-8 text-ink max-md:text-[15px] max-md:leading-7\">\n        {s.parts.map((p, i) => {\n          const src = p.cite ? s.sources[p.cite - 1] : undefined\n          if (!src) return <span key={i}>{p.text}</span>\n          // the number stays on the line of the word before it: the last word and the badge don't break apart\n          const cut = p.text.lastIndexOf(\" \") + 1\n          return (\n            <span key={i}>\n              {p.text.slice(0, cut)}\n              <span className=\"whitespace-nowrap\">\n                {p.text.slice(cut)}\n                <Cite {...src} label={fill(s.cite, { n: src.n, title: src.title })} />\n              </span>\n            </span>\n          )\n        })}\n      </p>\n      <ol className=\"mt-4 grid gap-1.5\">\n        {s.sources.map((src) => (\n          <li key={src.n} className=\"flex min-w-0 items-baseline gap-2.5 text-[12.5px] leading-5\">\n            <span className=\"num text-brand-ink\">{src.n}</span>\n            <span className=\"min-w-0 truncate text-ink-2\">{src.title}</span>\n            <span className=\"ml-auto shrink-0 text-ink-3 max-sm:hidden\">{src.where}</span>\n          </li>\n        ))}\n      </ol>\n    </div>\n  )\n}\n\n/** A fact under the tiles: the words first, then the bit of the product that proves them.\n *  Three in a row from 1024 px; below that one under another, so the product bits keep their width. */\nfunction Fact({ title, text, children }: { title: string; text: string; children: React.ReactNode }) {\n  return (\n    <li className=\"flex min-w-0 flex-col gap-4 rounded-2xl bg-surface/60 p-5 max-[380px]:p-4 xl:p-6\">\n      <span>\n        <span className=\"block text-[16px] font-medium\">{title}</span>\n        <span className=\"mt-1 block text-[14.5px] leading-[22px] text-ink-2\">{text}</span>\n      </span>\n      <div aria-hidden=\"true\" className=\"mt-auto flex items-center gap-1.5 max-[380px]:gap-1 lg:min-h-7\">\n        {children}\n      </div>\n    </li>\n  )\n}\n\nfunction Facts({ schedule, privacy, languages }: Pick<FeaturesContent, \"schedule\" | \"privacy\" | \"languages\">) {\n  return (\n    <ul className=\"mt-12 grid grid-cols-[minmax(0,1fr)] gap-3 max-md:mt-3 md:gap-4 lg:grid-cols-3 lg:gap-5\">\n      <Fact title={schedule.title} text={schedule.text}>\n        {schedule.days.map((d, i) => (\n          <span\n            key={i}\n            className={cn(\n              \"num grid size-7 shrink-0 place-items-center rounded-md text-[11px] max-[380px]:size-6 lg:max-xl:size-6\",\n              schedule.on.includes(i) ? \"bg-white/[0.08] text-ink\" : \"text-ink-3/60\",\n            )}\n          >\n            {d}\n          </span>\n        ))}\n        <span className=\"num ml-auto text-[13px] text-ink-2\">{schedule.at}</span>\n      </Fact>\n      <Fact title={privacy.title} text={privacy.text}>\n        <span className=\"truncate text-[13px] text-ink-2\">{privacy.setting}</span>\n        {/* a switch, off */}\n        <span className=\"ml-auto flex h-5 w-9 shrink-0 items-center rounded-full bg-white/[0.08] px-0.5\">\n          <span className=\"size-4 rounded-full bg-ink-3\" />\n        </span>\n      </Fact>\n      <Fact title={languages.title} text={languages.text}>\n        {languages.codes.map((c) => (\n          <span key={c} className=\"num rounded-md bg-white/[0.06] px-1.5 py-0.5 text-[11.5px] text-ink-2\">\n            {c}\n          </span>\n        ))}\n        <span className=\"num ml-auto text-[12px] text-ink-3\">{languages.more}</span>\n      </Fact>\n    </ul>\n  )\n}\n\ntype TileProps = TileText & {\n  children: React.ReactNode\n  className?: string\n  /** the visual runs past the right edge and fades at the bottom, instead of sitting inside the tile */\n  bleed?: boolean\n}\n\n/** A product tile: a short label, one big two-tone sentence, then the visual. */\nexport function Tile({ eyebrow, title, text, children, className, bleed }: TileProps) {\n  return (\n    <div className={cn(\"tile flex flex-col overflow-hidden\", className)}>\n      <div className=\"px-8 pt-8 max-md:px-6 max-md:pt-6 md:px-10 md:pt-10\">\n        <p className=\"text-[14px] font-medium text-brand-ink\">{eyebrow}</p>\n        <h3 className=\"mt-3 max-w-[560px] text-[26px] leading-[32px] font-semibold tracking-[-0.025em] text-balance max-md:text-[21px] max-md:leading-[27px] md:text-[30px] md:leading-[36px]\">\n          <span className=\"text-ink\">{title}.</span> <span className=\"text-ink-3\">{text}</span>\n        </h3>\n      </div>\n      {bleed ? (\n        <div className=\"relative mt-10 h-[300px] overflow-hidden [mask-image:linear-gradient(to_bottom,black_60%,transparent)] max-md:mt-6 max-md:h-[236px]\">\n          <div className=\"absolute top-0 left-8 w-[118%] max-md:right-6 max-md:left-6 max-md:w-auto md:left-10\">{children}</div>\n        </div>\n      ) : (\n        <div className=\"mt-auto px-8 pt-10 pb-8 max-md:px-6 max-md:pt-6 max-md:pb-6 md:px-10 md:pb-10\">{children}</div>\n      )}\n    </div>\n  )\n}\n\n/** The product section: two tiles built from pieces of the interface, and three facts under them.\n *  Phones stack the tiles one under another. */\nexport function Features({ label, title, lead, research, sources, schedule, privacy, languages }: FeaturesContent) {\n  return (\n    <section id=\"product\" className=\"relative\">\n      <div className=\"container-x relative py-16 max-md:py-12 md:py-24\">\n        <SectionHead label={label} title={title} lead={lead} />\n        <div className=\"mt-12 grid gap-5 max-md:mt-8 max-md:gap-3 md:mt-16 lg:grid-cols-12\">\n          <Tile {...research} className=\"lg:col-span-7\" bleed>\n            <ResearchArt r={research} />\n          </Tile>\n          <Tile {...sources} className=\"lg:col-span-5\">\n            <SourcesArt s={sources} />\n          </Tile>\n        </div>\n        <Facts schedule={schedule} privacy={privacy} languages={languages} />\n      </div>\n    </section>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/midnight/features.tsx"
    },
    {
      "path": "src/components/site/section-head.tsx",
      "content": "import { cn } from \"@/lib/utils\"\n\n/** A small four-point star, the page's section mark. */\nexport function StarGlyph({ className }: { className?: string }) {\n  return (\n    <svg viewBox=\"-6 -6 12 12\" className={cn(\"size-2.5\", className)} aria-hidden=\"true\">\n      <path d=\"M0 -6Q0 0 6 0Q0 0 0 6Q0 0 -6 0Q0 0 0 -6Z\" fill=\"currentColor\" />\n    </svg>\n  )\n}\n\ntype SectionHeadProps = {\n  label: string\n  title: string\n  lead?: string\n  className?: string\n}\n\n/** Section header, centred: a star and a label, the title in Fraunces, an optional lead. */\nexport function SectionHead({ label, title, lead, className }: SectionHeadProps) {\n  return (\n    <div className={cn(\"mx-auto max-w-[760px] text-center\", className)}>\n      <p className=\"eyebrow-star\">\n        <StarGlyph />\n        {label}\n      </p>\n      <h2 className=\"h2 mt-5\">{title}</h2>\n      {lead && <p className=\"lead mx-auto mt-5 max-w-[600px]\">{lead}</p>}\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/midnight/section-head.tsx"
    },
    {
      "path": "src/components/site/cite.tsx",
      "content": "\"use client\"\n\nimport { useState } from \"react\"\n\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from \"@/components/ui/tooltip\"\n\ntype CiteProps = {\n  n: number\n  title: string\n  where: string\n  /** what screen readers hear, for example \"Source 1: 38 tickets tagged billing, Tue to Thu\" */\n  label: string\n}\n\n/** A numbered source badge. Hover or focus shows where the line came from; on a phone a tap does.\n *  The tap area is 44 px wide and one line tall, so badges on neighbouring lines don't overlap. */\nexport function Cite({ n, title, where, label }: CiteProps) {\n  const [open, setOpen] = useState(false)\n  // the trigger is the badge itself (no asChild) and the content takes only props both tooltips share (no\n  // collisionPadding: Base UI's TooltipContent does not accept it), so this works with the Radix and the Base UI tooltip alike\n  return (\n    <TooltipProvider>\n      <Tooltip open={open} onOpenChange={setOpen}>\n        <TooltipTrigger\n          type=\"button\"\n          aria-label={label}\n          onClick={(e) => {\n            // a tap opens and never toggles: on Android the tap focuses the badge first, which already opens it.\n            // A tap elsewhere, scrolling or Esc closes it. Without preventDefault the trigger would close it again\n            e.preventDefault()\n            setOpen(true)\n          }}\n          className=\"num relative ml-[0.15em] inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-brand-soft px-1 align-[0.45em] text-[10px] leading-none text-brand-ink transition-colors before:absolute before:-inset-x-3.5 before:-inset-y-1.5 before:content-[''] hover:bg-brand hover:text-paper focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none\"\n        >\n          {n}\n        </TooltipTrigger>\n        <TooltipContent side=\"top\" className=\"max-w-[min(240px,calc(100vw-24px))] flex-col items-start gap-0 text-[12px] leading-4 motion-reduce:animate-none\">\n          <span className=\"block font-medium\">{title}</span>\n          <span className=\"mt-0.5 block opacity-70\">{where}</span>\n        </TooltipContent>\n      </Tooltip>\n    </TooltipProvider>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/midnight/cite.tsx"
    },
    {
      "path": "src/lib/fill.ts",
      "content": "/** Fills {name} placeholders: fill(\"Source {n}: {title}\", { n: 1, title: \"FAQ\" }). */\nexport const fill = (text: string, values: Record<string, string | number>) =>\n  text.replace(/\\{(\\w+)\\}/g, (m, k: string) => (k in values ? String(values[k]) : m))\n",
      "type": "registry:lib",
      "target": "@lib/fill.ts"
    }
  ],
  "docs": "The block takes its words as props; the types sit at the top of the file. Name the theme in the same command, for example: npx shadcn@latest add https://midnight-lite.vilqor.com/r/midnight-theme.json https://midnight-lite.vilqor.com/r/midnight-features.json. A theme that only comes in as a dependency adds its colours but keeps your existing --background, --primary and fonts. If the page is not night-blue, run: npx shadcn@latest add https://midnight-lite.vilqor.com/r/midnight-theme.json. Works with the Radix and the Base UI styles of shadcn/ui; React Aria (aria-nova) is not supported yet. No TooltipProvider needed: each source badge brings its own.\nThe full Midnight template, with seven more sections, forms and analytics: https://templates.vilqor.com/midnight?ref=shadcn",
  "categories": [
    "features"
  ],
  "type": "registry:block"
}