Skip to content

Commit 080dc86

Browse files
committed
Util classname 2
1 parent 7a389a2 commit 080dc86

File tree

14 files changed

+32
-31
lines changed

14 files changed

+32
-31
lines changed

src/components/ui/Collapsible/Collapsible.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { PropsWithChildren, ReactNode, useState } from 'react';
22
import ButtonPrimitive from '~/core/primitives/Button';
3-
3+
import { clsx } from 'clsx';
44
/*
55
* CHECKLIST
66
*
@@ -14,13 +14,13 @@ import ButtonPrimitive from '~/core/primitives/Button';
1414
export type CollapsibleProps = { open?: boolean, title?: string, trigger?: ReactNode} & PropsWithChildren;
1515

1616
const ExpandIcon = () => (
17-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className="size-6">
17+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className={clsx('size-6')}>
1818
<path strokeLinecap="round" strokeLinejoin="round" d="M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15" />
1919
</svg>
2020
);
2121

2222
const CollapseIcon = () => (
23-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className="size-6">
23+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className={clsx('size-6')}>
2424
<path strokeLinecap="round" strokeLinejoin="round" d="M9 9V4.5M9 9H4.5M9 9 3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5 5.25 5.25" />
2525
</svg>
2626
);

src/components/ui/Dropdown/Dropdown.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import Popper from '~/components/tools/Popper/Popper';
3-
3+
import { clsx } from 'clsx';
44
// TODO: fix any
55
export type DropdownProps ={
66
list: {value: any}[];
@@ -9,13 +9,13 @@ export type DropdownProps ={
99

1010
const Dropdown = ({ list = [], selected }: DropdownProps) => {
1111
const PopElem = () => {
12-
return <ul className='bg-white px-2 py-2 shadow-lg rounded-md'>
12+
return <ul className={clsx('bg-white px-2 py-2 shadow-lg rounded-md')}>
1313
{list.map((item, index) => {
1414
return <li key={index}>{item.value}</li>;
1515
})}
1616
</ul>;
1717
};
18-
return <div className='relative'>
18+
return <div className={clsx('relative')}>
1919
<Popper open={false} placement="bottom-start" popperName="dropdown" pop={<PopElem/>}>
2020
<span>Dropdown</span>
2121
</Popper>

src/components/ui/Em/Em.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 from 'react';
33
import { customClassSwitcher } from '~/core';
4-
4+
import { clsx } from 'clsx';
55
const COMPONENT_NAME = 'Em';
66

77
export type EmProps = {
@@ -13,7 +13,7 @@ export type EmProps = {
1313

1414
const Em = ({ children, customRootClass, className, ...props }: EmProps) => {
1515
const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);
16-
return <em className={`${rootClass} ${className}`} {...props}>
16+
return <em className={clsx(rootClass, className)} {...props}>
1717
{children}
1818
</em>;
1919
};

src/components/ui/Heading/Heading.tsx

Lines changed: 3 additions & 3 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 RENDER_AS_ENUMS = [
@@ -35,9 +35,9 @@ const Heading = ({ children, as = undefined, customRootClass = '', className = '
3535

3636
if (as !== undefined && RENDER_AS_ENUMS.find((item) => item.tag === as)) {
3737
const { tag: Tag } = RENDER_AS_ENUMS.find((item) => item.tag === as);
38-
return <Tag className={`${rootClass} ${className}`} {...props}>{children}</Tag>;
38+
return <Tag className={clsx(rootClass, className)} {...props}>{children}</Tag>;
3939
}
40-
return <h1 className={`${rootClass} ${className}`} {...props}>{children}</h1>;
40+
return <h1 className={clsx(rootClass, className)} {...props}>{children}</h1>;
4141
};
4242
Heading.displayName = 'Heading';
4343

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React, { useContext } from 'react';
2-
2+
import { clsx } from 'clsx';
33
import Floater from '~/core/primitives/Floater';
44
import HoverCardContext from '../contexts/HoverCardContext';
55

66
const HoverCardArrow = ({ ...props }) => {
77
const { floatingContext, arrowRef, rootClass } = useContext(HoverCardContext);
88

9-
return <Floater.Arrow className={`${rootClass}-arrow`} {...props} context={floatingContext} ref={arrowRef} />;
9+
return <Floater.Arrow className={clsx(`${rootClass}-arrow`)} {...props} context={floatingContext} ref={arrowRef} />;
1010
};
1111

1212
export default HoverCardArrow;

src/components/ui/HoverCard/fragments/HoverCardContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useContext, useEffect } from 'react';
2-
2+
import { clsx } from 'clsx';
33
import HoverCardContext from '../contexts/HoverCardContext';
44

55
type HoverCardContentProps = {
@@ -32,7 +32,7 @@ const HoverCardContent = ({ children, ...props }: HoverCardContentProps) => {
3232
return <div
3333
onPointerEnter={openWithDelay}
3434
onPointerLeave={closeWithDelay}
35-
className={`${rootClass}`} {...props}
35+
className={clsx(rootClass)} {...props}
3636
ref={floatingRefs.setFloating}
3737
style={floatingStyles}
3838
{...getFloatingProps()}>{children}</div>;

src/components/ui/HoverCard/fragments/HoverCardRoot.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, { useState, useRef } from 'react';
33
import HoverCardContext from '../contexts/HoverCardContext';
44
import Floater from '~/core/primitives/Floater';
55
import { customClassSwitcher } from '~/core';
6-
6+
import { clsx } from 'clsx';
77
const COMPONENT_NAME = 'HoverCard';
88

99
type HoverCardRootProps = {
@@ -114,7 +114,7 @@ const HoverCardRoot = ({ children, open: controlledOpen = undefined, onOpenChang
114114
};
115115

116116
return <HoverCardContext.Provider value={sendValues}>
117-
<div className={rootClass} {...props}>{children}</div>
117+
<div className={clsx(rootClass)} {...props}>{children}</div>
118118
</HoverCardContext.Provider>;
119119
};
120120

src/components/ui/HoverCard/fragments/HoverCardTrigger.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useContext } from 'react';
2-
2+
import { clsx } from 'clsx';
33
import HoverCardContext from '../contexts/HoverCardContext';
44

55
import Primitive from '~/core/primitives/Primitive';
@@ -14,7 +14,7 @@ const HoverCardTrigger = ({ children, className = '', ...props }: HoverCardTrigg
1414

1515
return <>
1616
<Primitive.span
17-
className={`${rootTriggerClass} ${className}`}
17+
className={clsx(rootTriggerClass, className)}
1818
onClick={() => {}}
1919
onMouseEnter={openWithDelay} onMouseLeave={closeWithDelay}
2020
ref={floatingRefs.setReference}

src/components/ui/Kbd/Kbd.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 from 'react';
33
import { customClassSwitcher } from '~/core';
4-
4+
import { clsx } from 'clsx';
55
const COMPONENT_NAME = 'Kbd';
66

77
export type KbdProps = {
@@ -13,7 +13,7 @@ export type KbdProps = {
1313

1414
const Kbd = ({ children, customRootClass, className, ...props }: KbdProps) => {
1515
const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);
16-
return <kbd className={`${rootClass} ${className}`} {...props}>{children}</kbd>;
16+
return <kbd className={clsx(rootClass, className)} {...props}>{children}</kbd>;
1717
};
1818

1919
export default Kbd;

src/components/ui/Link/Link.tsx

Lines changed: 3 additions & 3 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 = 'Link';
@@ -15,11 +15,11 @@ export type LinkProps = {
1515
}
1616

1717
// TODO: in the previous return value
18-
// return <a href={href} alt={alt} className={`${rootClass} ${className}`} {...props}>{children}</a>;
18+
// return <a href={href} alt={alt} className={clsx(rootClass, className)} {...props}>{children}</a>;
1919
// 'alt' prop does not exist on an anchor element
2020
const Link = ({ children, href = '#', alt, customRootClass, className, ...props }: LinkProps) => {
2121
const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);
22-
return <a href={href} className={`${rootClass} ${className}`} {...props}>{children}</a>;
22+
return <a href={href} className={clsx(rootClass, className)} {...props}>{children}</a>;
2323
};
2424

2525
Link.displayName = COMPONENT_NAME;

0 commit comments

Comments
 (0)