-
-
Notifications
You must be signed in to change notification settings - Fork 53
fix-issue-#517: Added a new code component which has copy button built in #759
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
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/components/CodeWithCopy.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. WalkthroughA new Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
Finishing Touches
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: 3
🧹 Nitpick comments (2)
docs/components/CodeWithCopy.js (2)
5-5: Add prop types and documentation.Consider adding:
- PropTypes or TypeScript types for the
codeprop- JSDoc documentation describing the component's purpose and props
- Default props if applicable
+import PropTypes from 'prop-types'; + +/** + * CodeWithCopy - A component that displays code with a copy button + * @param {Object} props + * @param {string} props.code - The code snippet to display + */ const CodeWithCopy = ({ code }) => {And at the bottom:
+CodeWithCopy.propTypes = { + code: PropTypes.string.isRequired +};
1-31: Consider architectural improvements for better UX.Suggestions for enhancing the component:
- Add error handling for copy failures
- Provide visual feedback on copy success/failure
- Consider adding syntax highlighting support
- Add support for different code block sizes
Would you like me to provide a more robust implementation that includes these features?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/components/CodeWithCopy.js(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (1)
docs/components/CodeWithCopy.js (1)
1-3: LGTM! Clean import structure.The imports are well-organized, properly separating external UI components from internal ones.
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/app/docs/contributing/contributing-to-rad-ui/page.tsx (1)
65-89: Consider enhancing commit message templates with examples.The current implementation uses a generic placeholder
<description>. Consider providing real examples to better guide contributors.Example enhancement:
-const SAMPLE_COMMIT_MESSAGE = '<description>' +const SAMPLE_COMMIT_MESSAGE = { + fix: 'resolve button click event not firing on mobile devices', + feature: 'add dark mode support to all components', + docs: 'update installation guide with troubleshooting steps', + // ... other message examples +}Then update the usage:
-For Fixes : <CodeWithCopy code={`git commit -m "Fix: ${SAMPLE_COMMIT_MESSAGE}"`} /> +For Fixes : <CodeWithCopy code={`git commit -m "Fix: ${SAMPLE_COMMIT_MESSAGE.fix}"`} />
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
docs/app/docs/contributing/contributing-to-rad-ui/page.tsx(2 hunks)docs/app/docs/contributing/setting-up-dev-environment/page.tsx(4 hunks)docs/app/docs/first-steps/installation/page.js(2 hunks)docs/components/CodeWithCopy.js(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- docs/components/CodeWithCopy.js
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (2)
docs/app/docs/first-steps/installation/page.js (1)
8-8: LGTM! The CodeWithCopy component enhances the installation instructions.The integration improves user experience by making it easier to copy installation commands.
Let's verify the component's existence and implementation:
Also applies to: 27-27, 30-30
✅ Verification successful
Verified: CodeWithCopy component is properly implemented and correctly used.
The component exists at
docs/components/CodeWithCopy.js, accepts the requiredcodeprop, and provides copy functionality with proper code formatting.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify the CodeWithCopy component exists and check its implementation fd -e js -e jsx -e tsx "CodeWithCopy" docs/components/Length of output: 86
Script:
#!/bin/bash # Check the component implementation echo "=== Component Implementation ===" cat docs/components/CodeWithCopy.js # Backup search using ripgrep for better context echo -e "\n=== Usage References ===" rg -l "CodeWithCopy" docs/Length of output: 1206
docs/app/docs/contributing/setting-up-dev-environment/page.tsx (1)
6-6: LGTM! The CodeWithCopy component enhances CLI command visibility.The integration improves developer experience by making CLI commands easily copyable.
Also applies to: 27-27, 59-59, 68-68, 71-71
docs/components/CodeWithCopy.js
Outdated
| import Tooltip from "@radui/ui/Tooltip"; | ||
|
|
||
| const CodeWithCopy = ({ code }) => { | ||
| const copyContent = code |
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.
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.
So the component should only have one line and overflow condition for X should be scroll?
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.
yeah,
in most cases we shouldnt be worried about scroll or it overflowing to multilines - if it does we'll use the multiline codeblock
just keep it simple, assume the usage of this component will have just a few characters - which rarely have overflow

#517
New code with copy component for the docs

Summary by CodeRabbit
Summary by CodeRabbit
CodeWithCopycomponent that enhances the display and copying of code snippets across various documentation pages.