-
Notifications
You must be signed in to change notification settings - Fork 4k
Dynamic TOC height #3233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Dynamic TOC height #3233
Conversation
🦋 Changeset detectedLatest commit: d61db35 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refines the styling and behavior of the TableOfContents by accounting for the announcement banner height and other header variations. Key changes include:
- Updating Tailwind configuration variants to accommodate new header and announcement states.
- Introducing a client-side script (TableOfContentsScript) for dynamic TOC positioning.
- Migrating from the legacy TableOfContents export to a more adaptive component (AdaptiveTableOfContents) and updating related layout and styling.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
packages/gitbook/tailwind.config.ts | Updated variant selectors to improve header and announcement styling. |
packages/gitbook/src/components/TableOfContents/index.ts | Refactored exports to include AdaptiveTableOfContents and additional modules. |
packages/gitbook/src/components/TableOfContents/TableOfContentsScript.tsx | Added a new client-side script for dynamic TOC size and position adjustments. |
packages/gitbook/src/components/TableOfContents/TableOfContents.tsx | Adjusted class names and included new dynamic positioning and announcement variants. |
packages/gitbook/src/components/TableOfContents/AdaptiveTableOfContents.tsx | Created a wrapper for combining server-rendered TOC with dynamic behavior. |
packages/gitbook/src/components/SpaceLayout/SpaceLayout.tsx | Replaced TableOfContents with AdaptiveTableOfContents for enhanced functionality. |
packages/gitbook/src/components/RootLayout/globals.css | Updated CSS selector for announcement banner to use an ID instead of a class. |
packages/gitbook/src/components/RootLayout/CustomizationRootLayout.tsx | Modified header class handling to use an array-based syntax for conditional classes. |
packages/gitbook/src/components/Announcement/AnnouncementBanner.tsx | Assigned an ID to the banner element, ensuring consistency with the new selectors. |
Comments suppressed due to low confidence (1)
packages/gitbook/src/components/RootLayout/CustomizationRootLayout.tsx:79
- Ensure that the tcls class concatenation helper correctly handles arrays of classes; if not, convert the array to a space-delimited string before passing it to avoid unexpected behavior.
: ['site-header', 'scroll-pt-[76px]'], // Take the sticky header in consideration for the scrolling
Summary of the deployments: Version 1
Version 2
Test content |
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
This PR adds a client-side available height calculation for the TableOfContents component. This solves two issues:
Important to note: to prevent layout shift the TOC still has a number of
top-*
andh-*
classes added to it, to set its initial positioning as close as possible on the server. Once the client loads we override these classes with the dynamic height through CSS variables.Before
CleanShot.2025-05-14.at.11.04.20.mp4
After
CleanShot.2025-05-14.at.11.07.12.mp4
Fixes RND-7090