Block library: 15 blocks, registry, primitives, templates, manifest, eject
- @intecion/ipal-kit/blocks: libraryBlocks() opt-in, one builder per block, field
builders, option merging, blockLibraryManifest, faqItemsFromLayout
- @intecion/ipal-kit/blocks/rsc: createBlockRegistry, the block components and UI
primitives (token utilities only; next/image and next/link passed in)
- @intecion/ipal-kit/templates: 10 page templates as createSeeder data
- createSeeder: { $form: title } references
- ipal-blocks eject <block>
- tests: options, rendering and a11y per block, Payload + seeding, GraphQL, admin
wording, schema snapshot (versioning), eject imports
- shorter admin labels: link "New tab", table of contents "Show contents"
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7918eaf6d4
commit
2d1cc0e77d
@@ -0,0 +1,49 @@
|
||||
import type { LibraryBlockProps } from '../../context.js'
|
||||
import type { BaseBlockData, LinkData, MediaValue } from '../../data.js'
|
||||
|
||||
import { MEDIA_SIZES } from '../../../media/mediaProps.js'
|
||||
import { Buttons, headingId } from '../../ui/Buttons.js'
|
||||
import { cx, parts } from '../../ui/cx.js'
|
||||
import { TitleLink } from '../../ui/TitleLink.js'
|
||||
|
||||
export type TeamMember = { bio?: null | string; heading: string; id?: null | string; link?: LinkData; media?: MediaValue; text?: null | string }
|
||||
export type TeamBlockData = { items?: null | TeamMember[] } & BaseBlockData
|
||||
|
||||
export const TEAM_PARTS = {
|
||||
name: 'font-heading text-h4 leading-heading text-fg-strong',
|
||||
bio: 'text-sm text-fg-muted',
|
||||
grid: 'grid gap-gap sm:grid-cols-2 lg:grid-cols-3',
|
||||
list: 'grid gap-6',
|
||||
listItem: 'grid gap-6 sm:grid-cols-[10rem_1fr] sm:items-start',
|
||||
photo: 'aspect-square h-auto w-full rounded-media object-cover',
|
||||
role: 'text-sm text-fg-muted',
|
||||
}
|
||||
|
||||
/** People with a photo, name, role, a short bio and a profile link (the name links to it). */
|
||||
export function TeamBlock(props: LibraryBlockProps<TeamBlockData>) {
|
||||
const { classNames, ctx, header, isFirst, items, links, locale, settings, ui, variant } = props
|
||||
if (!items?.length) {return null}
|
||||
const c = parts(TEAM_PARTS, classNames)
|
||||
const id = headingId(props)
|
||||
const list = variant === 'list'
|
||||
return (
|
||||
<ui.Section block={props.blockType} labelledBy={id} settings={settings}>
|
||||
<ui.SectionHeader as={isFirst ? 'h1' : 'h2'} header={header} id={id} />
|
||||
<ul className={list ? c.list : c.grid}>
|
||||
{items.map((m, i) => (
|
||||
<li className={cx('flex flex-col gap-3', list && c.listItem)} key={m.id ?? i}>
|
||||
<ui.Media className={c.photo} resource={m.media} sizes={list ? '10rem' : MEDIA_SIZES.third} />
|
||||
<div className="flex flex-col gap-1">
|
||||
<h3 className={c.name}><TitleLink link={m.link} Link={ctx.Link} locale={locale} resolve={ctx.content.resolveLink} stretch={false}>
|
||||
{m.heading}
|
||||
</TitleLink></h3>
|
||||
{m.text ? <p className={c.role}>{m.text}</p> : null}
|
||||
{m.bio ? <p className={c.bio}>{m.bio}</p> : null}
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<Buttons CMSLink={ui.CMSLink} links={links} locale={locale} />
|
||||
</ui.Section>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import type { Field } from 'payload'
|
||||
|
||||
import { buildLinkField } from '../../../links/buildLinkField.js'
|
||||
import { adminText, defineLibraryBlock, variantOption } from '../../define.js'
|
||||
import { buildItemsField, buildMediaField } from '../../fields.js'
|
||||
|
||||
export const TEAM_VARIANTS = [variantOption('grid', 'Grid', 'Siatka'), variantOption('list', 'List', 'Lista')] as const
|
||||
|
||||
/** Team — people with a photo, name, role and a profile link. */
|
||||
export const buildTeamBlock = defineLibraryBlock({
|
||||
slug: 'team',
|
||||
fields: ({ maxItems = 24 }) => [
|
||||
buildItemsField({
|
||||
fields: [
|
||||
buildMediaField({ label: adminText('Photo', 'Zdjęcie') }),
|
||||
{
|
||||
type: 'row',
|
||||
fields: [
|
||||
{ name: 'heading', type: 'text', admin: { width: '50%' }, label: adminText('Name', 'Imię i nazwisko'), localized: true, required: true },
|
||||
{ name: 'text', type: 'text', admin: { placeholder: adminText('Co-founder', 'Współzałożycielka'), width: '50%' }, label: adminText('Role', 'Stanowisko'), localized: true },
|
||||
],
|
||||
},
|
||||
{ name: 'bio', type: 'textarea', admin: { rows: 3 }, label: adminText('Short bio', 'Krótki opis'), localized: true },
|
||||
buildLinkField({ name: 'link', appearances: false }),
|
||||
] as Field[],
|
||||
labels: { plural: adminText('People', 'Osoby'), singular: adminText('Person', 'Osoba') },
|
||||
maxRows: maxItems,
|
||||
}),
|
||||
],
|
||||
interfaceName: 'TeamBlock',
|
||||
labels: { plural: adminText('Teams', 'Zespoły'), singular: adminText('Team', 'Zespół') },
|
||||
links: { maxRows: 1 },
|
||||
variants: TEAM_VARIANTS,
|
||||
})
|
||||
Reference in New Issue
Block a user