Skip to content
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

Util classname 1 #616

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
},
"dependencies": {
"@floating-ui/react": "^0.26.20",
"clsx": "^2.1.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
3 changes: 2 additions & 1 deletion src/components/ui/Accordion/fragments/AccordionContent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useContext } from 'react';
import { AccordionContext } from '../contexts/AccordionContext';
import { AccordionItemContext } from '../contexts/AccordionItemContext';
import { clsx } from 'clsx';

type AccordionContentProps = {
children: React.ReactNode;
Expand All @@ -16,7 +17,7 @@ const AccordionContent: React.FC<AccordionContentProps> = ({ children, index, ac

return (
<div
className={`${rootClass}-content ${className}`}
className={clsx(`${rootClass}-content`, className)}
id={`content-${index}`}
role="region"
aria-labelledby={`section-${index}`}
Expand Down
3 changes: 2 additions & 1 deletion src/components/ui/Accordion/fragments/AccordionHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { clsx } from 'clsx';

export type AccordionHeaderProps = {
children: React.ReactNode;
Expand All @@ -7,7 +8,7 @@ export type AccordionHeaderProps = {

const AccordionHeader: React.FC<AccordionHeaderProps> = ({ children, className = '' }) => {
return (
<div className={className}>
<div className={clsx(className)}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

dont need

{children}
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/Accordion/fragments/AccordionItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useContext, useId, useEffect, useRef } from 'react';

import { clsx } from 'clsx';
import { AccordionContext } from '../contexts/AccordionContext';
import { AccordionItemContext } from '../contexts/AccordionItemContext';

Expand Down Expand Up @@ -61,7 +61,7 @@ const AccordionItem: React.FC<AccordionItemProps> = ({ children, value, classNam
<AccordionItemContext.Provider value={{ itemValue, setItemValue, handleBlurEvent, handleClickEvent, handleFocusEvent }}>
<div
ref={accordionItemRef}
className={`${rootClass}-item ${className}`} {...props}
className={clsx(`${rootClass}-item`, className)} {...props}
id={`accordion-data-item-${id}`}
role="region"
aria-labelledby={`accordion-trigger-${id}`}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/Accordion/fragments/AccordionRoot.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useRef, useEffect } from 'react';

import { clsx } from 'clsx';
import { customClassSwitcher } from '~/core';
import { AccordionContext } from '../contexts/AccordionContext';
import { getAllBatchElements, getNextBatchItem, getPrevBatchItem } from '~/core/batches';
Expand Down Expand Up @@ -55,7 +55,7 @@ const AccordionRoot = ({ children, customRootClass }: AccordionRootProps) => {
accordionRef

}}>
<div className={`${rootClass}-root`} ref={accordionRef} >
<div className={clsx(${rootClass}-root)} ref={accordionRef} >
GoldGroove06 marked this conversation as resolved.
Show resolved Hide resolved
{children}
</div>
</AccordionContext.Provider>
Expand Down
3 changes: 2 additions & 1 deletion src/components/ui/Accordion/fragments/AccordionTrigger.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useContext } from 'react';
import { AccordionContext } from '../contexts/AccordionContext';
import { AccordionItemContext } from '../contexts/AccordionItemContext';
import { clsx } from 'clsx';
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Optimize clsx usage by removing template literal

The current implementation uses a template literal within clsx, but clsx can handle multiple arguments directly for better readability and performance.

- className={clsx(`${rootClass}-trigger`, className)}
+ className={clsx(rootClass + '-trigger', className)}

Or even better, if you want to maintain consistency across the codebase:

- className={clsx(`${rootClass}-trigger`, className)}
+ className={clsx([rootClass + '-trigger', className])}

Also applies to: 35-35


💡 Codebase verification

Template literals in clsx calls need to be replaced with string concatenation

The verification revealed inconsistent className handling patterns across the codebase:

  • Several components are using template literals within clsx calls (e.g., clsx(`${rootClass}-trigger`)), which is unnecessary since clsx already handles string concatenation
  • The pattern appears in multiple files:
    • src/components/ui/AlertDialog/fragments/AlertDialogContent.tsx
    • src/components/ui/Accordion/fragments/AccordionTrigger.tsx
    • src/components/ui/Accordion/fragments/AccordionItem.tsx
    • src/components/ui/AlertDialog/fragments/AlertDialogOverlay.tsx
    • src/components/ui/Accordion/fragments/AccordionContent.tsx

These should be simplified to clsx(rootClass + '-trigger') or better yet, use string concatenation without template literals: clsx(rootClass + '-trigger', className).

🔗 Analysis chain

Verify consistent className handling patterns

Let's check for consistency in className handling across the codebase.

Also applies to: 35-35

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for different className handling patterns

# Check for template literals within clsx calls
echo "Checking for template literals within clsx..."
rg "clsx\(`\${.*?}`" --type typescript

# Check for direct string concatenation in className
echo "Checking for string concatenation in className..."
rg "className=.*?\+.*?" --type typescript

# Check for potential mixing of different className utilities
echo "Checking for mixed usage of className utilities..."
rg "(clsx|classnames|cn)\(" --type typescript

Length of output: 645


Script:

#!/bin/bash
# Description: Check for different className handling patterns with correct file types

# Check for template literals within clsx calls
echo "Checking for template literals within clsx..."
rg "clsx\(`.*?\$" -t tsx -t jsx -t ts -t js

# Check for direct string concatenation in className
echo "Checking for string concatenation in className..."
rg "className=.*?\+" -t tsx -t jsx -t ts -t js

# Check for potential mixing of different className utilities
echo "Checking for mixed usage of className utilities..."
rg "(clsx|classnames|cn)\(" -t tsx -t jsx -t ts -t js

# Check for files using clsx
echo "Files using clsx..."
fd -e tsx -e jsx -e ts -e js -x rg -l "from ['\"]clsx['\"]"

Length of output: 217


Script:

#!/bin/bash
# Description: Check for different className handling patterns with correct file types

# Check for template literals within clsx calls
echo "Checking for template literals within clsx..."
rg "clsx\(\`" -t tsx -t jsx -t ts -t js

# Check for direct string concatenation in className
echo "Checking for string concatenation in className..."
rg "className=\".*?\+" -t tsx -t jsx -t ts -t js

# Check for potential mixing of different className utilities
echo "Checking for mixed usage of className utilities..."
rg "from ['\"](?:clsx|classnames)['\"]" -t tsx -t jsx -t ts -t js

# List all className assignments
echo "Checking className patterns..."
rg "className=" -t tsx -t jsx -t ts -t js -C 1

Length of output: 713


Script:

#!/bin/bash
# Description: Check for different className handling patterns

# Check for template literals within clsx calls
echo "Checking for template literals within clsx..."
rg "clsx\(\`"

# Check for direct string concatenation in className
echo "Checking for string concatenation in className..."
rg "className=\".*?\+"

# Check for potential mixing of different className utilities
echo "Checking for mixed usage of className utilities..."
rg "from ['\"](?:clsx|classnames)['\"]"

# List files with className assignments
echo "Files with className patterns..."
rg -l "className="

Length of output: 10305


type AccordionTriggerProps = {
children: React.ReactNode;
Expand Down Expand Up @@ -31,7 +32,7 @@ const AccordionTrigger: React.FC<AccordionTriggerProps> = ({ children, index, cl

<button
type="button"
className={`${rootClass}-trigger ${className}`}
className={clsx(`${rootClass}-trigger`, className)}
onBlur={handleBlurEvent}
onFocus={onFocusHandler}
onKeyDown={(e) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useContext } from 'react';
import { AlertDialogContext } from '../contexts/AlertDialogContext';

import { clsx } from 'clsx';
export type AlertDialogContentProps = {
children: React.ReactNode;
}
Expand All @@ -11,7 +11,7 @@ const AlertDialogContent = ({ children } : AlertDialogContentProps) => {
return (
<>
{isOpen && (
<div className={`${rootClass}-content`}>
<div className={clsx(`${rootClass}-content`)}>
{children}
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { useContext } from 'react';
import Floater from '~/core/primitives/Floater';
import { AlertDialogContext } from '../contexts/AlertDialogContext';

import { clsx } from 'clsx';
const AlertDialogOverlay = () => {
const { isOpen, rootClass, handleOverlayClick } = useContext(AlertDialogContext);
return (
<>
{isOpen && (
<Floater.Overlay
className={`${rootClass}-overlay`} onClick={handleOverlayClick}>
className={clsx(`${rootClass}-overlay`)} onClick={handleOverlayClick}>

</Floater.Overlay>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/AlertDialog/fragments/AlertDialogRoot.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import { customClassSwitcher } from '~/core';
import { AlertDialogContext } from '../contexts/AlertDialogContext';

import { clsx } from 'clsx';
import Floater from '~/core/primitives/Floater';

export type AlertDialogRootProps = {
Expand Down Expand Up @@ -31,7 +31,7 @@ const AlertDialogRoot = ({ children, customRootClass = '', open, onOpenChange, o
const props = { isOpen, handleOpenChange, floaterContext, rootClass, handleOverlayClick };
return (
<AlertDialogContext.Provider value={props}>
<div className={rootClass} >
<div className={clsx(rootClass)} >
Copy link
Collaborator

Choose a reason for hiding this comment

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

dont need

{children}
</div>
</AlertDialogContext.Provider>
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';

import { clsx } from 'clsx';
import AvatarPrimitive from '~/core/primitives/Avatar';

const COMPONENT_NAME = 'Avatar';
Expand All @@ -20,7 +20,7 @@ const Avatar = ({ customRootClass = '', fallback, className, src, alt, ...props
<AvatarPrimitive.Image
src={src}
alt={alt}
className={className}
className={clsx(className)}
Copy link
Collaborator

Choose a reason for hiding this comment

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

dont need

{...props}
/>
<AvatarPrimitive.Fallback>
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/AvatarGroup/AvatarGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';

import { clsx } from 'clsx';
import AvatarGroupRoot from './fragments/AvatarGroupRoot';
import AvatarPrimitiveRoot from '~/core/primitives/Avatar/fragments/AvatarPrimitiveRoot';
import AvatarPrimitiveFallback from '~/core/primitives/Avatar/fragments/AvatarPrimitiveFallback';
Expand All @@ -18,7 +18,7 @@ type AvatarGroupProps = {
}

const AvatarGroup = ({ avatars = [], size, customRootClass = '', className, ...props }: AvatarGroupProps) => {
return <AvatarGroupRoot customRootClass={customRootClass} className={className} {...props} >
return <AvatarGroupRoot customRootClass={customRootClass} className={clsx(className)} {...props} >
Copy link
Collaborator

Choose a reason for hiding this comment

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

dont need it here

{avatars.map((avatar, index) => (
<AvatarPrimitiveRoot key={index} src={avatar.src}>
<AvatarPrimitiveImage src={avatar.src} alt={avatar.alt} />
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/AvatarGroup/fragments/AvatarGroupRoot.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';

import { clsx } from 'clsx';
import { customClassSwitcher } from '~/core/customClassSwitcher';

type AvatarGroupRootProps = {
Expand All @@ -11,7 +11,7 @@ type AvatarGroupRootProps = {
const AvatarGroupRoot = ({ customRootClass = '', children, className, ...props }: AvatarGroupRootProps) => {
const rootClass = customClassSwitcher(customRootClass, 'AvatarGroup');
return (
<div className={`${rootClass} ${className}`} {...props}>
<div className={clsx(rootClass, className)} {...props}>
{children}
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion src/components/ui/Badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import React from 'react';
import BadgeRoot from './fragments/BadgeRoot';
import BadgeContent from './fragments/BadgeContent';
import { clsx } from 'clsx';
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify unnecessary clsx usage

The current usage of clsx with a single argument is redundant since there's no class name concatenation or conditional logic. You can pass the className directly.

-    return <BadgeRoot customRootClass={customRootClass} className={clsx(className)} color={color ?? undefined} {...props}>
+    return <BadgeRoot customRootClass={customRootClass} className={className} color={color ?? undefined} {...props}>

Also applies to: 15-15

export type BadgeProps = {
children?: React.ReactNode,
customRootClass?: string,
Expand All @@ -11,7 +12,7 @@ export type BadgeProps = {
}

const Badge = ({ children, customRootClass, className, color, ...props }: BadgeProps) => {
return <BadgeRoot customRootClass={customRootClass} className={`${className}`} color={color ?? undefined} {...props}>
return <BadgeRoot customRootClass={customRootClass} className={clsx(className)} color={color ?? undefined} {...props}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

dont need here


<BadgeContent>
{children}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/Badge/fragments/BadgeRoot.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { customClassSwitcher } from '~/core';

import { clsx } from 'clsx';
const COMPONENT_NAME = 'Badge';

type BadgeRootProps = {
Expand All @@ -15,7 +15,7 @@ const BadgeRoot = ({ children, customRootClass, className, color, ...props }:Bad
const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);

return (
<span className= {`${rootClass} ${className}`} data-accent-color={color ?? undefined} {...props}>
<span className={clsx(rootClass, className)} data-accent-color={color ?? undefined} {...props}>
{children}
</span>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/BlockQuote/BlockQuote.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';
import React from 'react';

import { clsx } from 'clsx';
import { customClassSwitcher } from '~/core';

const COMPONENT_NAME = 'BlockQuote';
Expand All @@ -14,7 +14,7 @@ export type BlockQuoteProps = {
const BlockQuote = ({ children, customRootClass, className, ...props }: BlockQuoteProps) => {
const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);

return <blockquote className={`${rootClass} ${className}`} {...props}>{children}</blockquote>;
return <blockquote className={clsx(rootClass, className)} {...props}>{children}</blockquote>;
};

BlockQuote.displayName = COMPONENT_NAME;
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';
import React, { ButtonHTMLAttributes, DetailedHTMLProps, PropsWithChildren } from 'react';
import { customClassSwitcher } from '~/core';

import { clsx } from 'clsx';
import ButtonPrimitive from '~/core/primitives/Button';

// make the color prop default accent color
Expand All @@ -21,7 +21,7 @@ const Button = ({ children, type = 'button', customRootClass = '', className = '
return (
<ButtonPrimitive
type={type}
className={`${rootClass} button-${variant} ${className} `} data-accent-color={color ?? undefined} data-size={size}
className={clsx(rootClass, 'button-${variant}', className, '')} data-accent-color={color ?? undefined} data-size={size}
GoldGroove06 marked this conversation as resolved.
Show resolved Hide resolved
{...props}
>
{children}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/Callout/Callout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Props typing issues confirmed in multiple components

The following components have incorrect props typing where props is defined as an array Record<string, any>[] instead of a spread parameter type:

  • src/components/ui/Link/Link.tsx
  • src/components/ui/Em/Em.tsx
  • src/components/ui/Kbd/Kbd.tsx
  • src/components/ui/BlockQuote/BlockQuote.tsx

These components use rest parameters (...props) which should be typed as a record object, not an array. The correct type should be Record<string, any> without the array notation.

🔗 Analysis chain

Verify props typing across all components.

Similar props typing issues were found in multiple components. It would be beneficial to verify and fix this pattern across the entire codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for potentially incorrect props type definitions
rg "props:.*\[\]" "src/components/"

Length of output: 303


Script:

#!/bin/bash
# Let's check the actual component props definitions in these files
echo "=== Link.tsx ==="
ast-grep --pattern 'interface $_ {
  $$$
}' src/components/ui/Link/Link.tsx

echo -e "\n=== Em.tsx ==="
ast-grep --pattern 'interface $_ {
  $$$
}' src/components/ui/Em/Em.tsx

echo -e "\n=== Kbd.tsx ==="
ast-grep --pattern 'interface $_ {
  $$$
}' src/components/ui/Kbd/Kbd.tsx

echo -e "\n=== BlockQuote.tsx ==="
ast-grep --pattern 'interface $_ {
  $$$
}' src/components/ui/BlockQuote/BlockQuote.tsx

Length of output: 513


Script:

#!/bin/bash
# Let's check the component definitions directly
echo "=== Link.tsx ==="
rg -A 10 "type.*Props.*=|interface.*Props" src/components/ui/Link/Link.tsx

echo -e "\n=== Em.tsx ==="
rg -A 10 "type.*Props.*=|interface.*Props" src/components/ui/Em/Em.tsx

echo -e "\n=== Kbd.tsx ==="
rg -A 10 "type.*Props.*=|interface.*Props" src/components/ui/Kbd/Kbd.tsx

echo -e "\n=== BlockQuote.tsx ==="
rg -A 10 "type.*Props.*=|interface.*Props" src/components/ui/BlockQuote/BlockQuote.tsx

Length of output: 2031


import { clsx } from 'clsx';
/**
* Shards
*/
Expand All @@ -15,7 +15,7 @@ export type CalloutProps = {

const COMPONENT_NAME = 'Callout';
const Callout = ({ children, className = '', color, customRootClass, ...props }: CalloutProps) => {
return (<CalloutRoot customRootClass={customRootClass} className={`${className}`} color={color ?? undefined} {...props}>
return (<CalloutRoot customRootClass={customRootClass} className={clsx(className)} color={color ?? undefined} {...props}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

dont need here since its direct usage

{children}
</CalloutRoot>);
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/Callout/fragments/CalloutRoot.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { customClassSwitcher } from '~/core';

import { clsx } from 'clsx';
const COMPONENT_NAME = 'Callout';

type CalloutRootProps = {
Expand All @@ -13,7 +13,7 @@ type CalloutRootProps = {

const CalloutRoot = ({ children, className, color, customRootClass, ...props }: CalloutRootProps) => {
const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);
return <div className={`${rootClass} ${className}`} data-accent-color={color ?? undefined} {...props}>
return <div className={clsx(rootClass, className)} data-accent-color={color ?? undefined} {...props}>
{children}
</div>;
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/Card/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { PropsWithChildren } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Based on the shell script results, I can now generate the final response:

Inconsistent className handling patterns detected

The codebase shows mixed patterns for handling classNames:

  • Some components use clsx utility: Code.tsx, Badge.tsx, Button.tsx
  • Others use template literals: ToggleGroupRoot.tsx, TextArea.tsx, Strong.tsx
  • Base class naming is also inconsistent:
    • Most components use custom root classes without 'rui-' prefix
    • Only Code.tsx uses the 'rui-' prefix pattern
🔗 Analysis chain

Verify consistent className handling across components

Let's verify that all UI components follow the same pattern for className handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for consistent className handling patterns across UI components

# Find all UI component files
echo "Checking className handling patterns..."
rg -l "className=" src/components/ui/ | while read -r file; do
    echo "\nFile: $file"
    # Show className related code with context
    rg -A 2 -B 2 "className=" "$file"
done

# Verify base class naming convention
echo "\nChecking base class naming convention..."
rg "className=.*['\"]rui-" src/components/ui/

Length of output: 46635

import CardRoot from './fragments/CardRoot';

import { clsx } from 'clsx';
Copy link
Collaborator

Choose a reason for hiding this comment

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

can be removed since its direct usage

export type CardProps = {
customRootClass?: string;
className?: string;
props?: any;
Comment on lines 4 to 7
Copy link
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 'any' type and consider consolidating className props

  1. The props?: any type is not recommended as it bypasses TypeScript's type checking. Consider using a more specific type or removing it if not needed.
  2. Having both className and customRootClass props seems redundant. Consider consolidating them into a single className prop.
 export type CardProps = {
-    customRootClass?: string;
     className?: string;
-    props?: any;
+    props?: React.ComponentProps<'div'>;
 } & React.ComponentProps<'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
export type CardProps = {
customRootClass?: string;
className?: string;
props?: any;
export type CardProps = {
className?: string;
props?: React.ComponentProps<'div'>;
} & React.ComponentProps<'div'>;

} & React.ComponentProps<'div'>;

const Card = ({ children, className = '', customRootClass, ...props }: PropsWithChildren<CardProps>) => (
<CardRoot className={className} customRootClass={customRootClass} {...props}>
<CardRoot className={clsx(className)} customRootClass={customRootClass} {...props}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

we dont need this here

{children}
Comment on lines 10 to 12
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify props handling by removing customRootClass

After consolidating the className props, update the component implementation:

-const Card = ({ children, className = '', customRootClass, ...props }: PropsWithChildren<CardProps>) => (
-    <CardRoot className={clsx(className)} customRootClass={customRootClass} {...props}>
+const Card = ({ children, className = '', ...props }: PropsWithChildren<CardProps>) => (
+    <CardRoot className={clsx('rui-card', className)} {...props}>
📝 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 Card = ({ children, className = '', customRootClass, ...props }: PropsWithChildren<CardProps>) => (
<CardRoot className={className} customRootClass={customRootClass} {...props}>
<CardRoot className={clsx(className)} customRootClass={customRootClass} {...props}>
{children}
const Card = ({ children, className = '', ...props }: PropsWithChildren<CardProps>) => (
<CardRoot className={clsx('rui-card', className)} {...props}>
{children}

</CardRoot>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/Card/fragments/CardRoot.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { customClassSwitcher } from '~/core';

import { clsx } from 'clsx';
const COMPONENT_NAME = 'Card';
export type CardRootProps = {
children: React.ReactNode;
Expand All @@ -13,7 +13,7 @@ const CardRoot = ({ children, customRootClass, className = '', ...props }: CardR
const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);

return (
<div className={`${rootClass} ${className}`} {...props} >
<div className={clsx(rootClass, className)} {...props} >
{children}
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/Code/Code.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use client';
import React from 'react';

import { clsx } from 'clsx';
export type CodeProps= {
children: React.ReactNode;
}

const Code = ({ children }: CodeProps) => {
return <code className='rui-code-root'>
return <code className={clsx('rui-code-root')}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing: customRootClass on Code component

Copy link
Collaborator

Choose a reason for hiding this comment

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

Inconsistent use of class prefix - rui is an old format we had used

Copy link
Collaborator

Choose a reason for hiding this comment

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

ignore above comments, referenced new issues for them

{children}
</code>;
};
Expand Down
Loading