{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "team-03",
  "description": "How many people are online, with their avatars and the team split by presence.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/kpi.json",
    "https://www.dashboardblocks.com/r/radix/team.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/team/team-03.tsx",
      "content": "'use client'\n\nimport {\n  BlockStateProvider,\n  type BlockStateProps,\n  Skeleton,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport { KPIValue } from '@/registry/components/dashboardblocks/kpi'\nimport {\n  AvatarStack,\n  type Person,\n  type Presence,\n  PresenceLabel,\n  presenceOrder,\n} from '@/registry/components/dashboardblocks/team'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\nimport { cn } from '@/lib/utils'\n\ninterface Team3Props extends BlockStateProps {\n  description: string\n  /** Leave out, or pass none, to show the empty state. */\n  people?: Person[]\n  title: string\n}\n\nconst roster: [string, Presence][] = [\n  ['Amara Okafor', 'online'],\n  ['Liam Carter', 'online'],\n  ['Mateo García', 'online'],\n  ['Elena Petrova', 'online'],\n  ['Kwame Mensah', 'online'],\n  ['Isabel Duarte', 'online'],\n  ['Oskar Lind', 'online'],\n  ['Sofia Rossi', 'away'],\n  ['Priya Nair', 'away'],\n  ['Noah Williams', 'away'],\n  ['Yusuf Demir', 'away'],\n  ['Jonas Weber', 'offline'],\n  ['Hana Kobayashi', 'offline'],\n  ['Chloé Martin', 'offline'],\n  ['Arjun Mehta', 'offline'],\n  ['Freya Hansen', 'offline'],\n]\n\nconst avatars: Partial<Record<string, string>> = {\n  'Amara Okafor': '/images/avatar-05.webp',\n  'Jonas Weber': '/images/avatar-07.webp',\n  'Liam Carter': '/images/avatar-04.webp',\n  'Mateo García': '/images/avatar-06.webp',\n  'Priya Nair': '/images/avatar-02.webp',\n  'Sofia Rossi': '/images/avatar-01.webp',\n}\n\nconst exampleProps: Team3Props = {\n  description: 'Product and engineering',\n  people: roster.map(([name, presence], index) => ({\n    avatar: avatars[name],\n    id: `p${index + 1}`,\n    name,\n    presence,\n  })),\n  title: 'Who’s online',\n}\n\nconst barFill: Record<Presence, string> = {\n  away: 'bg-orange-500',\n  offline: 'bg-muted-foreground/30',\n  online: 'bg-emerald-600 dark:bg-emerald-500',\n}\n\nconst Team3 = (props: Team3Props) => {\n  const { description, people = [], errorMessage, status, title } = props\n  const state = getBlockState(status, people)\n  const byPresence = Object.fromEntries(\n    presenceOrder.map((presence) => [\n      presence,\n      people.filter((person) => (person.presence ?? 'offline') === presence),\n    ]),\n  ) as Record<Presence, Person[]>\n  const online = byPresence.online.length\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={state}>\n      <Card>\n        <CardContent>\n          <section className='@container flex flex-col gap-4'>\n            <header className='flex flex-col gap-0.5'>\n              <h2 className='font-semibold tracking-tight'>{title}</h2>\n              {state ? (\n                <p className='text-muted-foreground text-sm'>{description}.</p>\n              ) : (\n                <p className='text-muted-foreground text-sm'>\n                  {description}, {people.length}{' '}\n                  {people.length === 1 ? 'person' : 'people'}.\n                </p>\n              )}\n            </header>\n            <div className='flex flex-wrap items-end justify-between gap-x-6 gap-y-3 border-t pt-4'>\n              <div className='flex items-baseline gap-2'>\n                <KPIValue value={online} format={(value) => String(value)} />\n                {!state && (\n                  <span className='text-muted-foreground text-sm'>\n                    of {people.length} online now\n                  </span>\n                )}\n              </div>\n              {!state && online > 0 && (\n                <AvatarStack label='Online now' max={5} people={byPresence.online} />\n              )}\n            </div>\n            {state === 'loading' && (\n              <>\n                <Skeleton className='h-2 w-full rounded-full' />\n                <dl className='grid grid-cols-3 gap-4'>\n                  {presenceOrder.map((presence) => (\n                    <div key={presence} className='flex flex-col gap-0.5'>\n                      <dt>\n                        <PresenceLabel presence={presence} />\n                      </dt>\n                      <dd>\n                        <KPIValue className='text-2xl' value={undefined} />\n                      </dd>\n                    </div>\n                  ))}\n                </dl>\n              </>\n            )}\n            {!state && (\n              <>\n                <div\n                  aria-hidden\n                  className='bg-muted flex h-2 w-full gap-0.5 overflow-hidden rounded-full'\n                >\n                  {presenceOrder.map((presence) =>\n                    byPresence[presence].length > 0 ? (\n                      <div\n                        key={presence}\n                        className={cn('h-full', barFill[presence])}\n                        style={{ flexGrow: byPresence[presence].length }}\n                      />\n                    ) : null,\n                  )}\n                </div>\n                <dl className='grid grid-cols-3 gap-4'>\n                  {presenceOrder.map((presence) => (\n                    <div key={presence} className='flex flex-col gap-0.5'>\n                      <dt>\n                        <PresenceLabel presence={presence} />\n                      </dt>\n                      <dd className='text-2xl font-light tracking-tight tabular-nums'>\n                        {byPresence[presence].length}\n                      </dd>\n                    </div>\n                  ))}\n                </dl>\n              </>\n            )}\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { Team3, exampleProps as team3ExampleProps, type Team3Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/team/team-03.tsx"
    }
  ],
  "meta": {
    "shows": "How many people are online, with their avatars and the team split by presence.",
    "size": "half",
    "usedWith": [
      "team-01",
      "team-04"
    ],
    "component": "Team3",
    "props": "{ description: string; people?: { avatar?: string; id: string; name: string; presence?: \"online\" | \"away\" | \"offline\" }[]; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
