{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "standings-feature",
  "type": "registry:block",
  "title": "Standings Feature",
  "description": "Feature Section built with Standings (animated leaderboard): apps race to rank for each keyword. A take on the leaderboard (ranking). A keyword-tracking feature section. On the left, the keywords an app could rank for, each with its monthly searches, the app's rank and how far it moved; on the right, the race for the picked keyword. Pick another and the same six apps slide to their new places, with a suggestion for how to climb under them. The keywords play by themselves, a line under the current one filling like a timer, until the visitor picks one.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "blocks",
    "feature-sections",
    "features",
    "leaderboard"
  ],
  "docs": "Live preview and the components it's built with: https://keyframeui.com/blocks/feature-sections/standings-feature",
  "registryDependencies": [
    "https://keyframeui.com/r/standings.json",
    "utils"
  ],
  "files": [
    {
      "path": "components/standings-feature.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"@/lib/utils\";\nimport { Standings, type StandingsEntry } from \"@/components/ui/standings\";\n\n/* ── Content ─────────────────────────────────────────────────\n * Everything you'd change to make the section yours: the copy,\n * the apps, and the keywords. Each keyword holds every app's\n * share of the installs that come from that search; pick one\n * and the apps race to its order. Your rank in the list is\n * worked out from the same numbers, so the two always agree.\n * ─────────────────────────────────────────────────────────── */\n\n/** The one accent: buttons, your row, the picked keyword and its timer. */\nconst ACCENT = \"#ff5a1f\";\n\nconst BADGE = \"Keyword tracking\";\nconst HEADLINE = \"See which searches you can win.\";\nconst SUBLINE =\n  \"Every keyword your app could rank for, how many people search it each month, and who's ahead of you. Pick one to watch its race.\";\nconst PRIMARY_CTA = { label: \"Track my keywords\", href: \"#start\" };\nconst SECONDARY_CTA = { label: \"See a sample report\", href: \"#sample\" };\nconst LIST = { title: \"Keywords\", note: \"5 of 214 · by searches\", columns: [\"Keyword\", \"Searches\", \"Rank\", \"30 days\"] };\nconst PANEL = { prefix: \"Results for\", unit: \"Share of installs from this search\" };\nconst SOURCES = { label: \"Rankings from\", items: [\"App Store\", \"Google Play\", \"Any CSV\"] };\n/** ms each keyword stays up while the list plays by itself, until a visitor picks one. */\nconst CYCLE = 4200;\n\ntype App = { id: string; label: string; detail: string; from: string; to: string; you?: boolean };\n\nconst APPS: App[] = [\n  { id: \"fieldnote\", label: \"Fieldnote\", detail: \"Notes that file themselves\", from: \"#ff8a3d\", to: \"#ff3d00\", you: true },\n  { id: \"tally\", label: \"Tally Notes\", detail: \"Notes & lists\", from: \"#4f8bff\", to: \"#1d4ed8\" },\n  { id: \"scribe\", label: \"Scribe\", detail: \"Voice to text\", from: \"#a78bfa\", to: \"#6d28d9\" },\n  { id: \"margin\", label: \"Margin\", detail: \"Linked notes\", from: \"#34d399\", to: \"#059669\" },\n  { id: \"quillbox\", label: \"Quillbox\", detail: \"Handwriting\", from: \"#fb7185\", to: \"#e11d48\" },\n  { id: \"inkpad\", label: \"Inkpad\", detail: \"Sketch & annotate\", from: \"#fbbf24\", to: \"#ea580c\" },\n];\n\ntype Keyword = {\n  id: string;\n  label: string;\n  /** Monthly searches. */\n  searches: number;\n  /** Places your rank moved in the last 30 days. */\n  moved: number;\n  /** Each app's share of the installs from this search, in percent. */\n  shares: Record<string, number>;\n  /** What Rung suggests changing to climb this one. */\n  tip: string;\n};\n\nconst KEYWORDS: Keyword[] = [\n  {\n    id: \"notes-app\",\n    label: \"notes app\",\n    searches: 90_000,\n    moved: 2,\n    shares: { tally: 31, scribe: 24, fieldnote: 17, margin: 12, quillbox: 9, inkpad: 7 },\n    tip: \"Put “notes app” in your subtitle. The two apps above you both have it.\",\n  },\n  {\n    id: \"meeting-notes\",\n    label: \"meeting notes\",\n    searches: 36_000,\n    moved: 1,\n    shares: { fieldnote: 34, scribe: 22, tally: 18, margin: 11, inkpad: 9, quillbox: 6 },\n    tip: \"You lead this one. Keep the meeting screenshot first in your gallery.\",\n  },\n  {\n    id: \"voice-memo\",\n    label: \"voice memo to text\",\n    searches: 22_000,\n    moved: 4,\n    shares: { scribe: 29, fieldnote: 27, quillbox: 19, tally: 12, inkpad: 8, margin: 5 },\n    tip: \"Two points behind Scribe. Mention transcription in the first line of your description.\",\n  },\n  {\n    id: \"second-brain\",\n    label: \"second brain\",\n    searches: 14_000,\n    moved: -1,\n    shares: { margin: 36, tally: 21, scribe: 17, inkpad: 12, fieldnote: 9, quillbox: 5 },\n    tip: \"Margin owns this term. Spend the keyword field on “meeting notes” instead.\",\n  },\n  {\n    id: \"handwriting\",\n    label: \"handwriting notes\",\n    searches: 9_000,\n    moved: 0,\n    shares: { inkpad: 38, quillbox: 23, fieldnote: 18, scribe: 11, tally: 6, margin: 4 },\n    tip: \"Holding third. A screenshot of pencil input could take second from Quillbox.\",\n  },\n];\n\nconst compact = new Intl.NumberFormat(\"en-US\", { notation: \"compact\" });\nconst top = Math.max(...KEYWORDS.map((k) => k.searches));\nconst youId = APPS.find((app) => app.you)?.id ?? \"\";\n\n/** Your place for a keyword, from its shares. */\nfunction placeFor(keyword: Keyword) {\n  return [...APPS].sort((a, b) => keyword.shares[b.id] - keyword.shares[a.id]).findIndex((app) => app.id === youId) + 1;\n}\n\nconst reducedQuery = \"(prefers-reduced-motion: reduce)\";\n\n/* ── Section ─────────────────────────────────────────────── */\n\nexport function StandingsFeature() {\n  const [active, setActive] = React.useState(0);\n  const [picked, setPicked] = React.useState(false);\n  const [auto, setAuto] = React.useState(false);\n  const sectionRef = React.useRef<HTMLElement>(null);\n  const tabs = React.useRef<(HTMLButtonElement | null)[]>([]);\n  const timer = React.useRef<HTMLSpanElement>(null);\n  const keyword = KEYWORDS[active];\n\n  // The list plays by itself while it's on screen, until a visitor picks a keyword.\n  React.useEffect(() => {\n    const el = sectionRef.current;\n    if (!el || picked || window.matchMedia(reducedQuery).matches) return;\n    const io = new IntersectionObserver(([entry]) => setAuto(entry.isIntersecting), { threshold: 0.35 });\n    io.observe(el);\n    return () => io.disconnect();\n  }, [picked]);\n\n  React.useEffect(() => {\n    if (!auto || picked) return;\n    const bar = timer.current?.animate([{ transform: \"scaleX(0)\" }, { transform: \"scaleX(1)\" }], {\n      duration: CYCLE,\n      easing: \"linear\",\n      fill: \"forwards\",\n    });\n    const id = window.setTimeout(() => setActive((i) => (i + 1) % KEYWORDS.length), CYCLE);\n    return () => {\n      window.clearTimeout(id);\n      bar?.cancel();\n    };\n  }, [auto, picked, active]);\n\n  const pick = (i: number) => {\n    setPicked(true);\n    setActive(i);\n  };\n\n  const onKeyDown = (e: React.KeyboardEvent) => {\n    const step = e.key === \"ArrowDown\" ? 1 : e.key === \"ArrowUp\" ? -1 : 0;\n    if (!step) return;\n    e.preventDefault();\n    const next = (active + step + KEYWORDS.length) % KEYWORDS.length;\n    pick(next);\n    tabs.current[next]?.focus();\n  };\n\n  const entries = React.useMemo<StandingsEntry[]>(\n    () =>\n      APPS.map((app) => ({\n        id: app.id,\n        label: app.label,\n        detail: app.detail,\n        you: app.you,\n        value: keyword.shares[app.id],\n        icon: (\n          <span\n            className=\"grid size-full place-items-center text-[13px] font-semibold text-white\"\n            style={{ backgroundImage: `linear-gradient(145deg, ${app.from}, ${app.to})` }}\n          >\n            {app.label[0]}\n          </span>\n        ),\n      })),\n    [keyword],\n  );\n\n  return (\n    <section\n      ref={sectionRef}\n      style={{ \"--accent\": ACCENT } as React.CSSProperties}\n      className=\"bg-[#f5f5f6] px-3 py-20 text-zinc-950 sm:px-4 sm:py-28 dark:bg-[#09090b] dark:text-white\"\n    >\n      <div className=\"mx-auto max-w-2xl px-3 text-center\">\n        <p className=\"inline-flex items-center gap-1.5 rounded-full bg-white px-2.5 py-1 text-xs font-medium text-zinc-700 shadow-[0_0_0_1px_rgb(0_0_0/0.06)] dark:bg-white/[0.06] dark:text-zinc-300 dark:shadow-[0_0_0_1px_rgb(255_255_255/0.08)]\">\n          <SearchGlyph className=\"size-3.5 text-(--accent)\" />\n          {BADGE}\n        </p>\n        <h2 className=\"mt-5 text-[2rem] leading-[1.1] font-semibold tracking-[-0.035em] text-balance sm:text-5xl\">{HEADLINE}</h2>\n        <p className=\"mx-auto mt-4 max-w-lg text-[15px] leading-relaxed text-pretty text-zinc-600 sm:text-base dark:text-zinc-400\">{SUBLINE}</p>\n        <div className=\"mt-7 flex flex-wrap items-center justify-center gap-2.5\">\n          <a\n            href={PRIMARY_CTA.href}\n            className=\"flex h-10 items-center gap-1 rounded-full bg-(--accent) pr-3.5 pl-4 text-sm font-semibold text-white transition-[filter,transform] duration-150 hover:brightness-110 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--accent) active:scale-[0.97]\"\n          >\n            {PRIMARY_CTA.label}\n            <Chevron className=\"size-3.5\" />\n          </a>\n          <a\n            href={SECONDARY_CTA.href}\n            className=\"flex h-10 items-center rounded-full bg-white px-4 text-sm font-semibold shadow-[0_1px_2px_rgb(0_0_0/0.05),0_0_0_1px_rgb(0_0_0/0.08)] transition-colors duration-150 hover:bg-zinc-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--accent) dark:bg-white/[0.06] dark:shadow-[0_0_0_1px_rgb(255_255_255/0.1)] dark:hover:bg-white/[0.09]\"\n          >\n            {SECONDARY_CTA.label}\n          </a>\n        </div>\n      </div>\n\n      <div className=\"mx-auto mt-14 grid max-w-6xl overflow-hidden rounded-[24px] bg-white shadow-[0_1px_2px_rgb(0_0_0/0.04),0_0_0_1px_rgb(0_0_0/0.05),0_24px_60px_-32px_rgb(0_0_0/0.2)] lg:grid-cols-[minmax(0,1.1fr)_minmax(0,1fr)] dark:bg-[#111113] dark:shadow-[0_0_0_1px_rgb(255_255_255/0.07)]\">\n        {/* The keywords: a vertical tab list that drives the race on the right. */}\n        <div className=\"flex flex-col border-b border-zinc-950/[0.07] p-2 sm:p-3 lg:border-r lg:border-b-0 dark:border-white/[0.07]\">\n          <div className=\"flex items-baseline justify-between px-3 pt-2 pb-3\">\n            <p className=\"text-[13px] font-semibold tracking-[-0.01em]\">{LIST.title}</p>\n            <p className=\"text-xs text-zinc-500 dark:text-zinc-400\">{LIST.note}</p>\n          </div>\n          <div className=\"grid grid-cols-[minmax(0,1fr)_5.5rem_3rem] gap-3 border-b border-zinc-950/[0.07] px-3 pb-2 text-[11px] font-medium text-zinc-500 sm:grid-cols-[minmax(0,1fr)_7.5rem_3rem_3.5rem] dark:border-white/[0.07] dark:text-zinc-400\">\n            {LIST.columns.map((column, i) => (\n              <span key={column} className={cn(i > 1 && \"text-right\", i === 3 && \"hidden sm:block\")}>\n                {column}\n              </span>\n            ))}\n          </div>\n          <div role=\"tablist\" aria-orientation=\"vertical\" aria-label={LIST.title} onKeyDown={onKeyDown} className=\"mt-1 flex flex-col gap-0.5\">\n            {KEYWORDS.map((k, i) => {\n              const selected = i === active;\n              const place = placeFor(k);\n              const filled = Math.max(1, Math.round((k.searches / top) * 5));\n              return (\n                <button\n                  key={k.id}\n                  ref={(el) => {\n                    tabs.current[i] = el;\n                  }}\n                  type=\"button\"\n                  role=\"tab\"\n                  id={`rung-keyword-${k.id}`}\n                  aria-selected={selected}\n                  aria-controls=\"rung-keyword-panel\"\n                  tabIndex={selected ? 0 : -1}\n                  onClick={() => pick(i)}\n                  className={cn(\n                    \"relative grid h-12 grid-cols-[minmax(0,1fr)_5.5rem_3rem] items-center gap-3 overflow-hidden rounded-xl px-3 text-left transition-colors duration-150 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-(--accent) sm:grid-cols-[minmax(0,1fr)_7.5rem_3rem_3.5rem]\",\n                    selected ? \"bg-zinc-950/[0.04] dark:bg-white/[0.06]\" : \"hover:bg-zinc-950/[0.02] dark:hover:bg-white/[0.03]\",\n                  )}\n                >\n                  <span className=\"flex min-w-0 items-center gap-2.5\">\n                    <SearchGlyph className={cn(\"size-3.5 shrink-0\", selected ? \"text-(--accent)\" : \"text-zinc-400 dark:text-zinc-500\")} />\n                    <span className={cn(\"truncate text-sm\", selected ? \"font-semibold\" : \"font-medium text-zinc-700 dark:text-zinc-300\")}>{k.label}</span>\n                  </span>\n                  <span className=\"flex items-center gap-2\">\n                    <span className=\"flex gap-[3px]\" aria-hidden>\n                      {Array.from({ length: 5 }, (_, s) => (\n                        <span key={s} className={cn(\"h-3 w-[5px] rounded-[1.5px]\", s < filled ? \"bg-emerald-500 dark:bg-emerald-400\" : \"bg-zinc-950/10 dark:bg-white/12\")} />\n                      ))}\n                    </span>\n                    <span className=\"text-xs text-zinc-600 tabular-nums dark:text-zinc-400\">{compact.format(k.searches)}</span>\n                  </span>\n                  <span className={cn(\"text-right text-sm font-semibold tabular-nums\", place === 1 && \"text-(--accent)\")}>#{place}</span>\n                  <span\n                    className={cn(\n                      \"hidden items-center justify-end gap-0.5 text-xs font-semibold tabular-nums sm:flex\",\n                      k.moved > 0 ? \"text-emerald-600 dark:text-emerald-400\" : k.moved < 0 ? \"text-rose-600 dark:text-rose-400\" : \"text-zinc-400\",\n                    )}\n                  >\n                    {k.moved === 0 ? \"–\" : (\n                      <>\n                        <svg viewBox=\"0 0 8 8\" className={cn(\"size-2\", k.moved < 0 && \"rotate-180\")} fill=\"currentColor\" aria-hidden>\n                          <path d=\"M4 1.2 7.2 6.4H.8Z\" />\n                        </svg>\n                        {Math.abs(k.moved)}\n                      </>\n                    )}\n                    <span className=\"sr-only\">{k.moved > 0 ? \" places up\" : k.moved < 0 ? \" place down\" : \" no change\"}</span>\n                  </span>\n                  {selected ? (\n                    <>\n                      <span className=\"absolute inset-y-2.5 left-0 w-[3px] rounded-full bg-(--accent)\" aria-hidden />\n                      {auto && !picked ? (\n                        <span ref={timer} className=\"absolute inset-x-3 bottom-0 h-px origin-left scale-x-0 bg-(--accent)\" aria-hidden />\n                      ) : null}\n                    </>\n                  ) : null}\n                </button>\n              );\n            })}\n          </div>\n          <p className=\"mt-auto flex flex-wrap items-center gap-1.5 px-3 pt-4 pb-1.5 text-xs text-zinc-500 dark:text-zinc-400\">\n            {SOURCES.label}\n            {SOURCES.items.map((item) => (\n              <span key={item} className=\"rounded-md px-1.5 py-0.5 font-medium text-zinc-700 shadow-[0_0_0_1px_rgb(0_0_0/0.08)] dark:text-zinc-300 dark:shadow-[0_0_0_1px_rgb(255_255_255/0.1)]\">\n                {item}\n              </span>\n            ))}\n          </p>\n        </div>\n\n        {/* The race for the picked keyword. */}\n        <div id=\"rung-keyword-panel\" role=\"tabpanel\" aria-labelledby={`rung-keyword-${keyword.id}`} className=\"flex flex-col p-2 sm:p-3\">\n          <div className=\"px-3 pt-2 pb-3\">\n            <p className=\"truncate text-[13px] font-semibold tracking-[-0.01em]\">\n              {PANEL.prefix} “{keyword.label}”\n            </p>\n            <p className=\"mt-0.5 text-xs text-zinc-500 dark:text-zinc-400\">{PANEL.unit}</p>\n          </div>\n          <Standings\n            aria-label={`${PANEL.prefix} “${keyword.label}”`}\n            entries={entries}\n            max={40}\n            change={false}\n            format={(v) => `${Math.round(v)}%`}\n            className=\"border-t border-zinc-950/[0.07] [--standings-row:3rem] [--standings-surface:#ffffff] dark:border-white/[0.07] dark:[--standings-surface:#111113]\"\n          />\n          <p\n            key={keyword.id}\n            className=\"mx-1 mt-3 mb-1 flex gap-2.5 rounded-xl bg-[color-mix(in_oklab,var(--accent)_7%,transparent)] px-3 py-2.5 text-[13px] leading-snug text-zinc-700 transition-opacity duration-300 starting:opacity-0 dark:text-zinc-300\"\n          >\n            <SparkGlyph className=\"mt-0.5 size-3.5 shrink-0 text-(--accent)\" />\n            {keyword.tip}\n          </p>\n        </div>\n      </div>\n    </section>\n  );\n}\n\n/* ── Glyphs ──────────────────────────────────────────────── */\n\nfunction SearchGlyph({ className }: { className?: string }) {\n  return (\n    <svg viewBox=\"0 0 16 16\" className={className} fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.7\" strokeLinecap=\"round\" aria-hidden>\n      <circle cx=\"7\" cy=\"7\" r=\"4.25\" />\n      <path d=\"m10.2 10.2 3.3 3.3\" />\n    </svg>\n  );\n}\n\nfunction SparkGlyph({ className }: { className?: string }) {\n  return (\n    <svg viewBox=\"0 0 16 16\" className={className} fill=\"currentColor\" aria-hidden>\n      <path d=\"M8 1.5c.3 2.9 1.6 4.2 4.5 4.5-2.9.3-4.2 1.6-4.5 4.5-.3-2.9-1.6-4.2-4.5-4.5 2.9-.3 4.2-1.6 4.5-4.5ZM12.5 10c.15 1.4.8 2.05 2.2 2.2-1.4.15-2.05.8-2.2 2.2-.15-1.4-.8-2.05-2.2-2.2 1.4-.15 2.05-.8 2.2-2.2Z\" />\n    </svg>\n  );\n}\n\nfunction Chevron({ className }: { className?: string }) {\n  return (\n    <svg viewBox=\"0 0 16 16\" className={className} fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n      <path d=\"m6 4 4 4-4 4\" />\n    </svg>\n  );\n}\n"
    }
  ]
}