{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "text-wall",
  "type": "registry:ui",
  "title": "Text Wall",
  "description": "The room's short answers on a shared screen: \"what would you ask someone your age who lives there?\". New posts rise in at the top; the presenter can put one in the spotlight, large, above the rest. Phones send with `QuestionAsk` (relabelled: \"Your answer\"…",
  "author": "ofri-peretz <https://github.com/ofri-peretz>",
  "categories": [
    "games",
    "game"
  ],
  "dependencies": [],
  "registryDependencies": [
    "https://ds.interlace.tools/r/interlace-base.json",
    "https://ds.interlace.tools/r/cn.json",
    "https://ds.interlace.tools/r/flip-group.json",
    "https://ds.interlace.tools/r/motion-token.json",
    "https://ds.interlace.tools/r/use-reduced-motion.json"
  ],
  "files": [
    {
      "path": "registry/interlace-ui/games/text-wall.tsx",
      "target": "components/ui/games/text-wall.tsx",
      "type": "registry:ui",
      "content": "'use client';\n\nimport * as React from 'react';\n\n// @interlace/text-wall v1.0.1 — Interlace design system.\n// Docs, props and live preview: https://ds.interlace.tools/c/text-wall\n// What changed since: https://ds.interlace.tools/c/text-wall#history\n// Generated banner — keep it, the upgrade diff reads this version.\n\n/**\n * @interlace/ui — TextWall\n *\n * The room's short answers on a shared screen: \"what would you ask someone\n * your age who lives there?\". New posts rise in at the top; the presenter\n * can put one in the spotlight, large, above the rest. Phones send with\n * `QuestionAsk` (relabelled: \"Your answer\", \"Post\"); posts go through the\n * same checks and moderation queue as the Q&A board (`question-board-model`\n * with `QuestionQueue`), so nothing unreviewed reaches the screen.\n *\n * ## Anatomy\n *\n *   TextWall                     (section — data-slot=\"text-wall\")\n *     ├─ figure                  (data-slot=\"text-wall-spotlight\": the featured post, large)\n *     ├─ p                       (data-slot=\"text-wall-count\": \"24 answers\")\n *     └─ ul                      (FlipGroup — data-slot=\"text-wall-list\": newest first, row by row)\n *          └─ li × n             (data-slot=\"text-wall-post\")\n *\n * The wall is not a live region: a screen reader user reads it at their\n * pace, and the count says how many there are.\n *\n * ## Motion\n *\n * A new post rises in at the top (200ms) and the others glide one place\n * along (FlipGroup, 250ms); a post moving into the spotlight scales in\n * (250ms). Under reduced motion they\n * simply appear.\n *\n * ## MIN_VIEWPORT — 320\n *\n * | Rule | Concept                   | Where in this file                               |\n * | ---- | ------------------------- | ------------------------------------------------ |\n * | R4   | Extends native el         | `section` props                                  |\n * | R6   | data-slot per part        | text-wall / -spotlight / -count / -list / -post  |\n * | R7   | cn + ...rest              | `cn(…, className)` + `{...props}`                |\n * | R8   | Enums, not booleans       | `size`                                           |\n * | R14  | Declares min viewport     | `data-min-viewport` + exported const             |\n * | R26  | A11y                      | a list in reading order; count as text; not live  |\n */\n\nimport { FlipGroup } from '@/components/ui/effects/flip-group';\nimport { cn } from '@/lib/utils';\nimport { motionEase } from '@/lib/motion-token';\nimport { useReducedMotion } from '@/hooks/use-reduced-motion';\n\nexport const MIN_VIEWPORT = 320 as const;\n\ninterface WallPost {\n  id: string;\n  text: string;\n  /** When it was posted, ms; newest show first. */\n  at: number;\n}\n\ninterface TextWallLabels {\n  /** @default (n, f) => `${f} ${n === 1 ? 'answer' : 'answers'}` */\n  count?: (n: number, formatted: string) => string;\n  /** @default 'Nothing here yet.' */\n  empty?: string;\n}\n\ntype TextWallProps = Omit<React.ComponentProps<'section'>, 'children'> & {\n  posts: readonly WallPost[];\n  /** A post to feature, large, above the wall. */\n  spotlight?: string | null;\n  /** The most posts on the wall; older ones leave. @default 40 */\n  max?: number;\n  /** `stage` for a shared screen. @default 'default' */\n  size?: 'default' | 'stage';\n  locale?: string;\n  labels?: TextWallLabels;\n};\n\nfunction Post({ id, text, enter }: { id: string; text: string; enter: boolean }) {\n  const ref = React.useRef<HTMLLIElement>(null);\n  // Runs once, on mount: only a post that arrives after the wall loaded rises in.\n  const enterOnMount = React.useRef(enter);\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!enterOnMount.current || !el || typeof el.animate !== 'function') return;\n    el.animate(\n      [\n        { transform: 'translateY(12px)', opacity: 0 },\n        { transform: 'translateY(0)', opacity: 1 },\n      ],\n      {\n        duration: 200,\n        easing: motionEase(el, 'enter'),\n      },\n    );\n  }, []);\n  return (\n    <li data-slot=\"text-wall-post\" data-flip-id={id} ref={ref} className=\"bg-card rounded-lg border p-4 text-pretty\">\n      {text}\n    </li>\n  );\n}\n\nfunction TextWall({\n  posts,\n  spotlight = null,\n  max = 40,\n  size = 'default',\n  locale,\n  labels,\n  className,\n  ...props\n}: TextWallProps) {\n  const reduced = useReducedMotion();\n  const nf = React.useMemo(() => new Intl.NumberFormat(locale), [locale]);\n  const stage = size === 'stage';\n  const featured = spotlight ? posts.find((p) => p.id === spotlight) : undefined;\n  const shown = [...posts]\n    .filter((p) => p.id !== featured?.id)\n    .sort((a, b) => b.at - a.at)\n    .slice(0, Math.max(0, max));\n  const loaded = React.useRef<Set<string> | null>(null);\n  if (loaded.current === null) loaded.current = new Set(posts.map((p) => p.id));\n  const spotRef = React.useRef<HTMLElement>(null);\n  // The spotlight on the wall at load stays still, like the posts: only a later one scales in.\n  const firstSpot = React.useRef<string | undefined | null>(null);\n  if (firstSpot.current === null) firstSpot.current = featured?.id;\n\n  React.useEffect(() => {\n    const el = spotRef.current;\n    if (featured?.id === firstSpot.current) return;\n    firstSpot.current = undefined;\n    if (!el || !featured || reduced || typeof el.animate !== 'function') return;\n    el.animate(\n      [\n        { transform: 'scale(0.96)', opacity: 0 },\n        { transform: 'scale(1)', opacity: 1 },\n      ],\n      {\n        duration: 250,\n        easing: motionEase(el, 'enter'),\n      },\n    );\n  }, [featured?.id, reduced]);\n\n  const count = (labels?.count ?? ((n: number, f: string) => `${f} ${n === 1 ? 'answer' : 'answers'}`))(\n    posts.length,\n    nf.format(posts.length),\n  );\n\n  return (\n    <section\n      data-slot=\"text-wall\"\n      data-min-viewport={String(MIN_VIEWPORT)}\n      className={cn('@container grid gap-4', className)}\n      {...props}\n    >\n      {featured ? (\n        <figure\n          ref={spotRef}\n          data-slot=\"text-wall-spotlight\"\n          className={cn(\n            'border-primary bg-primary/5 font-heading rounded-xl border-2 p-6 font-semibold text-balance',\n            stage ? 'text-section' : 'text-2xl',\n          )}\n        >\n          <blockquote>{featured.text}</blockquote>\n        </figure>\n      ) : null}\n      <p data-slot=\"text-wall-count\" className={cn('text-muted-foreground', stage ? 'text-lg' : 'text-sm')}>\n        {posts.length === 0 ? (labels?.empty ?? 'Nothing here yet.') : count}\n      </p>\n      <FlipGroup\n        render={<ul />}\n        duration={250}\n        data-slot=\"text-wall-list\"\n        className={cn('grid items-start gap-3 @md:grid-cols-2 @4xl:grid-cols-3', stage ? 'text-lg' : 'text-base')}\n      >\n        {shown.map((p) => (\n          <Post key={p.id} id={p.id} text={p.text} enter={!reduced && !(loaded.current?.has(p.id) ?? false)} />\n        ))}\n      </FlipGroup>\n    </section>\n  );\n}\nTextWall.displayName = 'TextWall';\n\nexport { TextWall };\nexport type { TextWallProps, TextWallLabels, WallPost };\n"
    }
  ],
  "meta": {
    "tier": "game",
    "client": true,
    "minViewport": 320,
    "loading": false,
    "version": "1.0.1",
    "since": "2.0.0"
  },
  "docs": "## @interlace/text-wall\n\nInstalled to `components/ui/games/text-wall.tsx`.\n\n```tsx\nimport { /* … */ } from '@/components/ui/games/text-wall';\n```\n\nProps, a11y contract, live preview and source: https://ds.interlace.tools/c/text-wall\n\nRequires the `@interlace/interlace-base` CSS baseline (installed automatically as a registry dependency). For the Interlace look, also add `@interlace/theme`."
}
