Skip to content

feat: Add TableOfContents component and fix Slug field button styling#429

Merged
ainsleyclark merged 5 commits intomainfrom
claude/add-sveltekit-component-4NnS4
Mar 13, 2026
Merged

feat: Add TableOfContents component and fix Slug field button styling#429
ainsleyclark merged 5 commits intomainfrom
claude/add-sveltekit-component-4NnS4

Conversation

@ainsleyclark
Copy link
Contributor

Summary

This PR adds a new TableOfContents component to the sveltekit-helper package with scrollspy functionality, and fixes a styling issue in the Payload helper's Slug field component.

Key Changes

TableOfContents Component (New)

  • Added new TableOfContents.svelte component with the following features:
    • Auto-discovery: Automatically discovers headings from DOM using configurable CSS selectors
    • Scrollspy: Tracks scroll position and highlights the active section in the TOC
    • Flexible configuration: Supports both auto-generated items from DOM and manually provided items via props
    • Data attributes: Uses data-sidebar-content and data-sidebar-selector attributes for DOM discovery
    • Customizable: Props for heading, border display, content selector, heading selector, and scroll offset
    • Styling: Includes responsive design with optional left border on tablet and above
  • Exported new component from packages/sveltekit-helper/src/components/index.ts

Slug Field Component Fix

  • Fixed build error in packages/payload-helper/src/fields/Slug/Component.tsx by:
    • Removing unsupported style prop from Payload's Button component
    • Wrapping the button in a <span> element to apply the styling instead

Implementation Details

  • The TableOfContents component uses Svelte 5's $state and $props runes for reactivity
  • Scrollspy detection includes a bottom threshold to ensure the last section is highlighted when scrolled to the bottom
  • The component is designed to work alongside richtext/content areas with heading elements that have id attributes
  • Priority order for heading selector: explicit prop > data-sidebar-selector attribute > default h2

https://claude.ai/code/session_01Qrcz9fPxJBQk2GD1G3ZAug

claude added 2 commits March 13, 2026 16:37
Adds a new TableOfContents Svelte 5 component that wraps Sidebar with
scrollspy logic. Headings are auto-discovered from the DOM using
data-sidebar-content / data-sidebar-selector attributes by default, with
contentSelector and headingSelector props for explicit overrides.

https://claude.ai/code/session_01Qrcz9fPxJBQk2GD1G3ZAug
…n in Slug component

The Button component from @payloadcms/ui dropped the style prop, causing
a TS2322 type error during build. Wrap the button in a span to preserve
the margin/padding styles.

https://claude.ai/code/session_01Qrcz9fPxJBQk2GD1G3ZAug
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@claude

This comment has been minimized.

@claude

This comment has been minimized.

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.26%. Comparing base (7f6b060) to head (9218ceb).
⚠️ Report is 514 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #429      +/-   ##
==========================================
+ Coverage   64.59%   70.26%   +5.67%     
==========================================
  Files         154      187      +33     
  Lines        6064     7439    +1375     
==========================================
+ Hits         3917     5227    +1310     
+ Misses       2064     2012      -52     
- Partials       83      200     +117     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ainsleyclark ainsleyclark merged commit f194cae into main Mar 13, 2026
5 of 6 checks passed
@ainsleyclark ainsleyclark deleted the claude/add-sveltekit-component-4NnS4 branch March 13, 2026 17:42
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.

2 participants