{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "empty-states-03",
  "title": "Block that failed to load",
  "description": "A page of cards where one block failed (simulated) and shows a notice with Retry, while the other cards keep working.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/avatar.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/checkbox.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/skeleton.json",
    "https://ui.ndekocode.dev/r/status-orb.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/empty-states/empty-states-03/index.tsx",
      "content": "import { ActivityCard } from './activity-card';\nimport { OpenTasksCard, TeamCard } from './working-cards';\n\nexport default function EmptyStates03() {\n  return (\n    <div className='bg-background text-foreground @container min-h-svh px-4 py-8 sm:px-8 sm:py-10'>\n      <div className='mx-auto max-w-4xl'>\n        <h1 className='text-sm font-semibold'>This week</h1>\n        <p className='text-muted-foreground text-xs'>\n          Mossline Web · Nov 2 to Nov 8\n        </p>\n        <div className='mt-5 grid gap-4 @3xl:grid-cols-2'>\n          <OpenTasksCard />\n          <TeamCard />\n          <ActivityCard className='@3xl:col-span-2' />\n        </div>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/empty-states-03/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/empty-states/empty-states-03/activity-card.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { RefreshCwIcon, RotateCcwIcon } from '@/registry/ndeko/lib/icons';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Skeleton } from '@/registry/ndeko/ui/skeleton';\nimport { StatusOrb } from '@/registry/ndeko/ui/status-orb';\n\nimport { DashboardCard } from './dashboard-card';\nimport { ACTIVITY, LOAD_DURATION_MS } from './data';\nimport { fadePresence } from './motion-parts';\nimport { personOf } from './people';\nimport { PersonAvatar } from './working-cards';\n\ntype LoadState = 'failed' | 'loading' | 'loaded';\n\nconst SKELETON_ROWS = ['first', 'second', 'third'];\n\nconst META: Record<LoadState, string> = {\n  failed: 'Not loaded',\n  loading: 'Loading',\n  loaded: 'Last 24 hours',\n};\n\nfunction FailedNotice({ onRetry }: { onRetry: () => void }) {\n  return (\n    <div className='flex items-start gap-3 py-1'>\n      <StatusOrb tone='error' size='sm' className='mt-px' />\n      <div className='min-w-0 flex-1'>\n        <p className='text-[13px] font-medium'>Couldn’t load recent activity</p>\n        <p className='text-muted-foreground mt-0.5 text-[13px] text-pretty'>\n          The activity service took too long to answer, the other cards are up\n          to date\n        </p>\n        <Button variant='outline' size='sm' onClick={onRetry} className='mt-3'>\n          <RotateCcwIcon />\n          Retry\n        </Button>\n      </div>\n    </div>\n  );\n}\n\nfunction ActivitySkeleton() {\n  return (\n    <div aria-busy='true' className='flex flex-col gap-3 py-1'>\n      <span className='sr-only'>Loading recent activity</span>\n      {SKELETON_ROWS.map((row) => (\n        <div key={row} className='flex items-center gap-2.5'>\n          <Skeleton className='size-6 rounded-full' />\n          <Skeleton className='h-2.5 w-2/5' />\n          <Skeleton className='ms-auto h-2.5 w-8' />\n        </div>\n      ))}\n    </div>\n  );\n}\n\nfunction ActivityList() {\n  return (\n    <ul className='flex flex-col gap-3 py-1'>\n      {ACTIVITY.map((entry) => {\n        const person = personOf(entry.personId);\n        return (\n          <li key={entry.id} className='flex items-center gap-2.5'>\n            <PersonAvatar person={person} />\n            <p className='text-muted-foreground min-w-0 flex-1 truncate text-[13px]'>\n              <span className='text-foreground font-medium'>{person.name}</span>{' '}\n              {entry.text}\n            </p>\n            <span className='text-muted-foreground shrink-0 text-xs tabular-nums'>\n              {entry.age}\n            </span>\n          </li>\n        );\n      })}\n    </ul>\n  );\n}\n\nexport function ActivityCard({ className }: { className?: string }) {\n  const [state, setState] = useState<LoadState>('failed');\n  const timers = useRef(new Set<ReturnType<typeof setTimeout>>());\n  const isLoaded = state === 'loaded';\n\n  useEffect(() => {\n    const pending = timers.current;\n    return () => {\n      pending.forEach((timer) => clearTimeout(timer));\n    };\n  }, []);\n\n  function load() {\n    setState('loading');\n    const timer = setTimeout(() => {\n      timers.current.delete(timer);\n      setState('loaded');\n    }, LOAD_DURATION_MS);\n    timers.current.add(timer);\n  }\n\n  const reloadButton = (\n    <Button\n      variant='ghost'\n      size='icon-sm'\n      aria-label='Reload activity'\n      onClick={load}\n      className='text-muted-foreground'\n    >\n      <RefreshCwIcon />\n    </Button>\n  );\n\n  return (\n    <DashboardCard\n      title='Recent activity'\n      meta={META[state]}\n      action={isLoaded && reloadButton}\n      className={className}\n    >\n      <AnimatedSize>\n        <div className='relative'>\n          <AnimatePresence mode='popLayout' initial={false}>\n            <motion.div key={state} {...fadePresence()}>\n              {state === 'failed' && <FailedNotice onRetry={load} />}\n              {state === 'loading' && <ActivitySkeleton />}\n              {isLoaded && <ActivityList />}\n            </motion.div>\n          </AnimatePresence>\n        </div>\n      </AnimatedSize>\n    </DashboardCard>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/empty-states-03/activity-card.tsx"
    },
    {
      "path": "registry/ndeko/blocks/empty-states/empty-states-03/working-cards.tsx",
      "content": "'use client';\n\nimport { useState } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\nimport { Checkbox } from '@/registry/ndeko/ui/checkbox';\n\nimport { DashboardCard } from './dashboard-card';\nimport { OPEN_TASKS, TEAM, type OpenTask, type Person } from './data';\nimport { personOf } from './people';\n\nfunction withDone(tasks: OpenTask[], taskId: string, isDone: boolean) {\n  return tasks.map((task) => {\n    if (task.id !== taskId) {\n      return task;\n    }\n    return { ...task, isDone };\n  });\n}\n\nexport function PersonAvatar({\n  person,\n  className,\n}: {\n  person: Person;\n  className?: string;\n}) {\n  return (\n    <Avatar\n      className={cn('size-6 text-[10px]', className)}\n      seed={person.name}\n    />\n  );\n}\n\nexport function OpenTasksCard() {\n  const [tasks, setTasks] = useState<OpenTask[]>(OPEN_TASKS);\n  const openCount = tasks.filter((task) => !task.isDone).length;\n\n  function toggle(taskId: string, isDone: boolean) {\n    setTasks((current) => withDone(current, taskId, isDone));\n  }\n\n  return (\n    <DashboardCard\n      title='Your open tasks'\n      meta={\n        <span className='inline-flex items-center gap-1 tabular-nums'>\n          <MotionNumber value={openCount} /> open\n        </span>\n      }\n    >\n      <ul className='-mx-1.5 flex flex-col'>\n        {tasks.map((task) => (\n          <li key={task.id}>\n            <label className='hover:bg-foreground/[0.03] flex h-9 cursor-pointer items-center gap-2.5 rounded-md px-1.5'>\n              <Checkbox\n                checked={task.isDone}\n                onCheckedChange={(checked) => toggle(task.id, checked)}\n              />\n              <span className='text-muted-foreground w-16 shrink-0 text-xs tabular-nums'>\n                {task.key}\n              </span>\n              <span\n                className={cn(\n                  'min-w-0 flex-1 truncate text-[13px]',\n                  task.isDone && 'text-muted-foreground line-through'\n                )}\n              >\n                {task.title}\n              </span>\n            </label>\n          </li>\n        ))}\n      </ul>\n    </DashboardCard>\n  );\n}\n\nexport function TeamCard() {\n  return (\n    <DashboardCard title='Team' meta='Working on now'>\n      <ul className='flex flex-col gap-3'>\n        {TEAM.map((member) => {\n          const person = personOf(member.personId);\n          return (\n            <li key={member.personId} className='flex items-center gap-2.5'>\n              <PersonAvatar person={person} />\n              <div className='min-w-0 flex-1'>\n                <p className='truncate text-[13px]'>{person.name}</p>\n                <p className='text-muted-foreground truncate text-xs'>\n                  {member.focus ?? 'No task in progress'}\n                </p>\n              </div>\n            </li>\n          );\n        })}\n      </ul>\n    </DashboardCard>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/empty-states-03/working-cards.tsx"
    },
    {
      "path": "registry/ndeko/blocks/empty-states/empty-states-03/dashboard-card.tsx",
      "content": "import { cn } from '@/registry/ndeko/lib/utils';\n\ntype DashboardCardProps = {\n  title: string;\n  meta: React.ReactNode;\n  action?: React.ReactNode;\n  children: React.ReactNode;\n  className?: string;\n};\n\nexport function DashboardCard({\n  title,\n  meta,\n  action,\n  children,\n  className,\n}: DashboardCardProps) {\n  return (\n    <section\n      aria-label={title}\n      className={cn(\n        'bg-card hairline-ring ring-border flex flex-col rounded-xl p-4 shadow-[0_1px_2px_rgb(0_0_0/0.04)]',\n        className\n      )}\n    >\n      <div className='flex min-h-7 items-center justify-between gap-2'>\n        <div className='flex min-w-0 items-baseline gap-2'>\n          <h2 className='truncate text-[13px] font-medium'>{title}</h2>\n          <span className='text-muted-foreground shrink-0 text-xs'>{meta}</span>\n        </div>\n        {action}\n      </div>\n      <div className='mt-3'>{children}</div>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/empty-states-03/dashboard-card.tsx"
    },
    {
      "path": "registry/ndeko/blocks/empty-states/empty-states-03/people.ts",
      "content": "import { PEOPLE } from './data';\n\nexport function personOf(personId: string) {\n  const found = PEOPLE.find((person) => person.id === personId);\n  if (found) {\n    return found;\n  }\n  return PEOPLE[0];\n}\n",
      "type": "registry:component",
      "target": "components/blocks/empty-states-03/people.ts"
    },
    {
      "path": "registry/ndeko/blocks/empty-states/empty-states-03/motion-parts.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type MotionProps,\n  type Transition,\n  type Variants,\n} from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { cn } from '@/registry/ndeko/lib/utils';\n\nconst EASE_OUT_STRONG: [number, number, number, number] = [0.23, 1, 0.32, 1];\n\nconst ENTER: Transition = { duration: 0.2, ease: EASE_OUT_STRONG };\n\nconst EXIT: Transition = { duration: 0.15, ease: EASE_OUT_STRONG };\n\ntype PresenceProps = Pick<\n  MotionProps,\n  'initial' | 'animate' | 'exit' | 'transition'\n>;\n\nconst HEIGHT_PRESENCE: PresenceProps = {\n  initial: { height: 0, opacity: 0 },\n  animate: { height: 'auto', opacity: 1 },\n  exit: { height: 0, opacity: 0, transition: EXIT },\n  transition: ENTER,\n};\n\nconst FADE_PRESENCE: PresenceProps = {\n  initial: { opacity: 0 },\n  animate: { opacity: 1 },\n  exit: { opacity: 0, transition: EXIT },\n  transition: ENTER,\n};\n\nexport function heightPresenceOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_PRESENCE;\n  }\n  return HEIGHT_PRESENCE;\n}\n\nexport function fadePresence() {\n  return FADE_PRESENCE;\n}\n\nconst SWAP_TRANSITION: Transition = { duration: 0.15, ease: EASE_OUT_STRONG };\n\nconst SWAP_VARIANTS: Variants = {\n  hidden: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n  shown: { opacity: 1, scale: 1, filter: 'blur(0px)' },\n};\n\nconst FADE_VARIANTS: Variants = {\n  hidden: { opacity: 0 },\n  shown: { opacity: 1 },\n};\n\nfunction swapVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return SWAP_VARIANTS;\n}\n\ntype SwapProps = {\n  swapKey: string;\n  children: React.ReactNode;\n  className?: string;\n};\n\nexport function Swap({ swapKey, children, className }: SwapProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = swapVariantsOf(shouldReduceMotion);\n\n  return (\n    <span className={cn('relative inline-flex', className)}>\n      <AnimatePresence mode='popLayout' initial={false}>\n        <motion.span\n          key={swapKey}\n          variants={variants}\n          initial='hidden'\n          animate='shown'\n          exit='hidden'\n          transition={SWAP_TRANSITION}\n          className='inline-flex'\n        >\n          {children}\n        </motion.span>\n      </AnimatePresence>\n    </span>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/empty-states-03/motion-parts.tsx"
    },
    {
      "path": "registry/ndeko/blocks/empty-states/empty-states-03/data.ts",
      "content": "export type Person = {\n  id: string;\n  name: string;\n};\n\nexport type OpenTask = {\n  id: string;\n  key: string;\n  title: string;\n  isDone: boolean;\n};\n\nexport type TeamMember = {\n  personId: string;\n  focus?: string;\n};\n\nexport type ActivityEntry = {\n  id: string;\n  personId: string;\n  text: string;\n  age: string;\n};\n\nexport const LOAD_DURATION_MS = 900;\n\nexport const PEOPLE: Person[] = [\n  {\n    id: 'amara',\n    name: 'Amara Okafor',\n  },\n  {\n    id: 'leo',\n    name: 'Léo Martin',\n  },\n  {\n    id: 'sana',\n    name: 'Sana Iqbal',\n  },\n  {\n    id: 'tomas',\n    name: 'Tomás Rivera',\n  },\n  {\n    id: 'mei',\n    name: 'Mei Lin',\n  },\n];\n\nexport const OPEN_TASKS: OpenTask[] = [\n  {\n    id: 'mos-155',\n    key: 'MOS-155',\n    title: 'Empty states for the plant library',\n    isDone: false,\n  },\n  {\n    id: 'mos-152',\n    key: 'MOS-152',\n    title: 'Offline drafts for field notes',\n    isDone: false,\n  },\n  {\n    id: 'mos-164',\n    key: 'MOS-164',\n    title: 'Copy for the weekly digest email',\n    isDone: false,\n  },\n  {\n    id: 'mos-133',\n    key: 'MOS-133',\n    title: 'Tag colours in the sidebar',\n    isDone: true,\n  },\n];\n\nexport const TEAM: TeamMember[] = [\n  { personId: 'leo', focus: 'MOS-148 Booking calendar on Safari' },\n  { personId: 'sana', focus: 'MOS-139 Rate limit share links' },\n  { personId: 'tomas', focus: 'MOS-152 Offline drafts' },\n  { personId: 'mei' },\n];\n\nexport const ACTIVITY: ActivityEntry[] = [\n  {\n    id: 'a-1',\n    personId: 'mei',\n    text: 'commented on MOS-148',\n    age: '12m',\n  },\n  {\n    id: 'a-2',\n    personId: 'leo',\n    text: 'set an estimate on MOS-148',\n    age: '1h',\n  },\n  {\n    id: 'a-3',\n    personId: 'sana',\n    text: 'moved MOS-139 to In review',\n    age: '3h',\n  },\n  {\n    id: 'a-4',\n    personId: 'tomas',\n    text: 'added the label Mobile to MOS-152',\n    age: 'Yesterday',\n  },\n];\n",
      "type": "registry:component",
      "target": "components/blocks/empty-states-03/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "empty-states"
  ],
  "type": "registry:block"
}