Skip to content

Commit f0d41ef

Browse files
committed
Util for className 1
1 parent 3221b2c commit f0d41ef

File tree

9 files changed

+18
-17
lines changed

9 files changed

+18
-17
lines changed

src/components/ui/Badge/Badge.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import React from 'react';
33
import BadgeRoot from './fragments/BadgeRoot';
44
import BadgeContent from './fragments/BadgeContent';
5+
import { clsx } from 'clsx';
56
export type BadgeProps = {
67
children?: React.ReactNode,
78
customRootClass?: string,
@@ -11,7 +12,7 @@ export type BadgeProps = {
1112
}
1213

1314
const Badge = ({ children, customRootClass, className, color, ...props }: BadgeProps) => {
14-
return <BadgeRoot customRootClass={customRootClass} className={`${className}`} color={color ?? undefined} {...props}>
15+
return <BadgeRoot customRootClass={customRootClass} className={clsx(className)} color={color ?? undefined} {...props}>
1516

1617
<BadgeContent>
1718
{children}

src/components/ui/Badge/fragments/BadgeRoot.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { customClassSwitcher } from '~/core';
3-
3+
import { clsx } from 'clsx';
44
const COMPONENT_NAME = 'Badge';
55

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

1717
return (
18-
<span className= {`${rootClass} ${className}`} data-accent-color={color ?? undefined} {...props}>
18+
<span className={clsx(rootClass, className)} data-accent-color={color ?? undefined} {...props}>
1919
{children}
2020
</span>
2121
);

src/components/ui/BlockQuote/BlockQuote.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22
import React from 'react';
3-
3+
import { clsx } from 'clsx';
44
import { customClassSwitcher } from '~/core';
55

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

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

2020
BlockQuote.displayName = COMPONENT_NAME;

src/components/ui/Button/Button.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22
import React, { ButtonHTMLAttributes, DetailedHTMLProps, PropsWithChildren } from 'react';
33
import { customClassSwitcher } from '~/core';
4-
4+
import { clsx } from 'clsx';
55
import ButtonPrimitive from '~/core/primitives/Button';
66

77
// make the color prop default accent color
@@ -21,7 +21,7 @@ const Button = ({ children, type = 'button', customRootClass = '', className = '
2121
return (
2222
<ButtonPrimitive
2323
type={type}
24-
className={`${rootClass} button-${variant} ${className} `} data-accent-color={color ?? undefined} data-size={size}
24+
className={clsx(rootClass, 'button-${variant}', className, '')} data-accent-color={color ?? undefined} data-size={size}
2525
{...props}
2626
>
2727
{children}

src/components/ui/Callout/Callout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
2+
import { clsx } from 'clsx';
33
/**
44
* Shards
55
*/
@@ -15,7 +15,7 @@ export type CalloutProps = {
1515

1616
const COMPONENT_NAME = 'Callout';
1717
const Callout = ({ children, className = '', color, customRootClass, ...props }: CalloutProps) => {
18-
return (<CalloutRoot customRootClass={customRootClass} className={`${className}`} color={color ?? undefined} {...props}>
18+
return (<CalloutRoot customRootClass={customRootClass} className={clsx(className)} color={color ?? undefined} {...props}>
1919
{children}
2020
</CalloutRoot>);
2121
};

src/components/ui/Callout/fragments/CalloutRoot.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { customClassSwitcher } from '~/core';
3-
3+
import { clsx } from 'clsx';
44
const COMPONENT_NAME = 'Callout';
55

66
type CalloutRootProps = {
@@ -13,7 +13,7 @@ type CalloutRootProps = {
1313

1414
const CalloutRoot = ({ children, className, color, customRootClass, ...props }: CalloutRootProps) => {
1515
const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);
16-
return <div className={`${rootClass} ${className}`} data-accent-color={color ?? undefined} {...props}>
16+
return <div className={clsx(rootClass, className)} data-accent-color={color ?? undefined} {...props}>
1717
{children}
1818
</div>;
1919
};

src/components/ui/Card/Card.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import React, { PropsWithChildren } from 'react';
22
import CardRoot from './fragments/CardRoot';
3-
3+
import { clsx } from 'clsx';
44
export type CardProps = {
55
customRootClass?: string;
66
className?: string;
77
props?: any;
88
} & React.ComponentProps<'div'>;
99

1010
const Card = ({ children, className = '', customRootClass, ...props }: PropsWithChildren<CardProps>) => (
11-
<CardRoot className={className} customRootClass={customRootClass} {...props}>
11+
<CardRoot className={clsx(className)} customRootClass={customRootClass} {...props}>
1212
{children}
1313
</CardRoot>
1414
);

src/components/ui/Card/fragments/CardRoot.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { customClassSwitcher } from '~/core';
3-
3+
import { clsx } from 'clsx';
44
const COMPONENT_NAME = 'Card';
55
export type CardRootProps = {
66
children: React.ReactNode;
@@ -13,7 +13,7 @@ const CardRoot = ({ children, customRootClass, className = '', ...props }: CardR
1313
const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);
1414

1515
return (
16-
<div className={`${rootClass} ${className}`} {...props} >
16+
<div className={clsx(rootClass, className)} {...props} >
1717
{children}
1818
</div>
1919
);

src/components/ui/Code/Code.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use client';
22
import React from 'react';
3-
3+
import { clsx } from 'clsx';
44
export type CodeProps= {
55
children: React.ReactNode;
66
}
77

88
const Code = ({ children }: CodeProps) => {
9-
return <code className='rui-code-root'>
9+
return <code className={clsx('rui-code-root')}>
1010
{children}
1111
</code>;
1212
};

0 commit comments

Comments
 (0)