Skip to content

Mdx migration b2#891

Merged
GoldGroove06 merged 3 commits intomainfrom
mdx-migration-b2
Feb 23, 2025
Merged

Mdx migration b2#891
GoldGroove06 merged 3 commits intomainfrom
mdx-migration-b2

Conversation

@GoldGroove06
Copy link
Copy Markdown
Collaborator

@GoldGroove06 GoldGroove06 commented Feb 23, 2025

  • BlockQuote
  • button
  • callout
  • code
  • card
  • em

Summary by CodeRabbit

  • Documentation
    • Enhanced documentation across several UI components including BlockQuote, Button, Callout, Card, Code, and Em.
    • Introduced comprehensive usage examples that showcase interactive demos, code snippets, and visual layouts.
    • Replaced placeholder content with detailed, structured guides and tables highlighting component properties and variations.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 23, 2025

Walkthrough

This pull request adds new documentation pages and code usage examples for several UI components. For each component (BlockQuote, Button, Callout, Card, Code, and Em), new JavaScript files provide sample code snippets in both JavaScript and SCSS, along with structured data (such as property tables). The documentation pages have been restructured using a Documentation component to replace placeholder content and include live, interactive examples. Additionally, some Button examples retrieve source code asynchronously via a utility function.

Changes

File(s) Change Summary
docs/app/docsv2/components/blockquote/docs/codeUsage.js
docs/app/docsv2/components/blockquote/page.mdx
Introduces a new code usage file with JS/SCSS examples and a property table for the BlockQuote component; updates the documentation page with a detailed layout using Documentation components.
docs/app/docsv2/components/button/docs/codeUsage.js
docs/app/docsv2/components/button/docs/colorCodeUsage.js
docs/app/docsv2/components/button/docs/sizeCodeUsage.js
docs/app/docsv2/components/button/docs/variantCodeUsage.js
docs/app/docsv2/components/button/examples/ButtonColor.tsx
docs/app/docsv2/components/button/examples/ButtonSizes.tsx
docs/app/docsv2/components/button/examples/ButtonVariants.tsx
docs/app/docsv2/components/button/page.mdx
Provides multiple new usage examples for the Button component, including asynchronous retrieval of source code for color, size, and variant demos; adds an Arrow component; and revamps the documentation page with comprehensive, interactive examples.
docs/app/docsv2/components/callout/docs/codeUsage.js
docs/app/docsv2/components/callout/page.mdx
Adds a new code usage file for the Callout component with corresponding JS/SCSS snippets and a BookmarkIcon component; updates its documentation page to showcase a detailed demo with error messaging.
docs/app/docsv2/components/card/docs/codeUsage.js
docs/app/docsv2/components/card/page.mdx
Introduces code examples for the Card component with JavaScript and SCSS snippets; updates the documentation page to feature a structured example incorporating an Avatar and detailed styling.
docs/app/docsv2/components/code/docs/codeUsage.js
docs/app/docsv2/components/code/page.mdx
Adds a new code usage file for the Code component that includes JS/CSS snippets and a CodeTable for property details; enhances the documentation page with structured code examples and tabular data.
docs/app/docsv2/components/em/docs/codeUsage.js
docs/app/docsv2/components/em/page.mdx
Provides a new code usage example for the Em component and replaces the placeholder documentation with a complete layout demonstrating how to emphasize text using the Em component.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ButtonPage
  participant ColorUsage
  participant SizeUsage
  participant VariantUsage
  participant SourceFetcher

  User->>ButtonPage: Request Button Documentation Page
  ButtonPage->>ColorUsage: Load color example
  ColorUsage->>SourceFetcher: getSourceCodeFromPath("ButtonColor.tsx")
  SourceFetcher-->>ColorUsage: Return source code snippet
  ButtonPage->>SizeUsage: Load size example
  SizeUsage->>SourceFetcher: getSourceCodeFromPath("ButtonSizes.tsx")
  SourceFetcher-->>SizeUsage: Return source code snippet
  ButtonPage->>VariantUsage: Load variant example
  VariantUsage->>SourceFetcher: getSourceCodeFromPath("ButtonVariants.tsx")
  SourceFetcher-->>VariantUsage: Return source code snippet
  ButtonPage-->>User: Render documentation with interactive examples
Loading

Possibly related PRs

  • Button color prop docs #789: Introduced a similar codeUsage.js implementation for other UI components, aligning with the approach taken in this pull request.

Suggested labels

automerge

Poem

I'm a happy rabbit, leaping through code,
Hopping on docs where clear examples are bestowed.
BlockQuote, Button, and Callout shine so bright,
With clean snippets and layouts that delight.
I nibble on carrots and admire each new file—
Celebrate these changes with a joyful, wiggly smile!
🥕🐇

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

docs/app/docsv2/components/blockquote/docs/codeUsage.js

Oops! 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.

docs/app/docsv2/components/button/docs/codeUsage.js

Oops! 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.

docs/app/docsv2/components/button/examples/ButtonColor.tsx

Oops! 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.

  • 9 others
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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?

❤️ Share
🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @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. (Beta)
  • @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
Copy Markdown
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: 4

🧹 Nitpick comments (26)
docs/app/docsv2/components/blockquote/docs/codeUsage.js (3)

1-21: Consider enhancing code examples with TypeScript and additional use cases.

The code examples are clear and demonstrate basic usage. However, consider these improvements:

  • Add TypeScript examples since the project appears to use it.
  • Include examples of different color variations.
  • Show examples with different content types (e.g., nested elements).

15-19: Add documentation for CSS custom properties.

The SCSS example uses a CSS custom property (--rad-ui-color-accent-600) but doesn't document its purpose or available values.

Consider adding a comment like:

 scss: {
     code: `.rad-ui-block-quote{
+    // Uses theme's accent color for the border
     border-color: var(--rad-ui-color-accent-600);
     border-left-width: 0.5rem;
     padding-left: 0.75rem; // Assuming 1rem = 16px
 }`

23-34: Enhance property documentation.

The table structure is good, but the properties documentation could be improved:

  • Add validation rules for the color prop (e.g., allowed values).
  • Consider adding more properties like className which is used in the example.
 data : [
     {prop: 'color', type: 'string', default: 'null', description: 'Accent Color of the quote', id: 'color'},
+    {prop: 'className', type: 'string', default: 'undefined', description: 'Additional CSS classes to apply', id: 'className'}
 ]
docs/app/docsv2/components/blockquote/page.mdx (3)

5-7: Enhance component description.

The current description is quite basic. Consider adding:

  • Common use cases
  • Best practices
  • Accessibility considerations
 <Documentation title={`BlockQuote`} description={`
-    BlockQuote is used to display a quote.
+    BlockQuote is used to display quoted content with visual emphasis. It follows semantic HTML practices
+    using the native <blockquote> element, making it accessible to screen readers. Use it for testimonials,
+    excerpts, or any content that needs to be distinguished as a quote.
 `}>
🧰 Tools
🪛 LanguageTool

[uncategorized] ~7-~7: Loose punctuation mark.
Context: ...te is used to display a quote. `}> <Documentation.ComponentHe...

(UNLIKELY_OPENING_PUNCTUATION)


10-19: Add citation to the quote example.

The BlockQuote example could be improved by adding attribution to demonstrate best practices in quoting content.

 <BlockQuote color="green" className="space-x-2" >
     When my time comes, forget the wrong that I've done.
     Help me leave behind some reasons to be missed.
     Don't resent me and when you're feeling empty, keep me in your memory.
     Leave out all the rest, leave out all the rest.
+    <footer>
+        <cite>— Leave Out All The Rest by Linkin Park</cite>
+    </footer>
 </BlockQuote>

26-26: Consider adding more documentation sections.

The documentation could benefit from additional sections like:

  • Installation instructions
  • Theming guidelines
  • Examples of different variations
docs/app/docsv2/components/callout/docs/codeUsage.js (2)

1-29: Consider improving the SCSS code formatting and variable naming.

The SCSS code block could benefit from:

  • Consistent indentation (some lines use 4 spaces, others 5)
  • Using semantic CSS variable names (e.g., --rad-ui-callout-bg instead of --rad-ui-color-accent-200)
  • Adding comments to explain the CSS variable usage

Apply this diff to improve the SCSS code formatting:

     scss: {
         code: `.rad-ui-callout {
-    padding:16px;
-    border-radius:8px;
-     background-color: var(--rad-ui-color-accent-200);
-     color: var(--rad-ui-color-accent-950);
-     display: flex;
-     align-items: center;
-     font-weight: 300;
-     font-size: 14px;
-     gap:8px;
+    padding: 16px;
+    border-radius: 8px;
+    /* Use semantic color variables for better maintainability */
+    background-color: var(--rad-ui-callout-bg, var(--rad-ui-color-accent-200));
+    color: var(--rad-ui-callout-text, var(--rad-ui-color-accent-950));
+    display: flex;
+    align-items: center;
+    font-weight: 300;
+    font-size: 14px;
+    gap: 8px;
 }`

31-33: Add accessibility attributes to the SVG icon.

The BookmarkIcon SVG should include ARIA attributes for better accessibility.

Apply this diff to improve accessibility:

 export const BookmarkIcon = () => {
-  return <svg width="24" height="24" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3.5 2C3.22386 2 3 2.22386 3 2.5V13.5C3 13.6818 3.09864 13.8492 3.25762 13.9373C3.41659 14.0254 3.61087 14.0203 3.765 13.924L7.5 11.5896L11.235 13.924C11.3891 14.0203 11.5834 14.0254 11.7424 13.9373C11.9014 13.8492 12 13.6818 12 13.5V2.5C12 2.22386 11.7761 2 11.5 2H3.5Z" fill="currentColor" fillRule="evenodd" clipRule="evenodd"></path></svg>;
+  return <svg width="24" height="24" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" aria-label="Bookmark icon"><path d="M3.5 2C3.22386 2 3 2.22386 3 2.5V13.5C3 13.6818 3.09864 13.8492 3.25762 13.9373C3.41659 14.0254 3.61087 14.0203 3.765 13.924L7.5 11.5896L11.235 13.924C11.3891 14.0203 11.5834 14.0254 11.7424 13.9373C11.9014 13.8492 12 13.6818 12 13.5V2.5C12 2.22386 11.7761 2 11.5 2H3.5Z" fill="currentColor" fillRule="evenodd" clipRule="evenodd"></path></svg>;
 };
docs/app/docsv2/components/callout/page.mdx (1)

6-21: Fix formatting and enhance component description.

The code has some formatting issues and could benefit from a more detailed description:

  • Remove extra whitespace and newlines
  • Enhance the component description to include use cases and variants

Apply this diff to improve formatting and description:

-<Documentation title={`Callout`} description={`
-            Callout is a component that can be used to display a message or a notification to the user.
-        `}>
-            <Documentation.ComponentHero codeUsage={codeUsage}>
-                <Callout color="red">
-                    
-                        <BookmarkIcon />
-
-                        
-                            <Text className="font-bold">Error</Text>
-                            <Text>Something went wrong. Please try again later.</Text>
-                        
-                    
-                </Callout>
-            </Documentation.ComponentHero>
-        </Documentation>
+<Documentation 
+    title={`Callout`} 
+    description={`
+        Callout is a component that displays important messages or notifications to users.
+        It supports different color variants (red, blue, green) for various message types
+        like errors, information, or success states. Use it to highlight important
+        information or draw attention to specific messages in your UI.
+    `}
+>
+    <Documentation.ComponentHero codeUsage={codeUsage}>
+        <Callout color="red">
+            <BookmarkIcon />
+            <Text className="font-bold">Error</Text>
+            <Text>Something went wrong. Please try again later.</Text>
+        </Callout>
+    </Documentation.ComponentHero>
+</Documentation>
🧰 Tools
🪛 LanguageTool

[uncategorized] ~8-~8: Loose punctuation mark.
Context: ...or a notification to the user. `}> <Documentation.ComponentHe...

(UNLIKELY_OPENING_PUNCTUATION)

docs/app/docsv2/components/code/docs/codeUsage.js (3)

12-19: Consider using relative units and consistent spacing in CSS example.

The CSS example could be improved for better maintainability and responsiveness:

  1. Replace pixel values with relative units (rem/em)
  2. Maintain consistent spacing in property declarations
 .rui-code-root{
     color: var(--rad-ui-color-accent-950);
     background-color: var(--rad-ui-color-accent-400);
-    padding: 1px 10px; // Add space for readability
+    padding: 0.0625rem 0.625rem; // Add space for readability
     display: inline-block;
     border-radius: 4px;
-    font-size:12px;
+    font-size: 0.75rem;
 }

3-9: Enhance code example with TypeScript and more use cases.

Consider:

  1. Adding TypeScript types to the example
  2. Demonstrating more advanced usage scenarios (e.g., different colors, custom styling)
-const CodeExample = () => (
+interface CodeProps {
+  color?: string;
+  className?: string;
+}
+
+const CodeExample: React.FC<CodeProps> = () => (
     <div>
-        <Code>console.log('This is some code')</Code>
+        <Code color="blue">console.log('Basic example')</Code>
+        <Code className="custom-style">npm install @radui/ui</Code>
     </div>
 )

23-33: Enhance props documentation with additional details.

Consider adding:

  1. Common props (className, style)
  2. Validation information for the color prop
  3. Examples in the description
 export const CodeTable = {
     columns : [
         {name: 'Prop', id: 'prop'},
         {name: 'Type', id: 'type'},
         {name: 'Default', id: 'default'},
         {name: 'Description', id: 'description'},
     ],
     data : [
-        {prop: 'color', type: 'string', default: 'null', description: 'Accent Color of the code', id: 'color'},
+        {prop: 'color', type: 'string', default: 'null', description: 'Accent color of the code. Accepts any valid CSS color value (e.g., "blue", "#ff0000")', id: 'color'},
+        {prop: 'className', type: 'string', default: 'null', description: 'Additional CSS class names', id: 'className'},
+        {prop: 'style', type: 'CSSProperties', default: 'null', description: 'Additional inline styles', id: 'style'},
     ]
 }
docs/app/docsv2/components/code/page.mdx (2)

5-15: Fix indentation and enhance documentation structure.

The documentation structure needs improvement:

  1. Fix inconsistent indentation
  2. Add sections for accessibility and best practices
 <Documentation
-           title={`Code`} description={`
-           Code is used to display inline code.
-        `}>
-            <Documentation.ComponentHero codeUsage={codeUsage}>
-                <div className='bg-gray-100 p-5 flex items-center rounded-md shadow'>
-                    <Code className="space-x-2" style={{ margin: 0 }}>console.log('This is some code')</Code>
-                </div>
-            </Documentation.ComponentHero>
+    title="Code"
+    description="Code is used to display inline code."
+>
+    <Documentation.ComponentHero codeUsage={codeUsage}>
+        <div className='bg-gray-100 p-5 flex items-center rounded-md shadow'>
+            <Code className="space-x-2" style={{ margin: 0 }}>console.log('This is some code')</Code>
+        </div>
+    </Documentation.ComponentHero>
+    
+    <Documentation.Section title="Accessibility">
+        <p>The Code component follows WCAG guidelines for color contrast and is keyboard accessible.</p>
+    </Documentation.Section>
+    
+    <Documentation.Section title="Best Practices">
+        <ul>
+            <li>Use for short, inline code snippets</li>
+            <li>For multi-line code blocks, consider using a dedicated code block component</li>
+        </ul>
+    </Documentation.Section>
🧰 Tools
🪛 LanguageTool

[uncategorized] ~8-~8: Loose punctuation mark.
Context: ...s used to display inline code. `}> <Documentation.ComponentHe...

(UNLIKELY_OPENING_PUNCTUATION)


17-19: Fix table placement and indentation.

Remove empty lines and fix indentation for better code organization.

-     
-                <Documentation.Table columns={CodeTable.columns} data={CodeTable.data} />
-           
+    <Documentation.Table columns={CodeTable.columns} data={CodeTable.data} />
docs/app/docsv2/components/card/page.mdx (2)

6-8: Enhance Documentation Description Clarity
The Documentation component’s title and description effectively introduce the Card component. However, the description text is somewhat repetitive (e.g., "used to group related information and actions" vs. "used to display information in a structured way") and could be streamlined for improved clarity and brevity. Additionally, a static analysis hint noted a loose punctuation mark—double-check for any unintended punctuation or formatting in the multi-line string.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~8-~8: Loose punctuation mark.
Context: ...formation in a structured way. `}> <Documentation.ComponentHe...

(UNLIKELY_OPENING_PUNCTUATION)


12-19: Consider Semantic HTML for Accessibility
The nested <div> structure displaying "Peter Parker" and "Biochemist" conveys the intended content, but using more semantic elements (like heading tags or paragraph tags) could improve accessibility and SEO. If the MDX context permits, consider using semantic HTML tags to better describe the content hierarchy.

docs/app/docsv2/components/em/docs/codeUsage.js (1)

19-21: Replace CSS placeholder with actual styling examples.

The CSS section contains a placeholder. Consider adding relevant CSS examples to demonstrate any custom styling possibilities for the Em component.

Would you like me to help generate CSS examples for styling the Em component?

docs/app/docsv2/components/em/page.mdx (1)

14-14: Consider extracting the common className to avoid repetition.

The same className "text-gray-1000" is repeated multiple times. Consider extracting it to a parent element or a variable for better maintainability.

 <div className='text-gray-900 bg-gray-50 rounded shadow-lg font-normal p-5 space-y-1'>
     <Text>
         I have a dream of a scene between the green hills.
         <br />
-        <Em className="text-gray-1000">Clouds</Em> pull away and the sunlight's revealed.
+        <Em>Clouds</Em> pull away and the sunlight's revealed.
         <br />
-        People don't talk about keeping it <Em className="text-gray-1000">real</Em>.
+        People don't talk about keeping it <Em>real</Em>.
         <br />
-        <Em className="text-gray-1000">It's understood</Em> that they actually will.
+        <Em>It's understood</Em> that they actually will.
     </Text>
 </div>

And add the className to the parent Text component:

-<Text>
+<Text className="text-gray-1000">

Also applies to: 16-16, 18-18

docs/app/docsv2/components/button/docs/sizeCodeUsage.js (1)

1-9: Consider abstracting the code usage pattern.

This file follows the same pattern as colorCodeUsage.js. Consider creating a utility function to reduce code duplication.

+// utils/createCodeUsage.js
+export async function createCodeUsage(examplePath) {
+    let sourceCode;
+    try {
+        sourceCode = await getSourceCodeFromPath(examplePath);
+    } catch (error) {
+        console.error(`Failed to load example from ${examplePath}:`, error);
+        sourceCode = '// Error loading example code';
+    }
+    return {
+        javascript: {
+            code: sourceCode
+        }
+    };
+}

+// sizeCodeUsage.js
 import { getSourceCodeFromPath } from '@/utils/parseSourceCode';
+import { createCodeUsage } from '@/utils/createCodeUsage';

-const buttonSizesSourceCode = await getSourceCodeFromPath('docs/app/docs/components/button/examples/ButtonSizes.tsx');
-
-export const code = {
-    javascript: {
-        code: buttonSizesSourceCode
-    }
-};
+export const code = await createCodeUsage('docs/app/docs/components/button/examples/ButtonSizes.tsx');
docs/app/docsv2/components/button/examples/ButtonColor.tsx (2)

5-6: Move configuration arrays to constants or import from a central location.

The sizes and variants arrays should be defined as constants or imported from a central configuration file to ensure consistency across components.

+import { BUTTON_SIZES, BUTTON_VARIANTS } from '@/constants/button';
+// or
+const BUTTON_SIZES = ['small', 'medium', 'large', 'x-large'] as const;
+const BUTTON_VARIANTS = ['solid', 'soft', 'outline', 'ghost'] as const;

 const ButtonColor = () => {
-    const sizes = ['small', 'medium', 'large', 'x-large'];
-    const variants = ['solid', 'soft', 'outline', 'ghost'];
+    const sizes = BUTTON_SIZES;
+    const variants = BUTTON_VARIANTS;

4-16: Add TypeScript types for better type safety.

The component is using TypeScript (.tsx) but doesn't leverage type safety. Consider adding proper types.

+type ButtonSize = 'small' | 'medium' | 'large' | 'x-large';
+type ButtonVariant = 'solid' | 'soft' | 'outline' | 'ghost';

-const ButtonColor = () => {
+const ButtonColor: React.FC = () => {
     const sizes: ButtonSize[] = ['small', 'medium', 'large', 'x-large'];
     const variants: ButtonVariant[] = ['solid', 'soft', 'outline', 'ghost'];
docs/app/docsv2/components/button/examples/ButtonSizes.tsx (1)

4-18: Add TypeScript types and improve accessibility.

Consider the following improvements:

  1. Add TypeScript types for the size and variant arrays.
  2. Use unique identifiers instead of array indices as keys.
  3. Add ARIA labels to describe button sizes and variants.
-const ButtonSizes = () => {
+type ButtonSize = 'small' | 'medium' | 'large' | 'x-large';
+type ButtonVariant = 'solid' | 'soft' | 'outline' | 'ghost';
+
+const ButtonSizes = () => {
-    const sizes = ['small', 'medium', 'large', 'x-large'];
-    const variants = ['solid', 'soft', 'outline', 'ghost'];
+    const sizes: ButtonSize[] = ['small', 'medium', 'large', 'x-large'];
+    const variants: ButtonVariant[] = ['solid', 'soft', 'outline', 'ghost'];
     return <div className='flex flex-col gap-4'>
-        {variants.map((variant, index) => {
-            return <div key={index} className='flex items-center gap-4'>
-                {sizes.map((size, index) => {
-                    return <Button key={index} size={size} variant={variant}>
+        {variants.map((variant) => {
+            return <div key={variant} className='flex items-center gap-4'>
+                {sizes.map((size) => {
+                    return <Button 
+                        key={`${variant}-${size}`} 
+                        size={size} 
+                        variant={variant}
+                        aria-label={`${size} ${variant} button`}>
                         <span>Button</span>
                         </Button>
                 })}
docs/app/docsv2/components/button/docs/codeUsage.js (2)

12-56: Enhance button styles for better accessibility and maintainability.

The SCSS styles need improvements:

  1. Missing focus states for keyboard navigation.
  2. Consider using CSS custom properties for consistent spacing.
  3. Add transitions for smoother hover effects.
 .rad-ui-button{
+    --button-padding: 12px;
+    --button-height: 32px;
+    --button-radius: 4px;
+    --button-transition: background-color 0.2s ease;
+
-    height: 32px;
-    border-radius: 4px;
+    height: var(--button-height);
+    border-radius: var(--button-radius);
     display:flex;
     align-items:center;
     justify-content:center;
-    padding:0px 12px;
+    padding: 0 var(--button-padding);
+    transition: var(--button-transition);
+    
+    &:focus-visible {
+        outline: 2px solid var(--rad-ui-color-accent-900);
+        outline-offset: 2px;
+    }
 }

60-62: Consider moving Arrow component to a shared location.

The Arrow component is duplicated in ButtonVariants.tsx. Consider moving it to a shared location to maintain DRY principles.

docs/app/docsv2/components/button/page.mdx (2)

11-14: Enhance component documentation with props table and usage guidelines.

The documentation would benefit from:

  1. A table of available props and their types.
  2. Common use cases and best practices.
  3. Accessibility guidelines.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~14-~14: Loose punctuation mark.
Context: ...m in forms, dialogs, and more. `}> <Documentation.ComponentHe...

(UNLIKELY_OPENING_PUNCTUATION)


16-19: Add more context to the example button.

The initial example should demonstrate a common use case and explain the purpose of the Arrow component.

 <Documentation.ComponentHero codeUsage={codeUsage}>
-    <Button color="green" className="space-x-2" ><span>Click Me! </span><Arrow /></Button>
+    <Button color="green" className="space-x-2" aria-label="Submit form">
+        <span>Submit </span>
+        <Arrow />
+    </Button>
 </Documentation.ComponentHero>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ce485e9 and 6c0eb02.

📒 Files selected for processing (18)
  • docs/app/docsv2/components/blockquote/docs/codeUsage.js (1 hunks)
  • docs/app/docsv2/components/blockquote/page.mdx (1 hunks)
  • docs/app/docsv2/components/button/docs/codeUsage.js (1 hunks)
  • docs/app/docsv2/components/button/docs/colorCodeUsage.js (1 hunks)
  • docs/app/docsv2/components/button/docs/sizeCodeUsage.js (1 hunks)
  • docs/app/docsv2/components/button/docs/variantCodeUsage.js (1 hunks)
  • docs/app/docsv2/components/button/examples/ButtonColor.tsx (1 hunks)
  • docs/app/docsv2/components/button/examples/ButtonSizes.tsx (1 hunks)
  • docs/app/docsv2/components/button/examples/ButtonVariants.tsx (1 hunks)
  • docs/app/docsv2/components/button/page.mdx (1 hunks)
  • docs/app/docsv2/components/callout/docs/codeUsage.js (1 hunks)
  • docs/app/docsv2/components/callout/page.mdx (1 hunks)
  • docs/app/docsv2/components/card/docs/codeUsage.js (1 hunks)
  • docs/app/docsv2/components/card/page.mdx (1 hunks)
  • docs/app/docsv2/components/code/docs/codeUsage.js (1 hunks)
  • docs/app/docsv2/components/code/page.mdx (1 hunks)
  • docs/app/docsv2/components/em/docs/codeUsage.js (1 hunks)
  • docs/app/docsv2/components/em/page.mdx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • docs/app/docsv2/components/card/docs/codeUsage.js
🧰 Additional context used
🪛 LanguageTool
docs/app/docsv2/components/em/page.mdx

[uncategorized] ~8-~8: Loose punctuation mark.
Context: ... Em is used to emphasize text. `}> <Documentation.ComponentHe...

(UNLIKELY_OPENING_PUNCTUATION)

docs/app/docsv2/components/card/page.mdx

[uncategorized] ~8-~8: Loose punctuation mark.
Context: ...formation in a structured way. `}> <Documentation.ComponentHe...

(UNLIKELY_OPENING_PUNCTUATION)

docs/app/docsv2/components/code/page.mdx

[uncategorized] ~8-~8: Loose punctuation mark.
Context: ...s used to display inline code. `}> <Documentation.ComponentHe...

(UNLIKELY_OPENING_PUNCTUATION)

docs/app/docsv2/components/callout/page.mdx

[uncategorized] ~8-~8: Loose punctuation mark.
Context: ...or a notification to the user. `}> <Documentation.ComponentHe...

(UNLIKELY_OPENING_PUNCTUATION)

docs/app/docsv2/components/blockquote/page.mdx

[uncategorized] ~7-~7: Loose punctuation mark.
Context: ...te is used to display a quote. `}> <Documentation.ComponentHe...

(UNLIKELY_OPENING_PUNCTUATION)

docs/app/docsv2/components/button/page.mdx

[uncategorized] ~14-~14: Loose punctuation mark.
Context: ...m in forms, dialogs, and more. `}> <Documentation.ComponentHe...

(UNLIKELY_OPENING_PUNCTUATION)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (7)
docs/app/docsv2/components/callout/docs/codeUsage.js (1)

35-35: LGTM!

The default export is correctly implemented.

docs/app/docsv2/components/callout/page.mdx (1)

1-4: LGTM!

The imports are correctly structured and all necessary components are imported.

docs/app/docsv2/components/card/page.mdx (3)

1-4: Import Declarations Are Clear
The imports for Documentation, Card, Avatar, and codeUsage are well-organized and use clear aliasing. The paths look correct given your project structure.


9-11: Component Hero and Card Usage Look Good
The integration of <Documentation.ComponentHero> with the provided codeUsage and the usage of the Card and Avatar components to showcase an example are implemented correctly. The fallback "PP" in the Avatar seems appropriate for "Peter Parker."


20-22: Component Closure Is Correct
The closing tags for <Card>, <Documentation.ComponentHero>, and <Documentation> are properly placed, ensuring a well-structured component layout.

docs/app/docsv2/components/em/page.mdx (1)

1-5: LGTM! Well-structured imports and organization.

The imports are properly organized and the component dependencies are correctly specified.

docs/app/docsv2/components/button/docs/variantCodeUsage.js (1)

1-9: Apply the same improvements as suggested for other usage files.

This file has the same structure as colorCodeUsage.js and sizeCodeUsage.js. Please apply the same error handling and abstraction improvements suggested in the previous comments.

Comment on lines +3 to +17
code: `import Em from "@radui/ui/Em"

const EmExample = () => (
<div>
<Text>
I have a dream of a scene between the green hills.
<br />
<Em>Clouds</Em> pull away and the sunlight's revealed.
<br />
People don't talk about keeping it <Em>real</Em>.
<br />
<Em>It's understood</Em> that they actually will.
</Text>
</div>
)`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add missing Text component import.

The example code uses the Text component but doesn't import it. Add the import statement to make the example complete.

 const code = {
     javascript: {
         code: `import Em from "@radui/ui/Em"
+import Text from "@radui/ui/Text"

 const EmExample = () => (
📝 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.

Suggested change
code: `import Em from "@radui/ui/Em"
const EmExample = () => (
<div>
<Text>
I have a dream of a scene between the green hills.
<br />
<Em>Clouds</Em> pull away and the sunlight's revealed.
<br />
People don't talk about keeping it <Em>real</Em>.
<br />
<Em>It's understood</Em> that they actually will.
</Text>
</div>
)`
code: `import Em from "@radui/ui/Em"
import Text from "@radui/ui/Text"
const EmExample = () => (
<div>
<Text>
I have a dream of a scene between the green hills.
<br />
<Em>Clouds</Em> pull away and the sunlight's revealed.
<br />
People don't talk about keeping it <Em>real</Em>.
<br />
<Em>It's understood</Em> that they actually will.
</Text>
</div>
)`

Comment on lines +1 to +9
import { getSourceCodeFromPath } from '@/utils/parseSourceCode';

const buttonColorSourceCode = await getSourceCodeFromPath('docs/app/docs/components/button/examples/ButtonColor.tsx');

export const code = {
javascript: {
code: buttonColorSourceCode
}
};
Copy link
Copy Markdown
Contributor

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 for source code retrieval.

The source code retrieval could fail if the file path is incorrect or the file is not accessible. Consider wrapping the operation in a try-catch block.

 import { getSourceCodeFromPath } from '@/utils/parseSourceCode';

-const buttonColorSourceCode = await getSourceCodeFromPath('docs/app/docs/components/button/examples/ButtonColor.tsx');
+let buttonColorSourceCode;
+try {
+    buttonColorSourceCode = await getSourceCodeFromPath('docs/app/docs/components/button/examples/ButtonColor.tsx');
+} catch (error) {
+    console.error('Failed to load button color example:', error);
+    buttonColorSourceCode = '// Error loading example code';
+}

 export const code = {
     javascript: {
         code: buttonColorSourceCode
     }
 };
📝 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.

Suggested change
import { getSourceCodeFromPath } from '@/utils/parseSourceCode';
const buttonColorSourceCode = await getSourceCodeFromPath('docs/app/docs/components/button/examples/ButtonColor.tsx');
export const code = {
javascript: {
code: buttonColorSourceCode
}
};
import { getSourceCodeFromPath } from '@/utils/parseSourceCode';
let buttonColorSourceCode;
try {
buttonColorSourceCode = await getSourceCodeFromPath('docs/app/docs/components/button/examples/ButtonColor.tsx');
} catch (error) {
console.error('Failed to load button color example:', error);
buttonColorSourceCode = '// Error loading example code';
}
export const code = {
javascript: {
code: buttonColorSourceCode
}
};

Comment on lines +8 to +14
{variants.map((variant, index) => {
return <div key={index} className='flex items-center gap-4'>
{sizes.map((size, index) => {
return <Button key={index} size={size} variant={variant} color='pink'>Button</Button>
})}
</div>
})}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid using array indices as React keys.

Using array indices as keys can lead to issues with React's reconciliation process when items are reordered or removed.

-        {variants.map((variant, index) => {
-            return <div key={index} className='flex items-center gap-4'>
-                {sizes.map((size, index) => {
-                    return <Button key={index} size={size} variant={variant} color='pink'>Button</Button>
+        {variants.map((variant) => {
+            return <div key={variant} className='flex items-center gap-4'>
+                {sizes.map((size) => {
+                    return <Button key={`${variant}-${size}`} size={size} variant={variant} color='pink'>Button</Button>
                 })}
             </div>
         })}
📝 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.

Suggested change
{variants.map((variant, index) => {
return <div key={index} className='flex items-center gap-4'>
{sizes.map((size, index) => {
return <Button key={index} size={size} variant={variant} color='pink'>Button</Button>
})}
</div>
})}
{variants.map((variant) => {
return <div key={variant} className='flex items-center gap-4'>
{sizes.map((size) => {
return <Button key={`${variant}-${size}`} size={size} variant={variant} color='pink'>Button</Button>
})}
</div>
})}

Comment on lines +25 to +30
const buttonStyleDescription = {
solid: 'Solid buttons are the most common type of button. They have a solid background color and a border.',
soft: 'Soft buttons have a soft background color and a border.',
outline: 'Outline buttons have a border and a background color.',
ghost: 'Ghost buttons have a border and a background color.',
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Update button variant descriptions for accuracy.

The descriptions for 'outline' and 'ghost' buttons are incorrect:

  • Outline buttons should be described as having only a border with transparent background.
  • Ghost buttons should be described as having no border or background until hovered.
   const buttonStyleDescription = {
     solid: 'Solid buttons are the most common type of button. They have a solid background color and a border.',
     soft: 'Soft buttons have a soft background color and a border.',
-    outline: 'Outline buttons have a border and a background color.',
-    ghost: 'Ghost buttons have a border and a background color.',
+    outline: 'Outline buttons have only a border with transparent background.',
+    ghost: 'Ghost buttons have no border or background until hovered.',
   };
📝 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.

Suggested change
const buttonStyleDescription = {
solid: 'Solid buttons are the most common type of button. They have a solid background color and a border.',
soft: 'Soft buttons have a soft background color and a border.',
outline: 'Outline buttons have a border and a background color.',
ghost: 'Ghost buttons have a border and a background color.',
};
const buttonStyleDescription = {
solid: 'Solid buttons are the most common type of button. They have a solid background color and a border.',
soft: 'Soft buttons have a soft background color and a border.',
outline: 'Outline buttons have only a border with transparent background.',
ghost: 'Ghost buttons have no border or background until hovered.',
};

@GoldGroove06 GoldGroove06 merged commit 6d80089 into main Feb 23, 2025
@GoldGroove06 GoldGroove06 deleted the mdx-migration-b2 branch February 23, 2025 08:18
@coderabbitai coderabbitai Bot mentioned this pull request Mar 18, 2025
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.

2 participants