{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "notifications-01",
  "title": "Inbox from a bell",
  "description": "A bell with a dot while something is unread, opening an inbox where each row leads with the task, then the event, with read and archive actions in the place of the age.",
  "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/icons.json",
    "https://ui.ndekocode.dev/r/popover.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/tooltip.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/notifications/notifications-01/index.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion, type Transition } from 'motion/react';\nimport { useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  BellIcon,\n  CheckIcon,\n  ChevronRightIcon,\n  InboxIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport {\n  Popover,\n  PopoverContent,\n  PopoverTitle,\n  PopoverTrigger,\n} from '@/registry/ndeko/ui/popover';\n\nimport {\n  ASSIGNED_TASKS,\n  INBOX,\n  TEAM_KEY,\n  WORKSPACE_NAME,\n  type InboxItem,\n} from './data';\nimport { IssueTypeGem } from './inbox-glyphs';\nimport { InboxRow } from './inbox-row';\n\nconst EASE_OUT_STRONG: [number, number, number, number] = [0.23, 1, 0.32, 1];\n\nconst DOT_TRANSITION: Transition = { duration: 0.18, ease: EASE_OUT_STRONG };\n\nconst FADE_TRANSITION: Transition = { duration: 0.18, ease: EASE_OUT_STRONG };\n\nfunction dotScaleOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return 1;\n  }\n  return 0.4;\n}\n\nfunction bellLabelOf(unreadCount: number) {\n  if (unreadCount === 0) {\n    return 'Inbox, nothing unread';\n  }\n  if (unreadCount === 1) {\n    return 'Inbox, 1 unread';\n  }\n  return `Inbox, ${unreadCount} unread`;\n}\n\nfunction unreadLabelOf(unreadCount: number) {\n  if (unreadCount === 0) {\n    return 'All read';\n  }\n  return `${unreadCount} unread`;\n}\n\nfunction withRead(items: InboxItem[], itemId: string, isUnread: boolean) {\n  return items.map((item) => {\n    if (item.id !== itemId) {\n      return item;\n    }\n    return { ...item, isUnread };\n  });\n}\n\nfunction InboxEmpty() {\n  return (\n    <div className='flex flex-col items-center px-6 py-10 text-center'>\n      <span className='keycap-3d text-muted-foreground flex size-9 items-center justify-center rounded-lg'>\n        <InboxIcon />\n      </span>\n      <p className='mt-3 text-sm font-medium'>No notifications</p>\n      <p className='text-muted-foreground mt-1 max-w-64 text-[13px] text-balance'>\n        Mentions, assignments and comments on your tasks arrive here\n      </p>\n    </div>\n  );\n}\n\nexport default function Notifications01() {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const [items, setItems] = useState<InboxItem[]>(INBOX);\n  const unreadCount = items.filter((item) => item.isUnread).length;\n  const hasUnread = unreadCount > 0;\n  const hasItems = items.length > 0;\n  const dotScale = dotScaleOf(shouldReduceMotion);\n\n  function markRead(itemId: string) {\n    setItems((current) => withRead(current, itemId, false));\n  }\n\n  function toggleRead(itemId: string) {\n    const item = items.find((entry) => entry.id === itemId);\n    if (!item) {\n      return;\n    }\n    setItems((current) => withRead(current, itemId, !item.isUnread));\n  }\n\n  function archive(itemId: string) {\n    setItems((current) => current.filter((item) => item.id !== itemId));\n  }\n\n  function markAllRead() {\n    setItems((current) =>\n      current.map((item) => ({ ...item, isUnread: false }))\n    );\n  }\n\n  return (\n    <div className='bg-background text-foreground flex min-h-svh flex-col'>\n      <header className='hairline-b border-border flex h-11 shrink-0 items-center justify-between gap-3 px-3 sm:px-5'>\n        <nav\n          aria-label='Breadcrumb'\n          className='flex min-w-0 items-center gap-1.5 text-[13px]'\n        >\n          <span className='text-muted-foreground'>{WORKSPACE_NAME}</span>\n          <ChevronRightIcon className='text-muted-foreground size-3.5' />\n          <span className='truncate font-medium'>My issues</span>\n        </nav>\n        <Popover>\n          <PopoverTrigger\n            render={\n              <Button\n                variant='ghost'\n                size='icon-sm'\n                aria-label={bellLabelOf(unreadCount)}\n              />\n            }\n          >\n            <BellIcon />\n            <AnimatePresence initial={false}>\n              {hasUnread && (\n                <motion.span\n                  key='dot'\n                  aria-hidden='true'\n                  initial={{ opacity: 0, scale: dotScale }}\n                  animate={{ opacity: 1, scale: 1 }}\n                  exit={{ opacity: 0, scale: dotScale }}\n                  transition={DOT_TRANSITION}\n                  className='bg-primary ring-background absolute top-1 right-1 size-2 rounded-full ring-2'\n                />\n              )}\n            </AnimatePresence>\n          </PopoverTrigger>\n          <PopoverContent\n            align='end'\n            className='w-[26rem] max-w-[calc(100vw-1rem)] p-0'\n          >\n            <div className='flex h-11 items-center justify-between gap-2 ps-4 pe-2'>\n              <div className='flex items-baseline gap-2'>\n                <PopoverTitle className='text-[13px] leading-none font-semibold'>\n                  Inbox\n                </PopoverTitle>\n                <span className='text-muted-foreground text-xs tabular-nums'>\n                  {unreadLabelOf(unreadCount)}\n                </span>\n              </div>\n              <Button\n                variant='ghost'\n                size='sm'\n                disabled={!hasUnread}\n                onClick={markAllRead}\n                className='text-muted-foreground'\n              >\n                <CheckIcon />\n                Mark all as read\n              </Button>\n            </div>\n            <AnimatedSize>\n              <div className='relative'>\n                <AnimatePresence mode='popLayout' initial={false}>\n                  {hasItems && (\n                    <motion.ul\n                      key='list'\n                      aria-label='Notifications'\n                      initial={{ opacity: 0 }}\n                      animate={{ opacity: 1 }}\n                      exit={{ opacity: 0 }}\n                      transition={FADE_TRANSITION}\n                      className='max-h-[24rem] overflow-y-auto px-1.5 pb-1.5'\n                    >\n                      <AnimatePresence initial={false}>\n                        {items.map((item) => (\n                          <InboxRow\n                            key={item.id}\n                            item={item}\n                            onOpen={markRead}\n                            onToggleRead={toggleRead}\n                            onArchive={archive}\n                          />\n                        ))}\n                      </AnimatePresence>\n                    </motion.ul>\n                  )}\n                  {!hasItems && (\n                    <motion.div\n                      key='empty'\n                      initial={{ opacity: 0 }}\n                      animate={{ opacity: 1 }}\n                      exit={{ opacity: 0 }}\n                      transition={FADE_TRANSITION}\n                    >\n                      <InboxEmpty />\n                    </motion.div>\n                  )}\n                </AnimatePresence>\n              </div>\n            </AnimatedSize>\n          </PopoverContent>\n        </Popover>\n      </header>\n      <main className='mx-auto w-full max-w-2xl px-4 py-8 sm:px-6'>\n        <h1 className='text-sm font-semibold'>My issues</h1>\n        <p className='text-muted-foreground text-xs'>\n          Assigned to you in {WORKSPACE_NAME} Web\n        </p>\n        <ul className='bg-card hairline-ring ring-border hairline-divide-y divide-border mt-4 overflow-clip rounded-xl shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n          {ASSIGNED_TASKS.map((task) => (\n            <li\n              key={task.number}\n              className='flex h-11 items-center gap-3 px-3 text-[13px]'\n            >\n              <IssueTypeGem type={task.type} />\n              <span className='text-muted-foreground w-14 shrink-0 text-xs tabular-nums'>\n                {TEAM_KEY}-{task.number}\n              </span>\n              <span className='min-w-0 flex-1 truncate'>{task.title}</span>\n              <span className='text-muted-foreground hidden text-xs sm:inline'>\n                {task.status}\n              </span>\n            </li>\n          ))}\n        </ul>\n      </main>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/notifications-01/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/notifications/notifications-01/inbox-row.tsx",
      "content": "'use client';\n\nimport { motion, type MotionProps, type Transition } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { ArchiveIcon, CheckIcon, MailIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport {\n  TOOLTIP_GLIDE_CLOSE_DELAY,\n  Tooltip,\n  TooltipContent,\n  TooltipTrigger,\n  useTooltipHandle,\n} from '@/registry/ndeko/ui/tooltip';\n\nimport { PEOPLE, TEAM_KEY, type InboxItem } from './data';\nimport { IssueTypeGem, SenderAvatar } from './inbox-glyphs';\n\nconst EASE_OUT_STRONG: [number, number, number, number] = [0.23, 1, 0.32, 1];\n\n/**\n * The spring AnimatedSize resizes with. It starts from rest, so the fade leads and the freed space\n * closes after it at the pace the list follows, instead of snapping shut.\n */\nconst SIZE_SPRING: Transition = { type: 'spring', bounce: 0, duration: 0.32 };\n\nconst ENTER: Transition = {\n  ...SIZE_SPRING,\n  opacity: { duration: 0.2, ease: EASE_OUT_STRONG },\n};\n\nconst EXIT: Transition = {\n  ...SIZE_SPRING,\n  opacity: { duration: 0.12, ease: EASE_OUT_STRONG },\n};\n\nconst FADE_ENTER: Transition = { duration: 0.2, ease: EASE_OUT_STRONG };\n\nconst FADE_EXIT: Transition = { duration: 0.12, ease: EASE_OUT_STRONG };\n\ntype PresenceProps = Pick<\n  MotionProps,\n  'initial' | 'animate' | 'exit' | 'transition'\n>;\n\nconst ROW_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 ROW_FADE: PresenceProps = {\n  initial: { opacity: 0 },\n  animate: { opacity: 1 },\n  exit: { opacity: 0, transition: FADE_EXIT },\n  transition: FADE_ENTER,\n};\n\nfunction rowPresenceOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return ROW_FADE;\n  }\n  return ROW_PRESENCE;\n}\n\nconst ACTION_BUTTON =\n  'inline-flex size-6 cursor-pointer items-center justify-center rounded-md text-muted-foreground outline-none transition-colors duration-150 hover:bg-foreground/5 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/25';\n\nfunction senderOf(item: InboxItem) {\n  const found = PEOPLE.find((person) => person.id === item.senderId);\n  if (found) {\n    return found;\n  }\n  return PEOPLE[0];\n}\n\nfunction readToggleLabelOf(item: InboxItem) {\n  if (item.isUnread) {\n    return 'Mark as read';\n  }\n  return 'Mark as unread';\n}\n\nfunction eventLineOf(senderName: string, item: InboxItem) {\n  const firstName = senderName.split(' ')[0];\n  if (item.excerpt) {\n    return `${firstName} ${item.event}: ${item.excerpt}`;\n  }\n  return `${firstName} ${item.event}`;\n}\n\ntype InboxRowProps = {\n  item: InboxItem;\n  onOpen: (itemId: string) => void;\n  onToggleRead: (itemId: string) => void;\n  onArchive: (itemId: string) => void;\n};\n\nexport function InboxRow({\n  item,\n  onOpen,\n  onToggleRead,\n  onArchive,\n}: InboxRowProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const sender = senderOf(item);\n  const key = `${TEAM_KEY}-${item.taskNumber}`;\n  const readLabel = readToggleLabelOf(item);\n  const actionHint = useTooltipHandle<string>();\n\n  return (\n    <motion.li\n      {...rowPresenceOf(shouldReduceMotion)}\n      className='overflow-hidden'\n    >\n      <div className='group/row hover:bg-foreground/[0.03] focus-within:bg-foreground/[0.03] relative flex items-start gap-3 rounded-lg px-2.5 py-2.5'>\n        {item.isUnread && (\n          <span\n            aria-hidden='true'\n            className='bg-primary absolute start-1 top-[1.15rem] size-1.5 rounded-full'\n          />\n        )}\n        <SenderAvatar person={sender} kind={item.kind} />\n        <button\n          type='button'\n          onClick={() => onOpen(item.id)}\n          className='focus-visible:after:ring-ring/25 min-w-0 flex-1 cursor-pointer text-left outline-none after:absolute after:inset-0 after:rounded-lg focus-visible:after:ring-[3px]'\n        >\n          <span className='flex min-w-0 items-center gap-1.5'>\n            <IssueTypeGem type={item.taskType} />\n            <span className='text-muted-foreground shrink-0 text-xs tabular-nums'>\n              {key}\n            </span>\n            <span\n              className={cn(\n                'truncate text-[13px] font-medium',\n                !item.isUnread && 'text-muted-foreground'\n              )}\n            >\n              {item.taskTitle}\n            </span>\n          </span>\n          <span className='text-muted-foreground mt-0.5 line-clamp-1 block text-xs'>\n            <span aria-hidden='true' className='hidden pointer-coarse:inline'>\n              {item.age} ·{' '}\n            </span>\n            {eventLineOf(sender.name, item)}\n          </span>\n          <span className='sr-only'>\n            , {item.age}\n            {item.isUnread && ', unread'}\n          </span>\n        </button>\n        <span className='relative z-10 flex h-5 shrink-0 items-center'>\n          <span\n            aria-hidden='true'\n            className='text-muted-foreground text-xs tabular-nums transition-opacity duration-150 group-focus-within/row:opacity-0 group-hover/row:opacity-0 pointer-coarse:hidden'\n          >\n            {item.age}\n          </span>\n          <span className='absolute end-0 flex items-center gap-0.5 opacity-0 transition-opacity duration-150 group-focus-within/row:opacity-100 group-hover/row:opacity-100 pointer-coarse:static pointer-coarse:opacity-100'>\n            <TooltipTrigger\n              handle={actionHint}\n              payload={readLabel}\n              closeDelay={TOOLTIP_GLIDE_CLOSE_DELAY}\n              aria-label={readLabel}\n              onClick={() => onToggleRead(item.id)}\n              className={ACTION_BUTTON}\n            >\n              {item.isUnread && <CheckIcon className='size-3.5' />}\n              {!item.isUnread && <MailIcon className='size-3.5' />}\n            </TooltipTrigger>\n            <TooltipTrigger\n              handle={actionHint}\n              payload='Archive'\n              closeDelay={TOOLTIP_GLIDE_CLOSE_DELAY}\n              aria-label='Archive'\n              onClick={() => onArchive(item.id)}\n              className={ACTION_BUTTON}\n            >\n              <ArchiveIcon className='size-3.5' />\n            </TooltipTrigger>\n            <Tooltip handle={actionHint}>\n              {({ payload }) => (\n                <TooltipContent glide>{payload}</TooltipContent>\n              )}\n            </Tooltip>\n          </span>\n        </span>\n      </div>\n    </motion.li>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/notifications-01/inbox-row.tsx"
    },
    {
      "path": "registry/ndeko/blocks/notifications/notifications-01/inbox-glyphs.tsx",
      "content": "import {\n  AtSignIcon,\n  BookmarkIcon,\n  CheckIcon,\n  CircleAlertIcon,\n  CircleDashedIcon,\n  MessageCircleIcon,\n  UserIcon,\n  ZapIcon,\n  type Icon,\n} from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\n\nimport type { IssueTypeId, NotificationKind, Person } from './data';\n\ntype IssueTypeMeta = {\n  name: string;\n  color: string;\n  glyph: Icon;\n};\n\nconst ISSUE_TYPES: Record<IssueTypeId, IssueTypeMeta> = {\n  task: { name: 'Task', color: 'var(--info)', glyph: CheckIcon },\n  bug: { name: 'Bug', color: 'var(--destructive)', glyph: CircleAlertIcon },\n  story: { name: 'Story', color: 'var(--success)', glyph: BookmarkIcon },\n  epic: { name: 'Epic', color: 'var(--primary)', glyph: ZapIcon },\n};\n\nexport function IssueTypeGem({\n  type,\n  className,\n}: {\n  type: IssueTypeId;\n  className?: string;\n}) {\n  const meta = ISSUE_TYPES[type];\n  const Glyph = meta.glyph;\n  const gemStyle = { '--gem': meta.color } as React.CSSProperties;\n\n  return (\n    <span\n      role='img'\n      aria-label={meta.name}\n      style={gemStyle}\n      className={cn(\n        'gem-plate inline-flex size-4 shrink-0 items-center justify-center rounded-[5px]',\n        className\n      )}\n    >\n      <Glyph strokeWidth={2.5} className='size-2.5' />\n    </span>\n  );\n}\n\nconst KIND_GLYPH: Record<NotificationKind, Icon> = {\n  mention: AtSignIcon,\n  comment: MessageCircleIcon,\n  assigned: UserIcon,\n  status: CircleDashedIcon,\n};\n\nfunction badgeMaterialOf(kind: NotificationKind) {\n  if (kind === 'mention') {\n    return 'chip-3d [--chip:var(--primary)]';\n  }\n  return 'keycap-3d text-muted-foreground';\n}\n\nexport function SenderAvatar({\n  person,\n  kind,\n}: {\n  person: Person;\n  kind: NotificationKind;\n}) {\n  const Glyph = KIND_GLYPH[kind];\n\n  return (\n    <span className='relative inline-flex shrink-0'>\n      <Avatar className='size-7' seed={person.name} />\n      <span\n        aria-hidden='true'\n        className='bg-popover absolute -end-1.5 -bottom-1.5 inline-flex rounded-full p-0.5'\n      >\n        <span\n          className={cn(\n            'inline-flex size-4 items-center justify-center rounded-full',\n            badgeMaterialOf(kind)\n          )}\n        >\n          <Glyph strokeWidth={2.25} className='size-2.5' />\n        </span>\n      </span>\n    </span>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/notifications-01/inbox-glyphs.tsx"
    },
    {
      "path": "registry/ndeko/blocks/notifications/notifications-01/data.ts",
      "content": "export type IssueTypeId = 'task' | 'bug' | 'story' | 'epic';\n\nexport type NotificationKind = 'mention' | 'comment' | 'assigned' | 'status';\n\nexport type Person = {\n  id: string;\n  name: string;\n};\n\nexport type InboxItem = {\n  id: string;\n  kind: NotificationKind;\n  senderId: string;\n  taskNumber: number;\n  taskTitle: string;\n  taskType: IssueTypeId;\n  event: string;\n  excerpt?: string;\n  age: string;\n  isUnread: boolean;\n};\n\nexport type AssignedTask = {\n  number: number;\n  title: string;\n  type: IssueTypeId;\n  status: string;\n};\n\nexport const TEAM_KEY = 'MOS';\n\nexport const WORKSPACE_NAME = 'Mossline';\n\nexport const PEOPLE: Person[] = [\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 INBOX: InboxItem[] = [\n  {\n    id: 'n-1',\n    kind: 'mention',\n    senderId: 'sana',\n    taskNumber: 148,\n    taskTitle: 'Booking calendar skips the first week on Safari',\n    taskType: 'bug',\n    event: 'mentioned you',\n    excerpt: 'Can you check the empty week on the mobile view?',\n    age: '4m',\n    isUnread: true,\n  },\n  {\n    id: 'n-2',\n    kind: 'comment',\n    senderId: 'leo',\n    taskNumber: 152,\n    taskTitle: 'Offline drafts for field notes',\n    taskType: 'story',\n    event: 'commented',\n    excerpt: 'Drafts now sync as soon as the tab is back online',\n    age: '38m',\n    isUnread: true,\n  },\n  {\n    id: 'n-3',\n    kind: 'assigned',\n    senderId: 'mei',\n    taskNumber: 164,\n    taskTitle: 'Copy for the weekly digest email',\n    taskType: 'task',\n    event: 'assigned it to you',\n    age: '2h',\n    isUnread: true,\n  },\n  {\n    id: 'n-4',\n    kind: 'status',\n    senderId: 'sana',\n    taskNumber: 139,\n    taskTitle: 'Rate limit the public share links',\n    taskType: 'task',\n    event: 'moved it to In review',\n    age: '5h',\n    isUnread: false,\n  },\n  {\n    id: 'n-5',\n    kind: 'comment',\n    senderId: 'tomas',\n    taskNumber: 160,\n    taskTitle: 'Sync photo captions across devices',\n    taskType: 'story',\n    event: 'commented',\n    excerpt: 'Captions written offline keep their order now',\n    age: 'Yesterday',\n    isUnread: false,\n  },\n  {\n    id: 'n-6',\n    kind: 'status',\n    senderId: 'leo',\n    taskNumber: 127,\n    taskTitle: 'Paginate the notes list',\n    taskType: 'task',\n    event: 'moved it to Done',\n    age: 'Mon',\n    isUnread: false,\n  },\n];\n\nexport const ASSIGNED_TASKS: AssignedTask[] = [\n  {\n    number: 155,\n    title: 'Empty states for the plant library',\n    type: 'task',\n    status: 'In review',\n  },\n  {\n    number: 152,\n    title: 'Offline drafts for field notes',\n    type: 'story',\n    status: 'In progress',\n  },\n  {\n    number: 164,\n    title: 'Copy for the weekly digest email',\n    type: 'task',\n    status: 'Todo',\n  },\n];\n",
      "type": "registry:component",
      "target": "components/blocks/notifications-01/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "notifications"
  ],
  "type": "registry:block"
}