Skip to content

Commit

Permalink
Util for className 1
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldGroove06 committed Dec 9, 2024
1 parent 3221b2c commit f0d41ef
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 17 deletions.
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';
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}>

<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}
{...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';

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}>
{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';
import CardRoot from './fragments/CardRoot';

import { clsx } from 'clsx';
export type CardProps = {
customRootClass?: string;
className?: string;
props?: any;
} & React.ComponentProps<'div'>;

const Card = ({ children, className = '', customRootClass, ...props }: PropsWithChildren<CardProps>) => (
<CardRoot className={className} customRootClass={customRootClass} {...props}>
<CardRoot className={clsx(className)} customRootClass={customRootClass} {...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')}>
{children}
</code>;
};
Expand Down

0 comments on commit f0d41ef

Please sign in to comment.