chore: fix dark mode bug + some improvements + rad ui with types#1306
chore: fix dark mode bug + some improvements + rad ui with types#1306
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughThis set of changes updates UI styling in several documentation components, removes two meta tags from the HTML head, deletes the Changes
Sequence Diagram(s)sequenceDiagram
participant Page as Page Component
participant BreadcrumbUtil as generatePageBreadcrumbs
participant StructuredDataUtil as generateBreadcrumbStructuredData
Page->>BreadcrumbUtil: generatePageBreadcrumbs(pathname, currentPageTitle)
BreadcrumbUtil-->>Page: BreadcrumbItem[]
Page->>StructuredDataUtil: generateBreadcrumbStructuredData(BreadcrumbItem[])
StructuredDataUtil-->>Page: BreadcrumbStructuredData (JSON-LD)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
docs/components/Main/Main.js (1)
19-19: Remove debug console.log statement.This debug logging statement should be removed before merging to production.
- console.log(darkModeSsrValue)docs/utils/seo/generateBreadcrumbData.ts (1)
23-60: Solid breadcrumb generation logic with room for improvement.The function correctly builds breadcrumb hierarchy and handles segment name formatting. However, consider adding input validation and edge case handling.
Consider these improvements:
export function generatePageBreadcrumbs(pathname: string, currentPageTitle: string): BreadcrumbItem[] { + if (!pathname || !currentPageTitle) { + throw new Error('pathname and currentPageTitle are required'); + } + const segments = pathname.split('/').filter(Boolean);Also consider handling special characters and URL encoding in segment names.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
docs/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (7)
docs/app/layout.js(0 hunks)docs/components/Copy.js(1 hunks)docs/components/Main/Main.js(2 hunks)docs/components/layout/Documentation/helpers/CodeBlock.js(1 hunks)docs/components/layout/Theme.js(0 hunks)docs/package.json(1 hunks)docs/utils/seo/generateBreadcrumbData.ts(1 hunks)
💤 Files with no reviewable changes (2)
- docs/app/layout.js
- docs/components/layout/Theme.js
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: kotAPI
PR: rad-ui/ui#640
File: .github/workflows/build-rad-ui.yml:5-5
Timestamp: 2024-12-14T02:25:41.034Z
Learning: In the `rad-ui/ui` repository, the `security-fixes` branch only updates dependencies, so linting and Chromatic workflows are not required for this branch.
📚 Learning: in the `rad-ui/ui` repository, the `security-fixes` branch only updates dependencies, so linting and...
Learnt from: kotAPI
PR: rad-ui/ui#640
File: .github/workflows/build-rad-ui.yml:5-5
Timestamp: 2024-12-14T02:25:41.034Z
Learning: In the `rad-ui/ui` repository, the `security-fixes` branch only updates dependencies, so linting and Chromatic workflows are not required for this branch.
Applied to files:
docs/package.json
📚 Learning: the code object in docs/app/docsv2/components/aspect-ratio/docs/codeusage.js requires two closing br...
Learnt from: GoldGroove06
PR: rad-ui/ui#889
File: docs/app/docsv2/components/aspect-ratio/docs/codeUsage.js:16-17
Timestamp: 2025-02-22T18:53:12.639Z
Learning: The code object in docs/app/docsv2/components/aspect-ratio/docs/codeUsage.js requires two closing braces - one for the inner `javascript` object and another for the outer `code` object.
Applied to files:
docs/components/layout/Documentation/helpers/CodeBlock.js
🧬 Code Graph Analysis (1)
docs/components/Main/Main.js (1)
docs/app/layout.js (1)
darkModeSsrValue(101-101)
🔇 Additional comments (5)
docs/package.json (1)
17-17: LGTM! Dependency update looks good.The @radui/ui version bump from ^0.0.46 to ^0.0.47 aligns with the PR objectives. Since this is a pre-1.0 package, ensure the update is compatible with existing component usage throughout the codebase.
docs/components/Copy.js (1)
34-34: Good UI refinement with consistent color adjustments.The changes to lighter blue shades (bg-blue-100 and hover:border-blue-500) make the copy button more subtle and visually consistent. This aligns well with the UI improvements mentioned in the PR objectives.
docs/components/Main/Main.js (1)
33-33: Good improvement to explicit background color handling.Adding explicit
bg-gray-50for light mode ensures consistent background styling instead of relying on default/inherited colors. This is a solid improvement for the dark mode implementation.docs/components/layout/Documentation/helpers/CodeBlock.js (1)
110-110: Improved copy button positioning.Increasing the right offset from 8px to 20px provides better visual spacing for the copy button. The use of arbitrary value
right-[20px]suggests this specific spacing was needed for optimal layout.docs/utils/seo/generateBreadcrumbData.ts (1)
1-15: Well-structured TypeScript interfaces for breadcrumb data.The interfaces clearly define the expected data structures for both internal breadcrumb items and schema.org-compliant structured data. Good use of TypeScript for type safety.
| export function generateBreadcrumbStructuredData(breadcrumbs: BreadcrumbItem[]): BreadcrumbStructuredData { | ||
| const baseUrl = 'https://rad-ui.com'; | ||
|
|
||
| return { | ||
| "@context": "https://schema.org", | ||
| "@type": "BreadcrumbList", | ||
| "itemListElement": breadcrumbs.map((breadcrumb, index) => ({ | ||
| "@type": "ListItem", | ||
| "position": index + 1, | ||
| "name": breadcrumb.name, | ||
| "item": `${baseUrl}${breadcrumb.url}` | ||
| })) | ||
| }; | ||
| } No newline at end of file |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Make base URL configurable instead of hard-coding.
The hard-coded baseUrl = 'https://rad-ui.com' should be configurable to support different environments (development, staging, production).
-export function generateBreadcrumbStructuredData(breadcrumbs: BreadcrumbItem[]): BreadcrumbStructuredData {
- const baseUrl = 'https://rad-ui.com';
+export function generateBreadcrumbStructuredData(
+ breadcrumbs: BreadcrumbItem[],
+ baseUrl: string = 'https://rad-ui.com'
+): BreadcrumbStructuredData {This allows for environment-specific URLs while maintaining backward compatibility.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export function generateBreadcrumbStructuredData(breadcrumbs: BreadcrumbItem[]): BreadcrumbStructuredData { | |
| const baseUrl = 'https://rad-ui.com'; | |
| return { | |
| "@context": "https://schema.org", | |
| "@type": "BreadcrumbList", | |
| "itemListElement": breadcrumbs.map((breadcrumb, index) => ({ | |
| "@type": "ListItem", | |
| "position": index + 1, | |
| "name": breadcrumb.name, | |
| "item": `${baseUrl}${breadcrumb.url}` | |
| })) | |
| }; | |
| } | |
| export function generateBreadcrumbStructuredData( | |
| breadcrumbs: BreadcrumbItem[], | |
| baseUrl: string = 'https://rad-ui.com' | |
| ): BreadcrumbStructuredData { | |
| return { | |
| "@context": "https://schema.org", | |
| "@type": "BreadcrumbList", | |
| "itemListElement": breadcrumbs.map((breadcrumb, index) => ({ | |
| "@type": "ListItem", | |
| "position": index + 1, | |
| "name": breadcrumb.name, | |
| "item": `${baseUrl}${breadcrumb.url}` | |
| })) | |
| }; | |
| } |
🤖 Prompt for AI Agents
In docs/utils/seo/generateBreadcrumbData.ts around lines 67 to 80, the baseUrl
is hard-coded as 'https://rad-ui.com', which limits flexibility across
environments. Modify the function to accept the baseUrl as a parameter or
retrieve it from a configuration or environment variable, so it can be set
dynamically for development, staging, or production. Ensure the existing
functionality remains intact by providing a default value if no baseUrl is
supplied.
Summary by CodeRabbit
New Features
Style
Chores
Refactor