Conversation
…d Heading Adds two page-builder sections and, more to the point, the shared heading they both reuse — there was no heading primitive or title/description schema fragment in the kit, so every section declared its own ad hoc `title` field. - `lib/schemas/heading.ts`: a registered object type (required `title`, optional `description`), modelled on `customImage`/`customLink`, referenced by both sections as `type: "heading"`. - `packages/ui/components/ui/heading`: the matching primitive, following the `button` cva-with-enum pattern. Alignment is a prop rather than a schema field — no section lets an author choose it, each knows its own layout. - `section.featureColumns`: heading (title only) plus `featureColumn` items. - `section.processSteps`: heading (title and description) plus `processStep` items. Numbering is derived from array position at render, so reordering in Studio renumbers the list and there is no number field to keep in sync. Both presets ship the real copy they were designed from, which also makes the optional-description contrast visible without typing anything. Also fixes the template-selector popover, which had no height constraint: the preset grid grows with the number of registered sections and was running off the bottom of the viewport, making the last rows unreachable. This is the only way to insert a section, since the selector replaces the array's default add button, so it blocked the new sections outright. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds two page-builder sections and the shared heading component they both reuse.
The shared heading
There was no heading primitive and no title/description schema fragment in the kit — every section declares its own ad hoc
titlefield today. Both halves are new:apps/sanity/src/lib/schemas/heading.ts— a registered object type (requiredtitle, optionaldescription), modelled oncustomImage/customLink. Both sections reference it astype: "heading", so the pair is declared once.packages/ui/components/ui/heading/— the matching primitive, following thebuttoncva-with-enum pattern.Alignment is a component prop, not a schema field: no section lets an author choose it, each one knows how it lays itself out. Modelling a knob nobody asked for seemed worse than a default.
The sections
section.featureColumnsfeatureColumn— icon, title, descriptionsection.processStepsprocessStep— title, descriptionStep numbers (
01.,02.…) are derived from array position at render time, so reordering in Studio renumbers the list and there is no number field to drift out of sync.Neither section needs a
query.tsGROQ fragment.CARDS_GRID_FRAGMENTexists only to dereference an internal page link viaLINK_FRAGMENT; images resolve throughprepareImagePropswithout GROQ help, which is whyCarouselhas images and no fragment.Popover fix
packages/sanity-template-selectorrendered its popover with no height constraint. The preset grid grows with the number of registered sections, so past a handful it runs off the bottom of the viewport and the last rows cannot be reached. Adding two presets was enough to trigger it.This is not cosmetic: the selector replaces the array's default add button, so the template browser is the only way to insert a section. Fixed with stock
PopoverProps—constrainSize(cap to available space) plusoverflow="auto"— no new dependency, no custom CSS.Worth knowing:
BlogandCarouselare registered but have no presets, which means they cannot currently be added to a page at all.Verification
pnpm gen:typesregenerated;Headingis one type, referenced by bothSectionFeatureColumnsandSectionProcessStepstsc --noEmitclean onapps/sanityandpackages/sanity-template-selectornext lintclean (theno-anonymous-default-exportwarning on the two new schemas matches every existing section schema)page.sectionsBody; both preset payloads validated against the registered schema namesPresets ship the copy the sections were designed from, so dropping both onto a page shows the optional-description contrast without typing anything.
Notes for review
Four pre-existing defects surfaced while building this. None are fixed here — happy to send separate PRs:
READMEsayspnpm gen; no such script exists. It ispnpm turbo gen.templates/sanitySection.hbsimportsI<Name>SectionPropsbutsanitySectionTypes.hbsexportsI<Name>Props— generated code does not compile.templates/sanitySectionSchema.hbsimportssectionMarginFields, whichcommonFields.tsxdoes not export (it issectionCommonFields) — also does not compile.name: "section.{{ sectionName }}"from raw input while the render map uses{{ loweraseFirstLetter sectionName }}. EnteringFeatureColumnsyields schemasection.FeatureColumnsagainst map keysection.featureColumns— the section saves fine in Studio and silently renders nothing. Entering camelCase avoids it. This one fails silently, unlike 2 and 3.Separately,
pnpm formatis broken repo-wide:prettier.config.jssetstailwindConfig: "./packages/ui/tailwind.config.ts", which no longer exists after the Tailwind v4 migration. The generator's inserted lines are hand-formatted in this PR as a result.🤖 Generated with Claude Code