Skip to content

Conversation

@carlagn
Copy link
Contributor

@carlagn carlagn commented Jul 29, 2025

Fixes #DC-4631

Summary by CodeRabbit

  • New Features

    • Introduced a customizable dropdown menu component with support for dark mode, right-click activation, and flexible positioning.
    • Added a new documentation item layout with improved table of contents (TOC) rendering for both desktop and mobile views.
    • Enhanced the TOC with a dropdown menu, enabling quick access to copy raw markdown and open the page in various AI chat platforms.
    • Added new React SVG icon components for use in menus and navigation.
  • Enhancements

    • Updated the icon component to support both standard icon classes and custom icon elements.
    • Extended the icon set with Markdown and OpenAI icons.
    • Added a new CSS variable for disabled font color, ensuring consistent theming across light and dark modes.
  • Bug Fixes

    • Removed unused React imports and console log statements for cleaner code and improved performance.
  • Style

    • Added and updated styles for dropdowns, documentation layouts, and the TOC to improve appearance and responsiveness.

@github-actions
Copy link
Contributor

Dangerous URL check

No absolute URLs to prisma.io/docs found.
No local URLs found.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 29, 2025

Redirect check

This PR probably requires the following redirects to be added to static/_redirects:

  • This PR does not change any pages in a way that would require a redirect.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jul 29, 2025

Deploying docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 86bfb92
Status: ✅  Deploy successful!
Preview URL: https://b9ee7195.docs-51g.pages.dev
Branch Preview URL: https://feat-dc-4631-dropdown-toc.docs-51g.pages.dev

View logs

@carlagn carlagn marked this pull request as ready for review July 29, 2025 15:11
@carlagn carlagn force-pushed the feat/DC-4631-dropdown-toc branch from 4352105 to 8a9c9f1 Compare August 1, 2025 13:20
aidankmcalister
aidankmcalister previously approved these changes Aug 3, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 4, 2025

Walkthrough

This update introduces several new React components and CSS modules, primarily enhancing the documentation site's layout, theming, and interactivity. New dropdown and table of contents (TOC) components are added with associated styles and SVG icons. Icon handling is extended to support custom icons. Theming variables and icon font classes are expanded, and minor code cleanups are performed throughout.

Changes

Cohort / File(s) Change Summary
Dropdown Component & Styles
src/components/content-dropdown/index.tsx, src/components/content-dropdown/styles.module.scss
Introduced a new dropdown React component with configurable anchor, items, and positioning; added corresponding SCSS module for styling.
TOC & Related Components
src/theme/TOC/index.tsx, src/theme/TOC/styles.module.css, src/theme/TOCItems/icons.tsx, src/theme/DocItem/TOC/Desktop/index.tsx, src/theme/DocItem/Layout/index.tsx, src/theme/DocItem/Layout/styles.module.css
Added new TOC component with dropdown actions, desktop TOC, layout components, and associated CSS modules and SVG icon exports.
Icon Component Update
src/components/Icon.tsx
Updated Icon to support both string-based and custom icon rendering, modifying props and conditional rendering logic.
CSS Theming and Icon Fonts
src/css/all.css, src/css/theming.css
Added new icon font classes for Markdown and OpenAI; introduced a new CSS variable for disabled font color in light and dark themes.
Minor Cleanups
src/theme/DocBreadcrumbs/index.tsx, src/theme/Tabs/index.tsx
Removed unused React imports and console log statements for cleaner code.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Dropdown
  participant TOC
  participant Clipboard
  participant ExternalSite

  User->>Dropdown: Clicks anchor or right-clicks (if enabled)
  Dropdown->>Dropdown: Toggles open/close state
  Dropdown->>Dropdown: Handles outside click/Escape to close

  User->>TOC: Opens TOC dropdown
  TOC->>Clipboard: Clicks "Copy Markdown" (fetches and copies)
  TOC->>ExternalSite: Clicks "Open in Chat" (opens new tab with URL)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Poem

In the docs where the dropdowns hop,
New icons and TOCs make navigation non-stop.
With custom themes and colors so bright,
Markdown and OpenAI icons now delight.
The rabbit reviews with a twitch of its nose—
"Such tidy code, as everyone knows!"
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8f4e46b and 86bfb92.

📒 Files selected for processing (2)
  • src/components/content-dropdown/styles.module.scss (1 hunks)
  • src/theme/TOC/index.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/content-dropdown/styles.module.scss
  • src/theme/TOC/index.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Check internal links
  • GitHub Check: runner / linkspector
  • GitHub Check: Lost Pixel
  • GitHub Check: Cloudflare Pages
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/DC-4631-dropdown-toc

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🧹 Nitpick comments (11)
src/theme/DocItem/Layout/styles.module.css (1)

6-10: Consider avoiding !important if possible.

While the !important declaration ensures the max-width constraint is enforced, it can make future styling harder to override. Consider if the specificity can be increased through selector chains instead.

 @media (min-width: 997px) {
   .docItemCol {
-    max-width: 75% !important;
+    max-width: 75%;
   }
 }
src/components/Icon.tsx (2)

5-6: Improve type safety for the customicon prop.

The customicon prop is typed as any, which defeats TypeScript's type checking benefits. Consider using ReactNode or JSX.Element for better type safety.

interface IconProps {
  icon?: string;
-  customicon?: any;
+  customicon?: ReactNode;
  color?: string;
  className?: string;
  size?: string;
  btn?: "left" | "right";
  fit?: "width" | "height";
}

40-56: Consider font size calculation for custom icons.

The conditional rendering logic is well-implemented. However, the dynamic font size calculation (lines 24-32) and resize event handling only work for the <i> element since iconRef is not attached to the <span> containing custom icons. This means custom icons will only use the provided size prop or default styling.

If dynamic sizing is needed for custom icons, consider attaching the ref to both elements or implementing a separate sizing strategy.

src/theme/TOC/index.tsx (1)

23-23: Improve type safety for metadata prop.

The metadata prop is typed as any, which reduces type safety. Consider creating a proper interface for the metadata object based on its expected structure.

+interface DocMetadata {
+  slug: string;
+  editUrl: string;
+  // Add other expected properties
+}

-export default function TOC({className, metadata, ...props}: Props & {metadata: any }): ReactNode {
+export default function TOC({className, metadata, ...props}: Props & {metadata: DocMetadata }): ReactNode {
src/theme/TOCItems/icons.tsx (1)

1-36: LGTM! Well-implemented SVG icon components.

The SVG icon components are properly structured with:

  • Appropriate dimensions and viewBox settings
  • currentColor usage for theme integration
  • Proper SVG path definitions for brand logos

The icons will integrate well with the theming system and provide consistent visual identity for the AI platform links.

Note: These appear to be brand logos for various AI platforms. Ensure compliance with each platform's brand guidelines and terms of service when using their logos.

src/components/content-dropdown/styles.module.scss (4)

1-1: Remove unused SCSS variable.

The $border-color variable is defined but never used in this stylesheet.

-$border-color: #2d3748;
-

41-48: Consider restructuring nested container selector.

The nested .container selector inside .overlayWrapper could be confusing since .container is also defined as a separate class. Consider using a more specific selector or restructuring.

 .overlayWrapper {
   opacity: 0;
   pointer-events: none;
   @media (max-width: 599px) {
     position: fixed;
     height: 100vh;
     z-index: 102;
     width: 100vw;
     background: rgb(9, 10, 21, 0.75);
     top: 0;
     left: 0;
   }
-  .container {
+  & .container {
     transform: translateY(-8px);
   }
   &.showOverlay {
-    .container {
+    & .container {
       transform: translateY(0);
     }
   }
 }

37-37: Use modern rgba() syntax.

Consider using the modern rgba() syntax for better browser compatibility and readability.

-    background: rgb(9, 10, 21, 0.75);
+    background: rgba(9, 10, 21, 0.75);

90-96: Consider alternatives to !important declarations.

While the !important declarations ensure proper positioning override, they can make future maintenance difficult. Consider if the specificity could be increased through other means.

If these overrides are truly necessary, consider documenting why !important is required in a comment for future maintainers.

src/components/content-dropdown/index.tsx (2)

66-66: Improve event handler typing.

Consider using a more specific event type instead of any for better type safety.

-        onClick={(e: any) => {
+        onClick={(e: React.MouseEvent<HTMLDivElement>) => {

72-76: Improve item mapping type safety.

Consider using a more specific type for items instead of any to improve type safety.

The current implementation works, but if the items have a known structure, consider defining a more specific interface:

type DropdownItem = React.ReactNode;

// Then in the component:
{items.map((item: DropdownItem, idx: number) => (
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7c7c4c and 8f4e46b.

📒 Files selected for processing (13)
  • src/components/Icon.tsx (2 hunks)
  • src/components/content-dropdown/index.tsx (1 hunks)
  • src/components/content-dropdown/styles.module.scss (1 hunks)
  • src/css/all.css (1 hunks)
  • src/css/theming.css (4 hunks)
  • src/theme/DocBreadcrumbs/index.tsx (1 hunks)
  • src/theme/DocItem/Layout/index.tsx (1 hunks)
  • src/theme/DocItem/Layout/styles.module.css (1 hunks)
  • src/theme/DocItem/TOC/Desktop/index.tsx (1 hunks)
  • src/theme/TOC/index.tsx (1 hunks)
  • src/theme/TOC/styles.module.css (1 hunks)
  • src/theme/TOCItems/icons.tsx (1 hunks)
  • src/theme/Tabs/index.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • src/theme/Tabs/index.tsx
🧰 Additional context used
🪛 Biome (2.1.2)
src/theme/TOC/index.tsx

[error] 33-33: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 34-34: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 39-39: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 44-44: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 49-49: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Check internal links
  • GitHub Check: runner / linkspector
  • GitHub Check: Lost Pixel
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (16)
src/theme/DocItem/Layout/styles.module.css (1)

1-4: CSS selector specificity looks appropriate.

The selectors target specific layout scenarios effectively - removing top margin from elements following headers and first children of articles within the doc container.

src/css/all.css (1)

847-853: Icon additions follow established patterns.

The new .fa-markdown and .fa-openai icon classes are properly implemented using the same ::before pseudo-element pattern as other icons in the file. The Unicode values are appropriate for FontAwesome icons.

src/theme/TOC/styles.module.css (1)

1-10: Sticky TOC positioning implemented correctly.

The sticky positioning with dynamic height calculation using CSS custom properties is well-implemented. The overflow settings appropriately handle scrollable content while maintaining horizontal visibility.

src/theme/DocBreadcrumbs/index.tsx (1)

1-1: Good cleanup of unused imports.

Removing the unused useEffect and useState imports is a good housekeeping practice that reduces bundle size and eliminates dead code.

src/theme/DocItem/TOC/Desktop/index.tsx (1)

7-16: Component logic and structure look solid.

The component properly extracts TOC data and front matter using Docusaurus hooks, and correctly passes all necessary props to the TOC component. The use of theme class names ensures consistent styling.

src/theme/DocItem/Layout/index.tsx (1)

21-40: LGTM! Well-structured TOC visibility logic.

The useDocTOC hook cleanly encapsulates the logic for determining when and how to render the TOC based on front matter settings, content availability, and viewport size. The responsive handling for desktop/mobile/SSR is appropriately implemented.

src/css/theming.css (1)

72-72: LGTM! Consistent theming implementation.

The addition of --disabled-font-color is well-implemented across all theme contexts with appropriate color values for light and dark themes. The consistent definition ensures the variable is available regardless of theme configuration.

src/components/content-dropdown/styles.module.scss (4)

17-27: LGTM!

The anchor button styling is well-structured with proper interactive states and consistent use of CSS custom properties for theming.


56-75: LGTM!

The container styling is well-structured with appropriate responsive behavior, smooth transitions, and good use of flexbox for layout.


77-88: LGTM!

The item styling provides good interactive feedback with smooth transitions and proper use of CSS custom properties for theming.


97-105: LGTM!

The child element styling and link color inheritance are well-implemented for the top positioning variant.

src/components/content-dropdown/index.tsx (5)

1-14: LGTM!

The imports are well-organized and the TypeScript interface is properly defined with appropriate optional properties and type annotations.


15-27: LGTM!

The component setup is well-structured with appropriate default values, proper state management, and good separation of concerns using custom hooks.


29-36: LGTM!

The keyboard event handling is properly implemented with appropriate cleanup, providing good accessibility support for closing the dropdown with the Escape key.


56-60: LGTM!

The anchor rendering is well-structured with appropriate conditional styling and proper use of Icon components for visual feedback.


61-83: LGTM!

The dropdown overlay and items rendering logic is well-implemented with proper event handling, conditional rendering, and appropriate use of React patterns.

@carlagn carlagn merged commit 8c5bbfe into main Aug 4, 2025
6 of 7 checks passed
@carlagn carlagn deleted the feat/DC-4631-dropdown-toc branch August 4, 2025 10:46
jlecordier pushed a commit to jlecordier/docs-1 that referenced this pull request Sep 3, 2025
* Add new dropdown to toc section

* Update hrefs on dropdown

* Update icons and add T3

* Update link text
Update dropdown order

* revert deleted files

* cleanup
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.

3 participants