{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "heroes-03",
  "title": "Hero with an email capture",
  "description": "A waitlist field that checks the address, shows its submitting state and morphs into a confirmation.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/avatar.json",
    "https://ui.ndekocode.dev/r/badge.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/chip.json",
    "https://ui.ndekocode.dev/r/field.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/input.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"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/heroes/heroes-03/index.tsx",
      "content": "import { Badge } from '@/registry/ndeko/ui/badge';\n\nimport { HERO } from './data';\nimport { IssuePreview } from './issue-preview';\nimport { WaitlistForm } from './waitlist-form';\n\nexport default function Heroes03() {\n  return (\n    <section className='px-4 py-16 sm:px-6 sm:py-24 lg:px-8'>\n      <div className='mx-auto grid max-w-6xl items-center gap-12 lg:grid-cols-[minmax(0,1fr)_24rem] lg:gap-16'>\n        <div className='flex max-w-xl flex-col items-start gap-6'>\n          <Badge variant='secondary' className='text-muted-foreground h-6 px-2'>\n            {HERO.eyebrow}\n          </Badge>\n          <h1 className='text-4xl font-semibold text-balance sm:text-5xl'>\n            {HERO.title}\n          </h1>\n          <p className='text-muted-foreground text-base text-pretty'>\n            {HERO.description}\n          </p>\n          <WaitlistForm />\n        </div>\n        <div className='hidden lg:block'>\n          <IssuePreview />\n        </div>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/heroes-03/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/heroes/heroes-03/waitlist-form.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  type Variants,\n} from 'motion/react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { LoaderCircleIcon } from '@/registry/ndeko/lib/icons';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Field, FieldError, FieldLabel } from '@/registry/ndeko/ui/field';\nimport { Input } from '@/registry/ndeko/ui/input';\nimport { StatusOrb } from '@/registry/ndeko/ui/status-orb';\n\nimport { HERO } from './data';\n\ntype Status = 'idle' | 'submitting' | 'confirmed';\n\nconst SUBMIT_DELAY_MS = 900;\n\nconst EMAIL_PATTERN = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nconst PANEL_TRANSITION: Transition = {\n  duration: 0.2,\n  ease: [0.23, 1, 0.32, 1],\n};\n\nconst LABEL_TRANSITION: Transition = {\n  type: 'spring',\n  bounce: 0,\n  duration: 0.3,\n};\n\nconst INSTANT: Transition = { duration: 0 };\n\nconst PANEL_VARIANTS: Variants = {\n  enter: { opacity: 0, scale: 0.98, filter: 'blur(2px)' },\n  visible: { opacity: 1, scale: 1, filter: 'blur(0px)' },\n  exit: { opacity: 0, scale: 0.98, filter: 'blur(2px)' },\n};\n\nconst SPINNER_VARIANTS: Variants = {\n  enter: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n  visible: { opacity: 1, scale: 1, filter: 'blur(0px)' },\n  exit: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n};\n\nconst FADE_VARIANTS: Variants = {\n  enter: { opacity: 0 },\n  visible: { opacity: 1 },\n  exit: { opacity: 0 },\n};\n\nfunction emailErrorOf(value: string) {\n  const trimmed = value.trim();\n  if (trimmed.length === 0) {\n    return 'Enter your email address to join the beta';\n  }\n  const isEmailShaped = EMAIL_PATTERN.test(trimmed);\n  if (!isEmailShaped) {\n    return 'Check the address, it should look like name@example.com';\n  }\n  return null;\n}\n\nfunction submitLabelOf(isSubmitting: boolean) {\n  if (isSubmitting) {\n    return 'Joining';\n  }\n  return 'Join the beta';\n}\n\nfunction panelVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return PANEL_VARIANTS;\n}\n\nfunction spinnerVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return SPINNER_VARIANTS;\n}\n\nfunction labelTransitionOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return INSTANT;\n  }\n  return LABEL_TRANSITION;\n}\n\nexport function WaitlistForm() {\n  const [email, setEmail] = useState('');\n  const [error, setError] = useState<string | null>(null);\n  const [hasTriedSubmit, setHasTriedSubmit] = useState(false);\n  const [status, setStatus] = useState<Status>('idle');\n  const inputRef = useRef<HTMLInputElement>(null);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const panelVariants = panelVariantsOf(shouldReduceMotion);\n  const spinnerVariants = spinnerVariantsOf(shouldReduceMotion);\n  const labelTransition = labelTransitionOf(shouldReduceMotion);\n  const isSubmitting = status === 'submitting';\n  const isConfirmed = status === 'confirmed';\n  const hasError = error !== null;\n  const submitLabel = submitLabelOf(isSubmitting);\n  const trimmedEmail = email.trim();\n\n  useEffect(() => {\n    if (!isSubmitting) {\n      return;\n    }\n    const timeout = window.setTimeout(() => {\n      setStatus('confirmed');\n    }, SUBMIT_DELAY_MS);\n    return () => window.clearTimeout(timeout);\n  }, [isSubmitting]);\n\n  function changeEmail(event: React.ChangeEvent<HTMLInputElement>) {\n    const nextEmail = event.target.value;\n    setEmail(nextEmail);\n    if (hasTriedSubmit) {\n      setError(emailErrorOf(nextEmail));\n    }\n  }\n\n  function submit(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    const nextError = emailErrorOf(email);\n    setHasTriedSubmit(true);\n    setError(nextError);\n    if (nextError) {\n      inputRef.current?.focus();\n      return;\n    }\n    setStatus('submitting');\n  }\n\n  function startOver() {\n    setEmail('');\n    setError(null);\n    setHasTriedSubmit(false);\n    setStatus('idle');\n  }\n\n  return (\n    <AnimatedSize className='w-full max-w-md' contentClassName='relative'>\n      <AnimatePresence mode='popLayout' initial={false}>\n        {isConfirmed && (\n          <motion.div\n            key='confirmation'\n            role='status'\n            variants={panelVariants}\n            initial='enter'\n            animate='visible'\n            exit='exit'\n            transition={PANEL_TRANSITION}\n            className='bg-card hairline-ring ring-border dark:bg-foreground/[0.04] flex items-start gap-3 rounded-xl p-4 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'\n          >\n            <StatusOrb tone='success' />\n            <div className='flex min-w-0 flex-col items-start gap-1'>\n              <p className='text-sm font-medium'>Check your inbox</p>\n              <p className='text-muted-foreground text-[13px]'>\n                We sent a confirmation link to{' '}\n                <span className='text-foreground font-medium break-all'>\n                  {trimmedEmail}\n                </span>\n                . Open it to keep your place in the beta.\n              </p>\n              <Button\n                variant='link'\n                size='sm'\n                className='h-auto px-0 py-0.5'\n                onClick={startOver}\n              >\n                Use another address\n              </Button>\n            </div>\n          </motion.div>\n        )}\n        {!isConfirmed && (\n          <motion.form\n            key='form'\n            noValidate\n            onSubmit={submit}\n            variants={panelVariants}\n            initial='enter'\n            animate='visible'\n            exit='exit'\n            transition={PANEL_TRANSITION}\n            className='flex flex-col gap-2'\n          >\n            <Field invalid={hasError}>\n              <FieldLabel className='sr-only'>Email address</FieldLabel>\n              <div className='flex flex-col gap-2 sm:flex-row'>\n                <Input\n                  ref={inputRef}\n                  type='email'\n                  name='email'\n                  size='lg'\n                  autoComplete='email'\n                  placeholder='you@example.com'\n                  value={email}\n                  onChange={changeEmail}\n                  readOnly={isSubmitting}\n                />\n                <Button\n                  type='submit'\n                  size='lg'\n                  disabled={isSubmitting}\n                  focusableWhenDisabled\n                  className='data-disabled:opacity-100'\n                >\n                  <AnimatePresence mode='popLayout' initial={false}>\n                    {isSubmitting && (\n                      <motion.span\n                        key='spinner'\n                        className='flex'\n                        variants={spinnerVariants}\n                        initial='enter'\n                        animate='visible'\n                        exit='exit'\n                        transition={PANEL_TRANSITION}\n                      >\n                        <LoaderCircleIcon className='animate-spin' />\n                      </motion.span>\n                    )}\n                  </AnimatePresence>\n                  <motion.span layout transition={labelTransition}>\n                    {submitLabel}\n                  </motion.span>\n                </Button>\n              </div>\n              {hasError && <FieldError match>{error}</FieldError>}\n            </Field>\n            <p className='text-muted-foreground text-xs'>{HERO.note}</p>\n          </motion.form>\n        )}\n      </AnimatePresence>\n    </AnimatedSize>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/heroes-03/waitlist-form.tsx"
    },
    {
      "path": "registry/ndeko/blocks/heroes/heroes-03/issue-preview.tsx",
      "content": "import { ClockIcon } from '@/registry/ndeko/lib/icons';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\nimport { Chip } from '@/registry/ndeko/ui/chip';\n\nimport { ISSUE } from './data';\n\nexport function IssuePreview() {\n  return (\n    <div\n      aria-hidden='true'\n      className='bg-foreground/[0.025] rounded-2xl p-6 sm:p-8'\n    >\n      <div className='bg-card hairline-ring ring-border dark:bg-foreground/[0.04] motion-safe:animate-float flex flex-col gap-4 rounded-xl p-5 shadow-[0_1px_2px_rgb(0_0_0/0.04),0_12px_32px_-16px_rgb(0_0_0/0.14)]'>\n        <div className='flex items-center gap-2.5'>\n          <Avatar\n            className='size-7'\n            seed={ISSUE.author.name}\n            role='img'\n            aria-label={ISSUE.author.name}\n          />\n          <div className='flex min-w-0 flex-col'>\n            <p className='truncate text-[13px] font-medium'>\n              {ISSUE.publication}\n            </p>\n            <p className='text-muted-foreground text-xs'>{ISSUE.number}</p>\n          </div>\n        </div>\n        <div className='flex flex-col gap-1.5'>\n          <p className='text-sm font-medium text-balance'>{ISSUE.subject}</p>\n          <p className='text-muted-foreground text-[13px] leading-relaxed'>\n            {ISSUE.excerpt}\n          </p>\n        </div>\n        <div className='flex items-center gap-2'>\n          <Chip color='var(--info)'>{ISSUE.status}</Chip>\n          <span className='text-muted-foreground inline-flex items-center gap-1 text-xs tabular-nums'>\n            <ClockIcon className='size-3.5' />\n            {ISSUE.sendsAt}\n          </span>\n        </div>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/heroes-03/issue-preview.tsx"
    },
    {
      "path": "registry/ndeko/blocks/heroes/heroes-03/data.ts",
      "content": "export const HERO = {\n  eyebrow: 'Private beta',\n  title: 'You write the issue, Fernpost sends it to every reader',\n  description:\n    'Drafts, schedules and subscriber lists in one quiet editor. Leave your address and we send an invite as soon as a seat opens.',\n  note: 'One email when your invite is ready, nothing else until you sign in',\n};\n\nexport const ISSUE = {\n  author: { name: 'Ama Mensah' },\n  publication: 'Notes from the reading room',\n  number: 'Issue 48',\n  subject: 'Three books about rivers, and one about leaving',\n  excerpt:\n    'This week I read slowly on purpose. Here is what stayed with me, and the passage I copied into the margin of my notebook.',\n  status: 'Scheduled',\n  sendsAt: 'Tue 07:00',\n};\n",
      "type": "registry:component",
      "target": "components/blocks/heroes-03/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "heroes"
  ],
  "type": "registry:block"
}