Repository navigation
fix: keep prose spacing out of component anatomy; add CardGrid - #194
Merged
Merged
Conversation
Prose block spacing outranked component roots and tied component sub-elements, so tab panels sat 24px under the tab list, content after the hidden tab heading or caption got another 24px, the copy button moved off its corner depending on stylesheet order, and card bodies got 24px on top of the card gap. Reset that spacing in each owning component with structural selectors that outrank prose, and pack card rows to the top when a grid stretches the card. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cards placed side by side in a grid each picked up Markdown's 24px block spacing after the first, so neighbouring cards in a row had different tops and heights. CardGrid lays cards out in one column, or two from @sm, and its Card sub-element removes that spacing so the grid gap alone separates cards. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged
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.
Problem
Markdown prose spacing (
.cookbook-markdown-content×3 * + :where(…), specificity 0,3,0) applies a 3x top margin to every block that follows a sibling — including component anatomy inside tabs, code groups, code blocks and cards:.td-code-block.td-code-block > [data-element="CopyButton"]ties prose at 0,3,0, so itsmargin: 0only wins when its rule happens to be emitted after the prose rule. When a CodeGroup renders inside page content first (Glaze home page), the button picks up a 24px top margin and sits 32px from the top but 8px from the right.divafter the title got 24px on top of the card's 1.5x grid gap, and a card stretched by a surrounding grid split its extra height between the title and description rows, pushing short descriptions down.CardGridgives the first card the same margin).Fix
Each owning component now resets the affected spacing with a structural selector that outranks prose regardless of stylesheet order:
TabsTab(new)> List ~ Tab— panels sit directly under the listTabBody(new element)> Heading + Body— content starts at the panel paddingCodeGroupMarkdownCodeBlock(new)Caption + MarkdownCodeBlock— the caption's own 1x end margin separates it from the codeMarkdownCodeBlockCopyButton,HoverCopyButton,CopiedButton> pre + CopyButton— corner placement no longer depends on rule orderCardBody(new element) +alignContent: start> h3 + Body— the grid gap alone separates title and body; rows stay at the top when stretchedTab and Card content is now wrapped in a
data-element="Body"div. New names are registered inCOOKBOOK_COMPONENT_SUB_ELEMENTSand documented indocs/component-styles.md, including a note in Block spacing on how to add space back.New
CardGridcomponentCardGridlays outCardelements in one column on narrow screens and two equal-height columns from@sm(40rem), with a 2x gap. ItsCardsub-element (> Card + Card) removes prose spacing between cards, so cards in a row share the same top and height. It is exported from@tenphi/cookbook/componentswith aCardGridPropstype, registered inCOOKBOOK_COMPONENT_NAMES, the config schema and the anatomy reference, and documented with an example in Authoring components. Changeset:minor.Behavior change: the existing browser assertion that a tab panel has a 24px top margin (pinned during the #135 style-ownership refactor) now expects 0px — that margin was the reported gap.
Verification
main(panel 24px below the list) and passes here.pnpm lint(0 warnings),pnpm test(468 passed), package typechecks,pnpm check:types,pnpm check:recipes,pnpm check:packages,pnpm knip,pnpm check:browser(126 passed).Entropy
Slightly Increased for renderer styling: five small margin resets, two
Bodywrappers, five new sub-element names and one new layout component (CardGrid), each relying on a sibling combinator partly for specificity (explained in a comment beside it). Slightly Decreased for site authors: tab, code group and card spacing no longer needs theme overrides, the copy button no longer depends on page-specific CSS order, and card grids no longer need a site-specific wrapper with margin workarounds.Considered and rejected: lowering the prose selector's specificity (it changes cascade outcomes across every prose/component interaction), and teaching prose spacing to skip
[hidden]siblings (it misses CSS-hidden captions and removes spacing between visible blocks around a hidden one).🤖 Generated with Claude Code