# Add the "Digital Resources" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/digital-resources) to this Pantheon Content Publisher (P1) Next.js project. A grid of e-resources by category, each with a description, an at-home access note and a link, plus a tech-help banner.

## Steps

1. Create `components/puck/digital-resources-block.tsx` with the exact file contents below. If `components/puck/` doesn't exist, find the folder where this project keeps its Puck components (look at the imports in `puck.config.tsx`) and put it there.
2. In `puck.config.tsx`, import it: `import { digitalResourcesBlock } from "./components/puck/digital-resources-block";`
3. Register it under `components` as `DigitalResourcesBlock: digitalResourcesBlock`.
4. Add `"DigitalResourcesBlock"` to the best-fitting entry in `categories` (this block's library category is "Libraries"). Create a category only if none fits.
5. Run the project's type check (usually `pnpm typecheck`) and resolve anything project-specific.
6. If `package.json` has a `sync:registry` script, tell the user it must run (or that CI will run it) before the new component appears in the P1 editor.

## Rules

- Do not add dependencies. The block is self-contained by design: one type-only import from `@puckeditor/core`, Tailwind v4 classes, no client JavaScript.
- Keep the files as-is unless the user asks for changes. The accent color is `indigo-*`; if the project has brand colors, offer to swap them with a find-and-replace on `indigo-`.
- Images are plain `imageUrl` + `imageAlt` text fields. If this project defines a P1 media-library field (search for `"p1-media"`), offer to switch to it.
- Don't change prop names in `defaultProps`. Content editors' saved pages depend on them.

## File: `components/puck/digital-resources-block.tsx`

```tsx
import type { ComponentConfig } from "@puckeditor/core";

/**
 * Digital Resources — the library's e-resources as a grid of cards: category, description,
 * an "at home with your card" note and a link. Generic labels so editors name their own services.
 * Register: `DigitalResourcesBlock: digitalResourcesBlock` in puck.config.tsx.
 */

type Heading = "h1" | "h2" | "h3" | "h4";

type Icon = "headphones" | "play" | "language" | "search" | "news" | "book";

type Resource = {
  icon: Icon;
  category: string;
  name: string;
  description: string;
  access: string;
  linkLabel: string;
  href: string;
};

export type DigitalResourcesProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  resources: Resource[];
  helpText: string;
  helpLabel: string;
  helpHref: string;
};

const childLevel = { h1: "h2", h2: "h3", h3: "h4", h4: "h5" } as const;

const icons: Record<Icon, React.ReactNode> = {
  headphones: <path strokeLinecap="round" strokeLinejoin="round" d="M4 15v-3a8 8 0 1 1 16 0v3M4 15a2 2 0 0 1 2-2h1v7H6a2 2 0 0 1-2-2v-3Zm16 0a2 2 0 0 0-2-2h-1v7h1a2 2 0 0 0 2-2v-3Z" />,
  play: <path strokeLinecap="round" strokeLinejoin="round" d="M3.75 5.25h16.5v13.5H3.75zM10 9.25v5.5l4.5-2.75L10 9.25Z" />,
  language: <path strokeLinecap="round" strokeLinejoin="round" d="m10.5 21 5.25-11.25L21 21m-9-3h7.5M3 5.621a48.474 48.474 0 0 1 6-.371m0 0c1.12 0 2.233.038 3.334.114M9 5.25V3m3.334 2.364C11.176 10.658 7.69 15.08 3 17.502m9.334-12.138c.896.061 1.785.147 2.666.257m-4.589 8.495a18.023 18.023 0 0 1-3.827-5.802" />,
  search: <path strokeLinecap="round" strokeLinejoin="round" d="m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z" />,
  news: <path strokeLinecap="round" strokeLinejoin="round" d="M12 7.5h1.5m-1.5 3h1.5m-7.5 3h7.5m-7.5 3h7.5m3-9h3.375c.621 0 1.125.504 1.125 1.125V18a2.25 2.25 0 0 1-2.25 2.25M16.5 7.5V18a2.25 2.25 0 0 0 2.25 2.25M16.5 7.5V4.875c0-.621-.504-1.125-1.125-1.125H4.125C3.504 3.75 3 4.254 3 4.875V18a2.25 2.25 0 0 0 2.25 2.25h13.5M6 7.5h3v3H6v-3Z" />,
  book: <path strokeLinecap="round" strokeLinejoin="round" d="M12 6.042A8.967 8.967 0 0 0 6 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 0 1 6 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 0 1 6-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0 0 18 18a8.967 8.967 0 0 0-6 2.292m0-14.25v14.25" />,
};

export const digitalResourcesBlock: ComponentConfig<DigitalResourcesProps> = {
  label: "Digital Resources",
  fields: {
    heading: { type: "text", label: "Heading" },
    headingLevel: {
      type: "select",
      label: "Heading level",
      options: [
        { label: "H1", value: "h1" },
        { label: "H2", value: "h2" },
        { label: "H3", value: "h3" },
        { label: "H4", value: "h4" },
      ],
      metadata: { help: "Sets the page outline for screen readers and search. The look doesn't change." },
    },
    intro: { type: "textarea", label: "Intro" },
    resources: {
      type: "array",
      label: "Resources",
      min: 1,
      max: 12,
      getItemSummary: (item) => item?.name || item?.category || "Resource",
      defaultItemProps: { icon: "book", category: "E-books", name: "New resource", description: "", access: "Use at home with your card", linkLabel: "Open", href: "" },
      arrayFields: {
        icon: {
          type: "select",
          label: "Icon",
          options: [
            { label: "Headphones", value: "headphones" },
            { label: "Play", value: "play" },
            { label: "Languages", value: "language" },
            { label: "Search", value: "search" },
            { label: "Newspaper", value: "news" },
            { label: "Book", value: "book" },
          ],
        },
        category: { type: "text", label: "Category", metadata: { help: "Small label above the name, such as Streaming." } },
        name: { type: "text", label: "Name", metadata: { help: "Your service's name, or a plain description of it." } },
        description: { type: "textarea", label: "Description" },
        access: { type: "text", label: "Access note", metadata: { help: "Such as Use at home with your card, or In the library only. Leave blank to hide it." } },
        linkLabel: { type: "text", label: "Link text", metadata: { help: "Such as Start reading. Leave blank to use Open." } },
        href: { type: "text", label: "Link" },
      },
    },
    helpText: { type: "text", label: "Help line", metadata: { help: "Such as New to e-books? Leave blank to hide the help line." } },
    helpLabel: { type: "text", label: "Help link text" },
    helpHref: { type: "text", label: "Help link" },
  },
  defaultProps: {
    heading: "Read, watch and learn from anywhere",
    headingLevel: "h2",
    intro: "Your Cedar Valley library card unlocks thousands of e-books, films, courses and research tools. Sign in with your card number and PIN; it's all free.",
    resources: [
      { icon: "headphones", category: "E-books & audiobooks", name: "E-books & audiobooks app", description: "Borrow bestsellers, kids' books and audiobooks on your phone, tablet or e-reader. Up to 10 loans at a time.", access: "Use at home with your card", linkLabel: "Start reading", href: "/digital/ebooks" },
      { icon: "play", category: "Streaming", name: "Film & TV streaming", description: "Documentaries, indie films, classic movies and kids' shows, with eight free streams each month.", access: "Use at home with your card", linkLabel: "Start watching", href: "/digital/streaming" },
      { icon: "language", category: "Learning & languages", name: "Language learning", description: "Self-paced lessons in more than 40 languages, including English for speakers of other languages.", access: "Use at home with your card", linkLabel: "Start a lesson", href: "/digital/languages" },
      { icon: "book", category: "Learning & languages", name: "Online courses & tutoring", description: "Video courses in software, business and creative skills, plus live homework help for K–12 students from 2 to 11 p.m.", access: "Use at home with your card", linkLabel: "Browse courses", href: "/digital/learning" },
      { icon: "search", category: "Research databases", name: "Research & genealogy", description: "Magazine and journal articles, consumer reports, business directories and family history records.", access: "Most at home with your card; genealogy in the library", linkLabel: "See all databases", href: "/digital/databases" },
      { icon: "news", category: "Newspapers", name: "Newspapers & magazines", description: "Full digital editions of national and local papers, plus 3,000 magazines, with back issues to 1985.", access: "Use at home with your card", linkLabel: "Read the news", href: "/digital/news" },
    ],
    helpText: "New to digital borrowing? We'll set up your device with you.",
    helpLabel: "Book a tech help session",
    helpHref: "/tech-help",
  },
  render: ({ heading, headingLevel, intro, resources, helpText, helpLabel, helpHref }) => {
    const H = headingLevel || "h2";
    const Sub = childLevel[H] ?? "h3";
    const list = (resources ?? []).filter((r) => r?.name);

    return (
      <section className="bg-neutral-50 px-4 py-16 sm:px-6 sm:py-20 lg:px-8 lg:py-24">
        <div className="mx-auto max-w-7xl">
          {heading || intro ? (
            <div className="max-w-2xl">
              {heading ? <H className="font-serif text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl">{heading}</H> : null}
              {intro ? <p className="mt-4 text-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}
            </div>
          ) : null}

          {list.length ? (
            <ul role="list" className={`grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3 ${heading || intro ? "mt-10 sm:mt-12" : ""}`}>
              {list.map((r, i) => (
                <li key={`${r.name}-${i}`} className="group relative flex flex-col rounded-2xl bg-white p-6 shadow-xs ring-1 ring-neutral-200 transition hover:-translate-y-0.5 hover:shadow-md hover:ring-indigo-200 motion-reduce:transition-none motion-reduce:hover:translate-y-0">
                  <div className="flex items-center gap-3">
                    <span className="grid size-11 shrink-0 place-items-center rounded-xl bg-indigo-50 text-indigo-700 ring-1 ring-indigo-600/10 transition group-hover:bg-indigo-600 group-hover:text-white">
                      <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" className="size-6">
                        {icons[r.icon] ?? icons.book}
                      </svg>
                    </span>
                    {r.category ? <p className="text-xs font-semibold tracking-wide text-neutral-600 uppercase">{r.category}</p> : null}
                  </div>
                  <Sub className="mt-5 text-lg font-semibold tracking-tight text-neutral-950">
                    {r.href ? (
                      <a href={r.href} className={`rounded-sm outline-none after:absolute after:inset-0 after:rounded-2xl focus-visible:after:outline-2 focus-visible:after:outline-offset-2 focus-visible:after:outline-indigo-600`}>
                        {r.name}
                      </a>
                    ) : (
                      r.name
                    )}
                  </Sub>
                  {r.description ? <p className="mt-2 text-sm leading-6 text-pretty text-neutral-600">{r.description}</p> : null}
                  <div className="mt-auto flex flex-wrap items-center justify-between gap-3 pt-5">
                    {r.access ? (
                      <p className="inline-flex items-center gap-1.5 rounded-full bg-neutral-100 px-2.5 py-1 text-xs font-medium text-neutral-700">
                        <svg aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" className="size-3.5 text-indigo-600">
                          <path d="M8.543 2.232a.75.75 0 0 0-1.085 0l-5.25 5.5A.75.75 0 0 0 2.75 9H4v4a1 1 0 0 0 1 1h1.5a1 1 0 0 0 1-1v-2h1v2a1 1 0 0 0 1 1H11a1 1 0 0 0 1-1V9h1.25a.75.75 0 0 0 .543-1.268l-5.25-5.5Z" />
                        </svg>
                        {r.access}
                      </p>
                    ) : null}
                    {r.href ? (
                      <span aria-hidden="true" className="inline-flex items-center gap-1 text-sm font-semibold text-indigo-700">
                        {r.linkLabel || "Open"}
                        <svg viewBox="0 0 20 20" fill="currentColor" className="size-4 transition group-hover:translate-x-0.5">
                          <path fillRule="evenodd" d="M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z" clipRule="evenodd" />
                        </svg>
                      </span>
                    ) : null}
                  </div>
                </li>
              ))}
            </ul>
          ) : null}

          {helpText || helpLabel ? (
            <div className="mt-10 flex flex-col gap-3 rounded-2xl bg-indigo-950 px-6 py-5 text-white sm:flex-row sm:items-center sm:justify-between">
              {helpText ? <p className="text-base font-medium text-pretty">{helpText}</p> : null}
              {helpLabel ? (
                <a
                  href={helpHref || "#"}
                  className="inline-flex min-h-11 shrink-0 items-center justify-center rounded-xl bg-white px-5 py-2.5 text-sm font-semibold text-indigo-950 transition hover:bg-indigo-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white"
                >
                  {helpLabel}
                </a>
              ) : null}
            </div>
          ) : null}
        </div>
      </section>
    );
  },
};
```
