{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "activity-feed-04",
  "description": "A week of activity as daily bars with the busiest day labelled, by kind, with the most active people.",
  "registryDependencies": [
    "https://www.dashboardblocks.com/r/radix/change-amount.json",
    "card",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/chart.json",
    "https://www.dashboardblocks.com/r/radix/kpi.json",
    "https://www.dashboardblocks.com/r/radix/team.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/activity-feed/activity-feed-04.tsx",
      "content": "'use client'\n\nimport {\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  SkeletonText,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport { ChangeAmount } from '@/registry/components/dashboardblocks/change-amount'\nimport {\n  chartFadedColor,\n  TinyBarChart,\n} from '@/registry/components/dashboardblocks/chart'\nimport { KPIChange, KPIValue } from '@/registry/components/dashboardblocks/kpi'\nimport { type Person, PersonAvatar } from '@/registry/components/dashboardblocks/team'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { formatNumber } from '@/registry/lib/dashboardblocks/format'\nimport { type ReactNode, useId } from 'react'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\nimport { cn } from '@/lib/utils'\n\ninterface ActivityCount {\n  icon?: ReactNode\n  label: string\n  previous: number\n  value: number\n}\n\ninterface ActivityDay {\n  /** The day's name, such as \"Thursday\". */\n  day: string\n  /** The same day a week earlier, shown in the tooltip and the week's change. */\n  previous: number\n  value: number\n}\n\ninterface Contributor extends Pick<Person, 'avatar' | 'name'> {\n  count: number\n}\n\ninterface ActivityFeed4Props extends BlockStateProps {\n  /** Most active first. */\n  contributors?: Contributor[]\n  counts?: ActivityCount[]\n  /** One entry per day, in order. Leave out, or pass none, to show the empty state. */\n  days?: ActivityDay[]\n  /** The dates the week covers, such as \"Sep 20 – 26\". */\n  range: string\n  title: string\n}\n\nconst exampleProps: ActivityFeed4Props = {\n  contributors: [\n    { avatar: '/images/avatar-14.webp', count: 64, name: 'Kevin Moore' },\n    { avatar: '/images/avatar-02.webp', count: 51, name: 'Priya Nair' },\n    { count: 38, name: 'Mei Tanaka' },\n    { count: 22, name: 'Kenji Watanabe' },\n    { count: 17, name: 'Amara Okafor' },\n  ],\n  counts: [\n    {\n      icon: (\n        <IconPlaceholder\n          lucide='CircleCheckIcon'\n          tabler='IconCircleCheck'\n          hugeicons='CheckmarkCircle02Icon'\n          phosphor='CheckCircleIcon'\n          remixicon='RiCheckboxCircleLine'\n        />\n      ),\n      label: 'Tasks done',\n      previous: 41,\n      value: 48,\n    },\n    {\n      icon: (\n        <IconPlaceholder\n          lucide='MessageSquareIcon'\n          tabler='IconMessage'\n          hugeicons='MessageIcon'\n          phosphor='ChatCircleIcon'\n          remixicon='RiChat1Line'\n        />\n      ),\n      label: 'Comments',\n      previous: 128,\n      value: 126,\n    },\n    {\n      icon: (\n        <IconPlaceholder\n          lucide='CirclePlusIcon'\n          tabler='IconCirclePlus'\n          hugeicons='AddCircleIcon'\n          phosphor='PlusCircleIcon'\n          remixicon='RiAddCircleLine'\n        />\n      ),\n      label: 'Tasks created',\n      previous: 35,\n      value: 44,\n    },\n    {\n      icon: (\n        <IconPlaceholder\n          lucide='UserPlusIcon'\n          tabler='IconUserPlus'\n          hugeicons='UserAdd01Icon'\n          phosphor='UserPlusIcon'\n          remixicon='RiUserAddLine'\n        />\n      ),\n      label: 'New members',\n      previous: 1,\n      value: 3,\n    },\n  ],\n  days: [\n    { day: 'Sunday', previous: 9, value: 12 },\n    { day: 'Monday', previous: 36, value: 41 },\n    { day: 'Tuesday', previous: 41, value: 39 },\n    { day: 'Wednesday', previous: 33, value: 46 },\n    { day: 'Thursday', previous: 38, value: 58 },\n    { day: 'Friday', previous: 42, value: 21 },\n    { day: 'Saturday', previous: 6, value: 4 },\n  ],\n  range: 'Sep 20 – 26',\n  title: 'This week',\n}\n\nconst CHART_COLOR = 'var(--color-chart-2)'\nconst COMPARISON = 'last week'\n\nconst formatCount = (value: number) => formatNumber(value, { maximumFractionDigits: 0 })\n\nfunction CountChange({ previous, value }: { previous: number; value: number }) {\n  const difference = value - previous\n  return (\n    <span className='text-muted-foreground'>\n      <ChangeAmount\n        change={difference}\n        className={cn(\n          'font-medium tabular-nums',\n          difference > 0 && 'text-emerald-700 dark:text-emerald-400',\n          difference < 0 && 'text-red-700 dark:text-red-400',\n        )}\n      >\n        {formatCount(Math.abs(difference))}\n      </ChangeAmount>{' '}\n      from <span className='tabular-nums'>{formatCount(previous)}</span> {COMPARISON}\n    </span>\n  )\n}\n\nconst ActivityFeed4 = (props: ActivityFeed4Props) => {\n  const {\n    contributors = [],\n    counts = [],\n    days = [],\n    range,\n    errorMessage,\n    status,\n    title,\n  } = props\n  const id = useId()\n  const state = getBlockState(status, days)\n  const total = days.reduce((sum, day) => sum + day.value, 0)\n  const previousTotal = days.reduce((sum, day) => sum + day.previous, 0)\n  const busiest = days.reduce(\n    (best, day, index) => (day.value > (days[best]?.value ?? -1) ? index : best),\n    0,\n  )\n  const top = contributors.slice(0, 5)\n  const max = Math.max(...top.map((person) => person.count), 1)\n  const compare = (day: ActivityDay) => {\n    const difference = day.value - day.previous\n    if (difference === 0) return 'the same as the week before'\n    return `${formatCount(Math.abs(difference))} ${difference > 0 ? 'more' : 'fewer'} than the ${day.day} before`\n  }\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              <p className='text-muted-foreground text-sm'>\n                {range}\n                {!state && days[busiest] ? `, busiest on ${days[busiest].day}.` : '.'}\n              </p>\n            </header>\n            <div className='flex flex-col gap-1'>\n              {state ? (\n                <KPIValue />\n              ) : (\n                <p className='text-4xl font-light tracking-tight tabular-nums'>\n                  {formatCount(total)}\n                  <span className='text-muted-foreground ml-1 text-base font-normal tracking-normal'>\n                    actions\n                  </span>\n                </p>\n              )}\n              <KPIChange comparison={COMPARISON} previous={previousTotal} value={total} />\n            </div>\n            <div className='flex flex-col gap-2'>\n              <div aria-hidden>\n                <TinyBarChart\n                  accessibilityLayer={false}\n                  bars={[{ dataKey: 'value', fill: CHART_COLOR }]}\n                  data={days.map((day) => ({\n                    label: day.day,\n                    value: day.value,\n                  }))}\n                  formatter={(value) =>\n                    `${formatCount(value)} ${value === 1 ? 'action' : 'actions'}`\n                  }\n                  height={128}\n                  highlightIndex={busiest}\n                  xAxisKey='label'\n                />\n              </div>\n              <ul className='sr-only'>\n                {!state &&\n                  days.map((day) => (\n                    <li key={day.day}>\n                      {day.day}: {formatCount(day.value)}{' '}\n                      {day.value === 1 ? 'action' : 'actions'}, {compare(day)}.\n                    </li>\n                  ))}\n              </ul>\n            </div>\n            {state === 'loading' && (\n              <div aria-hidden className='grid grid-cols-2 gap-x-4 gap-y-4 border-t pt-4'>\n                {Array.from({ length: 4 }, (_, index) => (\n                  <div key={index} className='flex flex-col gap-1.5'>\n                    <SkeletonText className='w-20 text-sm' />\n                    <SkeletonText className='w-12 text-2xl' />\n                    <SkeletonText className='w-32 text-xs' />\n                  </div>\n                ))}\n              </div>\n            )}\n            {!state && (\n              <dl className='grid grid-cols-2 gap-x-4 gap-y-4 border-t pt-4'>\n                {counts.map((count) => (\n                  <div key={count.label} className='flex min-w-0 flex-col gap-0.5'>\n                    <dt className='text-muted-foreground flex items-center gap-1.5 text-sm [&_svg]:size-3.5 [&_svg]:shrink-0'>\n                      {count.icon}\n                      <span className='truncate'>{count.label}</span>\n                    </dt>\n                    <dd className='text-2xl font-light tracking-tight tabular-nums'>\n                      {formatCount(count.value)}\n                    </dd>\n                    <dd className='text-xs'>\n                      <CountChange previous={count.previous} value={count.value} />\n                    </dd>\n                  </div>\n                ))}\n              </dl>\n            )}\n            {state !== 'error' && state !== 'empty' && (\n              <section aria-labelledby={id} className='flex flex-col gap-3 border-t pt-4'>\n                <h3 id={id} className='text-sm font-medium'>\n                  Most active\n                </h3>\n                {state === 'loading' && <BlockStateRows rows={5} />}\n                {!state && (\n                  <ol className='flex flex-col gap-2.5'>\n                    {top.map((person, index) => (\n                      <li key={person.name} className='flex items-center gap-3 text-sm'>\n                        <PersonAvatar person={person} size='sm' />\n                        <span className='w-28 truncate'>{person.name}</span>\n                        <span aria-hidden className='h-1.5 flex-1'>\n                          <span\n                            className='block h-full rounded-full'\n                            style={{\n                              backgroundColor:\n                                index === 0 ? CHART_COLOR : chartFadedColor(CHART_COLOR),\n                              width: `${(person.count / max) * 100}%`,\n                            }}\n                          />\n                        </span>\n                        <span className='w-8 text-right tabular-nums'>\n                          {formatCount(person.count)}\n                          <span className='sr-only'> actions</span>\n                        </span>\n                      </li>\n                    ))}\n                  </ol>\n                )}\n              </section>\n            )}\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport {\n  ActivityFeed4,\n  exampleProps as activityFeed4ExampleProps,\n  type ActivityCount,\n  type ActivityDay,\n  type ActivityFeed4Props,\n  type Contributor,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/activity-feed/activity-feed-04.tsx"
    }
  ],
  "meta": {
    "shows": "A week of activity as daily bars with the busiest day labelled, by kind, with the most active people.",
    "size": "half",
    "usedWith": [
      "activity-feed-01",
      "stat-group-02",
      "leaderboard-01"
    ],
    "component": "ActivityFeed4",
    "props": "{ contributors?: { count: number; avatar?: string; name: string }[]; counts?: { icon?: ReactNode; label: string; previous: number; value: number }[]; days?: { day: string; previous: number; value: number }[]; range: string; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
