Skip to content

Restore the gap above top-level sidebar sections - #158

Merged
tenphi merged 1 commit into
mainfrom
claude/sidebar-section-gap
Oct 15, 2026
Merged

tenphi merged 1 commit into
mainfrom
claude/sidebar-section-gap

Conversation

@tenphi

@tenphi tenphi commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Top-level sidebar sections (Start, Author, Customize, …) lost the gap above their headings, which made the sidebar look dense. This was a regression from #147.

Cause

Before #147, the two spacing rules had different specificity:

TopLevelSpacing: { $: ".top-level > li + li", blockMargin: "0 start" },
GroupSpacing: { $: ".top-level > li + li", blockMargin: { "@own(:is(… :has(> .sidebar-section-label)))": "($gap * 2.5) start" } },

The :is() condition made GroupSpacing more specific, so sections kept their gap. #147 moved both rules to states on ul > li + li. Tasty compiles states to :where(), which adds no specificity:

ul > li + li:where([data-section][data-top-level]) { margin-block: calc(var(--gap) * 2.5) 0; }
ul > li + li:where([data-top-level]) { margin-block: 0; }

Both rules match a section, and they now tie. Tasty emits the zero-margin rule last, so it wins.

Fix

TopLevelSpacing now uses @own(top-level & !section). The two rules can no longer match the same item, so their order doesn't matter. The resulting spacing matches what the sidebar had before #147.

  • Sidebar.TopLevelSpacing and Sidebar.GroupSpacing keep their names, and partial theme.styles overrides merge as before.
  • docs/component-styles.md lists only the names, so it needs no update.

On the reference site, each top-level section now has a 20px margin above it (2.5 × the 8px --gap). The first item, Overview, stays flush.

Test

A new spec in component-ownership.spec.ts checks two things:

  • In the sidebar-badges fixture, the second top-level section has a 20px margin above it.
  • In the manual fixture, adjacent non-section top-level entries stay flush.

Without the fix, the spec fails (Received: "0px"). With the fix, it passes.

Review and validation

I followed the local review procedure (.claude/skills/review/SKILL.md) for the diff and found no violations:

  • @own targets only the selected <li>.
  • No structural $ path is repeated in a state map.
  • The customization contract and the docs are unchanged.

While checking for related issues, I looked at the other sidebar sub-elements that share a selector. Base and hover pairs such as Close/HoverClose are safe because Tasty emits rules without states first. The remaining stateful pairs either can't match together or differ in specificity. I did not audit the other components that #147 converted.

All of these passed locally:

  • pnpm build
  • pnpm lint (zero warnings)
  • pnpm format:check
  • pnpm typecheck
  • pnpm test (409 tests)
  • pnpm check:browser (97 tests)
  • pnpm check:theming

Entropy change (sidebar styles): Neutral. One existing condition is narrowed, with a comment explaining why. There is no new concept, sub-element or option.

Entropy change (browser tests): Slightly Increased, justified. One focused regression spec covers both sides of the spacing rule.

There are no exceptions or follow-ups.

🤖 Generated with Claude Code

#147 moved Sidebar.TopLevelSpacing and Sidebar.GroupSpacing from
class and :is() selectors to the `top-level` and `section` states. Tasty
compiles states to zero-specificity :where(), so both rules now tie on
`ul > li + li`. Tasty emitted the zero-margin TopLevelSpacing rule last,
so it won and sections lost their gap.

Limit TopLevelSpacing to `top-level & !section` so the two rules can't
match the same item and rule order no longer matters. This matches the
spacing from before #147, and both sub-element names stay the same.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@tenphi
tenphi merged commit 7778fc9 into main Oct 15, 2026
12 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant