{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "project-status-tile",
  "title": "Project Status Tile",
  "description": "A compact project card for status boards: health you can change in place, progress with its milestones, who's on it and when it's due.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/new-york/project-status-tile/project-status-tile.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type ProjectHealth = \"on-track\" | \"at-risk\" | \"off-track\" | \"done\";\n\nexport interface ProjectMilestone {\n  id: string;\n  label: string;\n  /** Short date, e.g. \"14 Mar\". */\n  date: string;\n  /** Where it sits along the project, from 0 to 100. */\n  at: number;\n  done?: boolean;\n}\n\nexport interface ProjectStatusTileProps extends Omit<\n  React.ComponentPropsWithoutRef<\"article\">,\n  \"title\"\n> {\n  theme?: \"dark\" | \"light\";\n  name?: string;\n  team?: string;\n  health?: ProjectHealth;\n  tasksDone?: number;\n  tasksTotal?: number;\n  milestones?: ProjectMilestone[];\n  /** Initials of the people on it. */\n  people?: string[];\n  /** Short date, e.g. \"28 Mar\". */\n  due?: string;\n  /** e.g. \"2d ago\". */\n  updated?: string;\n  onHealthChange?: (health: ProjectHealth) => void;\n}\n\nconst FONT =\n  '\"Inter Variable\", Inter, \"SF Pro Display\", -apple-system, BlinkMacSystemFont, sans-serif';\nconst RING = \"outline-none focus-visible:ring-2 focus-visible:ring-[#5E6AD2]\";\nconst BAR_H = 22;\n\nconst HEALTH: Record<ProjectHealth, { label: string; color: string }> = {\n  \"on-track\": { label: \"On track\", color: \"#5E6AD2\" },\n  \"at-risk\": { label: \"At risk\", color: \"#FC7840\" },\n  \"off-track\": { label: \"Off track\", color: \"#EB5757\" },\n  done: { label: \"Done\", color: \"#27A644\" },\n};\nconst ORDER: ProjectHealth[] = [\"on-track\", \"at-risk\", \"off-track\", \"done\"];\n\nconst PALETTES = {\n  dark: {\n    card: \"#0F1011\",\n    menu: \"#161718\",\n    tile: \"#161718\",\n    border: \"rgba(255,255,255,0.08)\",\n    track: \"rgba(255,255,255,0.1)\",\n    text: \"#F7F8F8\",\n    soft: \"#D0D6E0\",\n    sub: \"#8A8F98\",\n    faint: \"#62666D\",\n    chip: \"rgba(255,255,255,0.05)\",\n    hover: \"rgba(255,255,255,0.05)\",\n    shadow: \"0 12px 32px rgba(0,0,0,0.5)\",\n  },\n  light: {\n    card: \"#FFFFFF\",\n    menu: \"#FFFFFF\",\n    tile: \"#F7F8F8\",\n    border: \"rgba(8,9,10,0.1)\",\n    track: \"rgba(8,9,10,0.1)\",\n    text: \"#08090A\",\n    soft: \"#3C3F44\",\n    sub: \"#62666D\",\n    faint: \"#8A8F98\",\n    chip: \"rgba(8,9,10,0.04)\",\n    hover: \"rgba(8,9,10,0.04)\",\n    shadow: \"0 12px 32px rgba(8,9,10,0.12)\",\n  },\n};\n\nconst DEFAULT_MILESTONES: ProjectMilestone[] = [\n  { id: \"spec\", label: \"Spec signed off\", date: \"2 Mar\", at: 15, done: true },\n  {\n    id: \"design\",\n    label: \"Designs approved\",\n    date: \"9 Mar\",\n    at: 38,\n    done: true,\n  },\n  { id: \"beta\", label: \"Beta to 50 customers\", date: \"20 Mar\", at: 70 },\n  { id: \"launch\", label: \"Public launch\", date: \"28 Mar\", at: 100 },\n];\n\nconst DEFAULT_PEOPLE = [\"ML\", \"JR\", \"PN\", \"AS\"];\n\nfunction useWidth<T extends HTMLElement>(fallback: number) {\n  const ref = React.useRef<T>(null);\n  const [width, setWidth] = React.useState(fallback);\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const ro = new ResizeObserver(([entry]) => {\n      setWidth(Math.round(entry.contentRect.width));\n    });\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, []);\n  return [ref, width] as const;\n}\n\n/** Drawn as SVG, because a tiny border-radius circle turns lumpy on 1x screens. */\nfunction Dot({ size, color }: { size: number; color: string }) {\n  const r = size / 2;\n  return (\n    <svg\n      aria-hidden=\"true\"\n      width={size}\n      height={size}\n      viewBox={`0 0 ${size} ${size}`}\n      className=\"block shrink-0\"\n    >\n      <circle\n        cx={r}\n        cy={r}\n        r={r}\n        className=\"motion-safe:transition-[fill] motion-safe:duration-200\"\n        style={{ fill: color }}\n      />\n    </svg>\n  );\n}\n\nexport function ProjectStatusTile({\n  theme = \"dark\",\n  name = \"Pricing page refresh\",\n  team = \"Growth\",\n  health = \"on-track\",\n  tasksDone = 12,\n  tasksTotal = 18,\n  milestones = DEFAULT_MILESTONES,\n  people = DEFAULT_PEOPLE,\n  due = \"28 Mar\",\n  updated = \"2d ago\",\n  onHealthChange,\n  className,\n  style,\n  ...rest\n}: ProjectStatusTileProps) {\n  const c = PALETTES[theme];\n  const [state, setState] = React.useState(health);\n  const [menu, setMenu] = React.useState(false);\n  const [focus, setFocus] = React.useState<string | null>(null);\n  const [barRef, width] = useWidth<HTMLDivElement>(280);\n  const rootRef = React.useRef<HTMLElement>(null);\n  const triggerRef = React.useRef<HTMLButtonElement>(null);\n  const menuId = React.useId();\n\n  const look = HEALTH[state];\n  const share = tasksTotal ? tasksDone / tasksTotal : 0;\n  const percent = state === \"done\" ? 100 : Math.round(share * 100);\n  const nextUp = milestones.find((m) => !m.done);\n  const shown = milestones.find((m) => m.id === focus) ?? nextUp;\n\n  React.useEffect(() => {\n    if (!menu) return;\n    const onDown = (e: PointerEvent) => {\n      if (!rootRef.current?.contains(e.target as Node)) setMenu(false);\n    };\n    // On the document: Safari doesn't focus a button when it's clicked, so the key wouldn't reach the card.\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key !== \"Escape\") return;\n      setMenu(false);\n      triggerRef.current?.focus();\n    };\n    document.addEventListener(\"pointerdown\", onDown);\n    document.addEventListener(\"keydown\", onKey);\n    return () => {\n      document.removeEventListener(\"pointerdown\", onDown);\n      document.removeEventListener(\"keydown\", onKey);\n    };\n  }, [menu]);\n\n  const pick = (next: ProjectHealth) => {\n    setState(next);\n    setMenu(false);\n    triggerRef.current?.focus();\n    onHealthChange?.(next);\n  };\n\n  const x = (at: number) =>\n    Math.round(6 + (Math.min(100, Math.max(0, at)) / 100) * (width - 12));\n  const mid = BAR_H / 2;\n\n  return (\n    <article\n      ref={rootRef}\n      aria-label={name}\n      className={`relative flex w-full flex-col rounded-2xl border p-4 ${className ?? \"\"}`}\n      style={{\n        background: c.card,\n        borderColor: c.border,\n        color: c.text,\n        fontFamily: FONT,\n        ...style,\n      }}\n      {...rest}\n    >\n      <header className=\"flex items-start gap-3\">\n        <span\n          aria-hidden=\"true\"\n          className=\"flex shrink-0 items-center justify-center rounded-lg text-[14px] leading-[20px] font-[590]\"\n          style={{\n            width: 34,\n            height: 34,\n            background: c.tile,\n            color: look.color,\n          }}\n        >\n          {name.slice(0, 1)}\n        </span>\n        <div className=\"min-w-0 flex-1\">\n          <h3 className=\"m-0 line-clamp-2 text-[15px] leading-[20px] font-[590] tracking-[-0.012em]\">\n            {name}\n          </h3>\n          <p\n            className=\"m-0 truncate text-[12.5px] leading-[16px] tracking-[-0.008em]\"\n            style={{ color: c.faint }}\n          >\n            {team}\n          </p>\n        </div>\n        <button\n          ref={triggerRef}\n          type=\"button\"\n          data-status=\"\"\n          aria-haspopup=\"menu\"\n          aria-expanded={menu}\n          aria-controls={menuId}\n          onClick={() => setMenu(!menu)}\n          className={`flex h-7 shrink-0 cursor-pointer items-center gap-1.5 rounded-full border-0 pr-2 pl-2.5 text-[12.5px] leading-[18px] font-[510] tracking-[-0.008em] ${RING}`}\n          style={{ background: c.chip, color: c.soft }}\n        >\n          <Dot size={7} color={look.color} />\n          {look.label}\n          <svg\n            aria-hidden=\"true\"\n            viewBox=\"0 0 16 16\"\n            width=\"12\"\n            height=\"12\"\n            fill=\"none\"\n            className=\"block motion-safe:transition-transform motion-safe:duration-150\"\n            style={{ transform: menu ? \"rotate(180deg)\" : \"none\" }}\n          >\n            <path\n              d=\"m4 6 4 4 4-4\"\n              stroke=\"currentColor\"\n              strokeWidth=\"1.5\"\n              strokeLinecap=\"round\"\n              strokeLinejoin=\"round\"\n            />\n          </svg>\n        </button>\n      </header>\n\n      {/* The menu floats over the tile, so opening it never changes the tile's height. */}\n      <div\n        id={menuId}\n        role=\"menu\"\n        aria-label=\"Project health\"\n        aria-hidden={!menu}\n        inert={!menu}\n        className=\"absolute z-10 rounded-xl border p-1 motion-safe:transition-[opacity,transform] motion-safe:duration-150\"\n        style={{\n          top: 50,\n          right: 16,\n          width: 156,\n          background: c.menu,\n          borderColor: c.border,\n          boxShadow: c.shadow,\n          opacity: menu ? 1 : 0,\n          visibility: menu ? \"visible\" : \"hidden\",\n          transform: menu ? \"none\" : \"translateY(-4px)\",\n        }}\n      >\n        {ORDER.map((h) => (\n          <button\n            key={h}\n            type=\"button\"\n            role=\"menuitemradio\"\n            aria-checked={h === state}\n            data-health={h}\n            onClick={() => pick(h)}\n            className={`flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg border-0 bg-transparent px-2.5 text-left text-[13px] leading-[20px] tracking-[-0.011em] ${RING}`}\n            style={{\n              color: c.text,\n              background: h === state ? c.hover : \"transparent\",\n            }}\n          >\n            <Dot size={7} color={HEALTH[h].color} />\n            <span className=\"flex-1\">{HEALTH[h].label}</span>\n            {h === state && (\n              <svg\n                aria-hidden=\"true\"\n                viewBox=\"0 0 16 16\"\n                width=\"14\"\n                height=\"14\"\n                fill=\"none\"\n                className=\"block\"\n              >\n                <path\n                  d=\"m3.5 8.5 3 3 6-7\"\n                  stroke={c.sub}\n                  strokeWidth=\"1.5\"\n                  strokeLinecap=\"round\"\n                  strokeLinejoin=\"round\"\n                />\n              </svg>\n            )}\n          </button>\n        ))}\n      </div>\n\n      <div className=\"mt-4 flex items-baseline justify-between gap-3\">\n        <p\n          aria-live=\"polite\"\n          className=\"m-0 text-[28px] leading-[32px] font-[510] tracking-[-0.022em] tabular-nums\"\n        >\n          {percent}%\n        </p>\n        <p\n          className=\"m-0 text-[12.5px] leading-[18px] tracking-[-0.008em] tabular-nums\"\n          style={{ color: c.sub }}\n        >\n          {state === \"done\" ? tasksTotal : tasksDone} of {tasksTotal} tasks\n        </p>\n      </div>\n\n      <div ref={barRef} className=\"mt-2 w-full\" style={{ height: BAR_H }}>\n        <svg\n          role=\"group\"\n          aria-label=\"Milestones\"\n          width={width}\n          height={BAR_H}\n          className=\"block overflow-visible\"\n          onPointerLeave={() => setFocus(null)}\n        >\n          <rect\n            x={6}\n            y={mid - 2}\n            width={Math.max(0, width - 12)}\n            height={4}\n            rx={2}\n            fill={c.track}\n          />\n          <rect\n            x={6}\n            y={mid - 2}\n            width={Math.max(0, x(percent) - 6)}\n            height={4}\n            rx={2}\n            fill={look.color}\n            className=\"motion-safe:transition-[width,fill] motion-safe:duration-300\"\n          />\n          {milestones.map((m) => {\n            const done = m.done || state === \"done\";\n            const next = m.id === nextUp?.id && state !== \"done\";\n            return (\n              <g\n                key={m.id}\n                data-milestone={m.id}\n                tabIndex={0}\n                role=\"button\"\n                aria-label={`${m.label}, ${m.date}${done ? \", done\" : \"\"}`}\n                onPointerEnter={() => setFocus(m.id)}\n                onFocus={() => setFocus(m.id)}\n                onBlur={() => setFocus(null)}\n                onClick={() => setFocus(m.id)}\n                className=\"cursor-pointer outline-none [&:focus-visible>circle:last-child]:[stroke:#5E6AD2]\"\n              >\n                <circle cx={x(m.at)} cy={mid} r={11} fill=\"transparent\" />\n                <circle\n                  cx={x(m.at)}\n                  cy={mid}\n                  r={next ? 5.5 : 4.5}\n                  fill={done ? look.color : c.card}\n                  stroke={done ? c.card : next ? look.color : c.faint}\n                  strokeWidth={done ? 2 : 1.5}\n                  className=\"motion-safe:transition-[fill,stroke] motion-safe:duration-200\"\n                />\n              </g>\n            );\n          })}\n        </svg>\n      </div>\n\n      <p\n        className=\"m-0 mt-1.5 flex items-center justify-between gap-3 text-[12.5px] leading-[18px] tracking-[-0.008em]\"\n        style={{ height: 18 }}\n      >\n        <span className=\"min-w-0 truncate\" style={{ color: c.soft }}>\n          {state === \"done\"\n            ? \"Every milestone met\"\n            : focus\n              ? shown?.label\n              : `Next: ${shown?.label ?? \"Nothing left\"}`}\n        </span>\n        <span className=\"shrink-0 tabular-nums\" style={{ color: c.faint }}>\n          {state === \"done\" ? \"\" : shown?.date}\n        </span>\n      </p>\n\n      <footer\n        className=\"mt-4 flex items-center justify-between gap-3 border-t pt-3\"\n        style={{ borderColor: c.border }}\n      >\n        <span\n          className=\"flex items-center\"\n          aria-label={`${people.length} people`}\n        >\n          {people.slice(0, 4).map((p, i) => (\n            <svg\n              key={p}\n              aria-hidden=\"true\"\n              width=\"24\"\n              height=\"24\"\n              viewBox=\"0 0 24 24\"\n              className=\"block\"\n              style={{ marginLeft: i ? -6 : 0 }}\n            >\n              <circle\n                cx=\"12\"\n                cy=\"12\"\n                r=\"11.25\"\n                fill={c.tile}\n                stroke={c.card}\n                strokeWidth=\"1.5\"\n              />\n              <text\n                x=\"12\"\n                y=\"15.5\"\n                textAnchor=\"middle\"\n                fontSize=\"9\"\n                fontWeight=\"590\"\n                fill={c.soft}\n              >\n                {p}\n              </text>\n            </svg>\n          ))}\n          {people.length > 4 && (\n            <span\n              className=\"ml-1.5 text-[12px] leading-[16px] tabular-nums\"\n              style={{ color: c.faint }}\n            >\n              +{people.length - 4}\n            </span>\n          )}\n        </span>\n        <span\n          className=\"text-[12.5px] leading-[18px] tracking-[-0.008em] tabular-nums\"\n          style={{ color: c.sub }}\n        >\n          Due {due}\n          <span style={{ color: c.faint }}>, updated {updated}</span>\n        </span>\n      </footer>\n    </article>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}