-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Docs Improvements #676
Docs Improvements #676
Conversation
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
docs/app/docs/components/card/page.jsOops! Something went wrong! :( ESLint: 8.56.0 ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct. The config "next/core-web-vitals" was referenced from the config file in "/docs/.eslintrc.json". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. WalkthroughThe pull request introduces a significant refactoring of the navigation and layout components. The main changes involve creating a new Changes
Possibly related PRs
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (4)
docs/components/Main/Main.js (1)
16-16
: Remove redundant empty line
Although minor, consider removing or repurposing this blank line to keep the file tidy.16c16 - + // (Optional) Add a quick comment or remove this extra linedocs/components/layout/Documentation/utils.js (1)
3-5
: Use a self-closing tag for readability
A small styling preference: consider formatting yourLinkIcon
inline for readability, since it returns a single<svg>
element.-const LinkIcon =()=>{ - return <svg ...></svg> -} +const LinkIcon = () => <svg ...></svg>;docs/components/Main/NavBar.js (2)
17-24
: Inline SVG for brand logo
Keeping the RadUI logo inline is acceptable. As an alternative, consider splitting icons into a separate file if you plan to reuse them across components.
38-40
: Use a single callback function
TheopenLink
function is straightforward. You may consider an inline approach for smaller code footprints, but this is a matter of preference.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
docs/package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (4)
docs/components/Main/Main.js
(1 hunks)docs/components/Main/NavBar.js
(1 hunks)docs/components/layout/Documentation/utils.js
(1 hunks)docs/package.json
(1 hunks)
🔇 Additional comments (11)
docs/components/Main/Main.js (3)
5-5
: Use of nookies
for cookie parsing and setting
Good choice for handling SSR cookie data. Ensure that any higher-level frameworks or serverless setups properly pass along cookies to maintain user preferences.
7-7
: Proper modularization by separating the NavBar
Importing the NavBar
directly clarifies responsibilities between layout and navigation. This is a clean approach.
22-22
: NavBar integration
Reusing darkMode
and setDarkMode
at the layout level is a solid approach, ensuring consistent theming across the site.
docs/components/layout/Documentation/utils.js (1)
12-19
: Inline icon usage
Wrapping children in a <span>
and positioning the icon to the right offers a neat layout. Good job!
docs/components/Main/NavBar.js (5)
9-12
: SVG logos for external services
The approach of defining each logo as a self-contained component is clean and promotes reusability.
26-32
: Dark mode icons
The SunIcon
and MoonIcon
SVGs are well-defined and easy to read.
35-36
: Ensure consistent cookie usage
Parsing cookies early within NavBar
is fine. Be sure there’s no conflict if other components also read or manipulate the same cookie.
42-50
: Update cookie logic
This code effectively toggles dark mode and updates the cookie. Confirm the rest of the app references the same cookie key for a consistent user experience.
53-82
: Solid layout and button usage
Using @radui/ui/Button
for external link buttons and the theme toggle is a cohesive approach. This fosters design consistency and code clarity.
docs/package.json (2)
10-10
: Updating @radui/ui
Switching from npm update
to npm i @radui/ui@latest
is direct and ensures the latest version is installed.
13-13
: Verify dependency updates
Confirm that version ^0.0.26
remains compatible with the rest of your code.
✅ Verification successful
Based on the search results, I can verify the dependency update. Let me analyze the findings:
Dependency update is compatible
The codebase shows extensive usage of @radui/ui
components across multiple files, and the version ^0.0.26
is correctly reflected in both package.json
and package-lock.json
. The search results reveal:
- The package is properly installed and locked at version 0.0.26
- Components from
@radui/ui
are widely used throughout the codebase - No breaking changes or compatibility issues are evident
- The codebase follows a consistent import pattern:
import Component from '@radui/ui/Component'
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# This script checks if there are any compatibility notes about @radui/ui ^0.0.26
rg -A 5 '@radui/ui'
Length of output: 49010
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.
Actionable comments posted: 1
🧹 Nitpick comments (7)
docs/app/layout.js (1)
19-19
: Consolidate the function signature change with usage context
By makingRootLayout
an async function, you implicitly allow awaiting any additional async operations like data fetching or metadata retrieval. Ensure that all internal and external consumers ofRootLayout
anticipate the possibility of asynchronous behavior.docs/components/Main/Main.js (2)
16-16
: Minor code clarity
Adding helper comments or descriptive code docs about your styling approach (Tailwind classes, user-provided themes, etc.) can help future maintainers quickly understand how theming is structured, especially since it’s your core layout.
22-22
: Decouple theming from layout?
You might consider separating theme logic from the layout logic. This can reduce the responsibility of the parent layout component and simplify future expansions, e.g., supporting multiple themes.docs/components/Main/NavBar.js (3)
37-38
: Check link reliability
You’re opening external links in a new tab. To avoid potential security vulnerabilities and inform screen readers, consider addingrel="noopener noreferrer"
andaria-label
s for accessibility.
51-80
: Enhance responsiveness & accessibility
- The sticky navbar with backdrop blur is great for modern UX. Validate that the text contrast meets WCAG accessibility guidelines, especially in dark mode.
- Ensure the various icons and links have accessible text or aria-labels for screen readers.
74-76
: Clearer icon states for toggling
Currently, the button dynamically chooses between<MoonIcon />
and<SunIcon />
. This is correct for a typical dark-mode toggle. Consider adding a short text label or tooltip for better accessibility and clarity.docs/components/Copy.js (1)
34-34
: Hover styles and visual feedback.
These Tailwind-based hover styles give clear feedback. Looks good for user interaction.As a minor note, ensure
text-blue-1000
is a valid utility class in your Tailwind config.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
docs/app/docs/first-steps/installation/page.js
(1 hunks)docs/app/layout.js
(1 hunks)docs/components/Copy.js
(2 hunks)docs/components/Main/Main.js
(1 hunks)docs/components/Main/NavBar.js
(1 hunks)docs/components/layout/Documentation/helpers/CodeBlock.js
(2 hunks)
🔇 Additional comments (10)
docs/app/layout.js (1)
21-21
: Confirm consistent cookie handling
You’re correctly using await cookies()
here. Verify that downstream components—especially those using or updating cookies—handle async logic uniformly to prevent potential race conditions, especially if cookies are manipulated elsewhere.
docs/components/Main/Main.js (2)
5-5
: Securely manage cookies
Using nookies
for client-side cookies is convenient, but keep security in mind. Confirm that secure
, sameSite
, or similar cookie attributes are properly set for sensitive data when needed.
7-7
: NavBar import clarity
Importing NavBar
from a dedicated file increases modularity and readability. Good job on separating concerns.
docs/components/Main/NavBar.js (1)
40-48
: Local state & cookie synchronization
Toggling dark mode updates both local state and cookies. This is good for SSR and rehydration, but confirm that your logic covers edge cases where cookie updates fail or happen asynchronously. A fallback or error boundary might be helpful if cookies can’t be set for any reason.
Would you like a sample approach to error-handle a failed cookie write?
docs/components/layout/Documentation/helpers/CodeBlock.js (1)
5-5
: Import statement looks good.
Including the Copy
component is a solid choice to enable convenient copy functionality.
docs/app/docs/first-steps/installation/page.js (3)
22-22
: Spacing change looks clean.
Changing mb-2
to mb-4
achieves more comfortable spacing for readability.
26-33
: Margin adjustments and flex layout are consistent.
Switching from mt-4 mb-1
to my-2
for the “Using Yarn” section standardizes vertical spacing. The new flex layout with a dedicated <span>
for the command text plus the <Copy>
component is a clean approach.
37-42
: NPM section mirrored changes.
These changes ensure consistency between Yarn and NPM instructions, with an identical layout pattern for copying.
docs/components/Copy.js (2)
4-4
: Renaming prop to content
clarifies usage.
This naming better reflects the text being copied, improving readability.
8-8
: Validate clipboard usage in all target browsers.
While navigator.clipboard.writeText
is well-supported in modern browsers, confirm your user base doesn’t require a fallback for older browsers.
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.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
docs/components/layout/Documentation/helpers/ComponentHero/ComponentHero.js (1)
Line range hint
43-46
: Remove unused state variable.The
activeTab
state is declared but never used in the component.const ComponentHero = ({ children, codeUsage = {} }) => { - const [activeTab, setActiveTab] = useState('tab1') const data = initializeTabs(codeUsage)
🧹 Nitpick comments (3)
docs/components/layout/Documentation/helpers/ComponentHero/ComponentHero.js (1)
Line range hint
17-39
: Consider enhancing the robustness of tab initialization.While the language mapping from 'javascript' to 'jsx' is appropriate for proper syntax highlighting, the function could benefit from some improvements.
Consider this more robust implementation:
const initializeTabs = (codeUsage) => { + if (!codeUsage || typeof codeUsage !== 'object') { + return []; + } const tabs = [] - - for (const key in codeUsage) { - if (Object.hasOwnProperty.call(codeUsage, key)) { - let language = key - if(key === 'javascript') { - language = 'jsx' - } - const element = codeUsage[key]; - tabs.push({ - label: key, - value: key, - content: <CodeBlock language={language} >{codeUsage[key]?.code}</CodeBlock>, - }) - } - } + return Object.entries(codeUsage).map(([key, value]) => ({ + label: key, + value: key, + content: ( + <CodeBlock + language={key === 'javascript' ? 'jsx' : key} + > + {value?.code} + </CodeBlock> + ), + })); - - return tabs - - - }docs/components/layout/Documentation/helpers/CodeBlock.js (2)
33-36
: Consider adding JSDoc comment for copyContent formatting.The code formatting logic would benefit from documentation explaining the purpose of newline normalization and trimming.
+ /** + * Format the code for copying: + * - Normalize multiple newlines to single newlines + * - Remove leading/trailing whitespace + */ const copyContent = children .replace(/\n{2,}/g, '\n') .trim();
49-51
: Remove unnecessary blank lines at end of file.There are multiple blank lines at the end of the file that should be removed.
export default CodeBlock; - - -
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
docs/app/globals.scss
(1 hunks)docs/app/landingComponents/HeroSection.js
(1 hunks)docs/components/Copy.js
(2 hunks)docs/components/layout/Documentation/helpers/CodeBlock.js
(2 hunks)docs/components/layout/Documentation/helpers/ComponentHero/ComponentHero.js
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- docs/app/landingComponents/HeroSection.js
🚧 Files skipped from review as they are similar to previous changes (1)
- docs/components/Copy.js
🔇 Additional comments (5)
docs/components/layout/Documentation/helpers/ComponentHero/ComponentHero.js (2)
Line range hint 1-15
: LGTM! Clean imports and utility component implementation.
The imports are well-organized, and the TabContainer utility component follows React best practices with proper prop handling.
48-50
: Verify contrast ratio for accessibility.
The new styling using bg-gray-200
with black text should be verified for sufficient contrast ratio to maintain accessibility standards.
docs/app/globals.scss (1)
13-13
: LGTM! Color scheme changes align with design system.
The updated color variables maintain consistency with RadUI's design system.
Let's verify the color variables are defined:
Also applies to: 15-15
✅ Verification successful
Color variables are properly defined and used consistently
The verification confirms that both --rad-ui-color-gray-1000
and --rad-ui-color-accent-500
are properly defined in the design system's base tokens file (styles/cssTokens/base.tokens.css
) and are used consistently across the codebase:
--rad-ui-color-gray-1000
is defined ashsl(0, 0%, 93.5%)
for light mode- Both variables are used appropriately in various components maintaining design consistency
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check if these CSS variables are defined in the codebase
rg --type css "rad-ui-color-(gray|accent)-[0-9]+"
Length of output: 44567
docs/components/layout/Documentation/helpers/CodeBlock.js (2)
5-6
: LGTM! SCSS language support properly integrated.
The SCSS language import and registration are correctly implemented.
Also applies to: 10-10
39-43
: Verify Copy component positioning across different code block sizes.
The absolute positioning of the Copy component looks correct, but we should ensure it works well with various code block sizes and doesn't overlap with the content.
Let's check for potential positioning issues in other code blocks:
✅ Verification successful
Copy component positioning is well-implemented and safe
The implementation is robust for the following reasons:
- The Copy component is properly contained within a flex container (
span
withflex items-center
) - The button has appropriate padding and margin (
px-1.5 py-1.5 m-0.5
) - The parent code block uses
relative
positioning with the copy button absolutely positioned attop-2 right-2
- The code content uses
whitespace-pre-wrap
andword-break: break-word
which prevents content overlap
The current implementation ensures the copy button:
- Maintains consistent spacing from code content
- Stays properly aligned in the top-right corner
- Won't overlap with code due to text wrapping properties
- Has proper containment within its flex container
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Look for other instances of code blocks with absolute positioning
rg --type js "className=\"relative\".*<code"
Length of output: 44
Script:
#!/bin/bash
# Let's try a more flexible search pattern to find code blocks and copy components
rg -U --type js -A 5 'pre.*className.*relative'
# Also search for Copy component usage
rg -U --type js -A 3 '<Copy'
Length of output: 1921
Script:
#!/bin/bash
# Let's examine the Copy component implementation to understand its dimensions and styling
cat docs/components/Copy.js
# Let's also check if there are any reported issues or style overrides related to Copy component positioning
rg -U --type js -A 3 'Copy.*className'
Length of output: 2461
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
docs/components/layout/Documentation/utils.js (1)
3-5
: Consider optimizing the LinkIcon component.The component could benefit from the following improvements:
- Fix spacing in the function declaration
- Memoize the component since it's static
- Add proper typing
-const LinkIcon =()=>{ +const LinkIcon = React.memo(() => { return <svg width="24" height="24" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.62471 4.00001L4.56402 4.00001C4.04134 3.99993 3.70687 3.99988 3.4182 4.055C2.2379 4.28039 1.29846 5.17053 1.05815 6.33035C0.999538 6.61321 0.999604 6.93998 0.999703 7.43689L0.999711 7.50001L0.999703 7.56313C0.999604 8.06004 0.999538 8.38681 1.05815 8.66967C1.29846 9.8295 2.2379 10.7196 3.4182 10.945C3.70688 11.0001 4.04135 11.0001 4.56403 11L4.62471 11H5.49971C5.77585 11 5.99971 10.7762 5.99971 10.5C5.99971 10.2239 5.77585 10 5.49971 10H4.62471C4.02084 10 3.78907 9.99777 3.60577 9.96277C2.80262 9.8094 2.19157 9.21108 2.03735 8.46678C2.00233 8.29778 1.99971 8.08251 1.99971 7.50001C1.99971 6.91752 2.00233 6.70225 2.03735 6.53324C2.19157 5.78895 2.80262 5.19062 3.60577 5.03725C3.78907 5.00225 4.02084 5.00001 4.62471 5.00001H5.49971C5.77585 5.00001 5.99971 4.77615 5.99971 4.50001C5.99971 4.22387 5.77585 4.00001 5.49971 4.00001H4.62471ZM10.3747 5.00001C10.9786 5.00001 11.2104 5.00225 11.3937 5.03725C12.1968 5.19062 12.8079 5.78895 12.9621 6.53324C12.9971 6.70225 12.9997 6.91752 12.9997 7.50001C12.9997 8.08251 12.9971 8.29778 12.9621 8.46678C12.8079 9.21108 12.1968 9.8094 11.3937 9.96277C11.2104 9.99777 10.9786 10 10.3747 10H9.49971C9.22357 10 8.99971 10.2239 8.99971 10.5C8.99971 10.7762 9.22357 11 9.49971 11H10.3747L10.4354 11C10.9581 11.0001 11.2925 11.0001 11.5812 10.945C12.7615 10.7196 13.701 9.8295 13.9413 8.66967C13.9999 8.38681 13.9998 8.06005 13.9997 7.56314L13.9997 7.50001L13.9997 7.43688C13.9998 6.93998 13.9999 6.61321 13.9413 6.33035C13.701 5.17053 12.7615 4.28039 11.5812 4.055C11.2925 3.99988 10.9581 3.99993 10.4354 4.00001L10.3747 4.00001H9.49971C9.22357 4.00001 8.99971 4.22387 8.99971 4.50001C8.99971 4.77615 9.22357 5.00001 9.49971 5.00001H10.3747ZM5.00038 7C4.72424 7 4.50038 7.22386 4.50038 7.5C4.50038 7.77614 4.72424 8 5.00038 8H10.0004C10.2765 8 10.5004 7.77614 10.5004 7.5C10.5004 7.22386 10.2765 7 10.0004 7H5.00038Z" fill="currentColor" fillRule="evenodd" clipRule="evenodd"></path></svg> -} +});
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
docs/app/docs/components/card/page.js
(1 hunks)docs/app/docs/components/heading/page.js
(1 hunks)docs/app/docs/components/separator/page.js
(1 hunks)docs/app/docs/components/text/page.js
(1 hunks)docs/app/docs/components/tooltip/page.js
(1 hunks)docs/components/layout/Documentation/utils.js
(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- docs/app/docs/components/text/page.js
- docs/app/docs/components/heading/page.js
🔇 Additional comments (5)
docs/app/docs/components/separator/page.js (1)
18-23
: Verify color and accessibility.
Transitioning from text-gray-50
to text-gray-1000
can significantly impact visual contrast. Confirm that this new color aligns with the documentation’s design system and does not reduce readability or accessibility. The rest of the layout changes (using a vertical Separator
) appear structurally sound.
docs/app/docs/components/card/page.js (1)
19-25
: Ensure fallback text and name consistency.
Changing the fallback from "PK" to "PP" matches the new name "Peter Parker," enhancing consistency. Updating the role to "Biochemist" suggests a more thematic or realistic example. This adjustment appears valid, and the component remains functionally correct.
docs/app/docs/components/tooltip/page.js (1)
25-25
: Confirm updated Tooltip prop.
Using label
instead of content
indicates an API revision for Tooltip
. Verify that this change is compatible and that no other references to content
remain within the codebase.
docs/components/layout/Documentation/utils.js (2)
26-38
: LGTM! Well-structured component with good accessibility.
The component implementation:
- Uses semantic HTML
- Includes proper ARIA labels
- Has clean styling with flex layout
7-38
: Verify BookMarkLink integration with NavBar.
Let's verify how the BookMarkLink component is used in the NavBar component.
const scrollToElement = (e) => { | ||
e.preventDefault(); | ||
const element = document.getElementById(sanitizedId); | ||
const offset = 80; // Adjust this value based on your header height | ||
const elementPosition = element.getBoundingClientRect().top; | ||
const offsetPosition = elementPosition + window.pageYOffset - offset; | ||
|
||
window.scrollTo({ | ||
top: offsetPosition, | ||
behavior: 'smooth' | ||
}); | ||
|
||
// Update URL without triggering another scroll | ||
window.history.pushState({}, '', `#${sanitizedId}`); | ||
}; |
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.
🛠️ Refactor suggestion
Add error handling and browser compatibility checks.
The scroll functionality needs additional safeguards:
- Add error handling for missing elements
- Check for smooth scroll support
- Consider making the offset configurable
const scrollToElement = (e) => {
e.preventDefault();
const element = document.getElementById(sanitizedId);
+ if (!element) {
+ console.warn(`Element with id "${sanitizedId}" not found`);
+ return;
+ }
const offset = 80; // Adjust this value based on your header height
const elementPosition = element.getBoundingClientRect().top;
const offsetPosition = elementPosition + window.pageYOffset - offset;
+ const supportsNativeSmoothScroll = 'scrollBehavior' in document.documentElement.style;
+
+ if (supportsNativeSmoothScroll) {
window.scrollTo({
top: offsetPosition,
behavior: 'smooth'
});
+ } else {
+ // Fallback for browsers that don't support smooth scrolling
+ window.scrollTo(0, offsetPosition);
+ }
// Update URL without triggering another scroll
window.history.pushState({}, '', `#${sanitizedId}`);
};
📝 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.
const scrollToElement = (e) => { | |
e.preventDefault(); | |
const element = document.getElementById(sanitizedId); | |
const offset = 80; // Adjust this value based on your header height | |
const elementPosition = element.getBoundingClientRect().top; | |
const offsetPosition = elementPosition + window.pageYOffset - offset; | |
window.scrollTo({ | |
top: offsetPosition, | |
behavior: 'smooth' | |
}); | |
// Update URL without triggering another scroll | |
window.history.pushState({}, '', `#${sanitizedId}`); | |
}; | |
const scrollToElement = (e) => { | |
e.preventDefault(); | |
const element = document.getElementById(sanitizedId); | |
if (!element) { | |
console.warn(`Element with id "${sanitizedId}" not found`); | |
return; | |
} | |
const offset = 80; // Adjust this value based on your header height | |
const elementPosition = element.getBoundingClientRect().top; | |
const offsetPosition = elementPosition + window.pageYOffset - offset; | |
const supportsNativeSmoothScroll = 'scrollBehavior' in document.documentElement.style; | |
if (supportsNativeSmoothScroll) { | |
window.scrollTo({ | |
top: offsetPosition, | |
behavior: 'smooth' | |
}); | |
} else { | |
// Fallback for browsers that don't support smooth scrolling | |
window.scrollTo(0, offsetPosition); | |
} | |
// Update URL without triggering another scroll | |
window.history.pushState({}, '', `#${sanitizedId}`); | |
}; |
Summary by CodeRabbit
New Features
NavBar
component for improved navigation.BookMarkLink
component with a newLinkIcon
for better visual representation.CodeBlock
component.HeroSection
with a new gradient direction.Bug Fixes
Tooltip
component.Chores
package.json
.Documentation
component for improved spacing around navigation links.