Skip to content

Commit c2211a3

Browse files
committed
chore: use-tailwind-merge-with-clsx
1 parent eb23314 commit c2211a3

File tree

7 files changed

+26
-13
lines changed

7 files changed

+26
-13
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
"simplebar": "^5.3.6",
9292
"simplebar-react": "^2.3.6",
9393
"smooth-scroll-into-view-if-needed": "^1.1.33",
94+
"tailwind-merge": "^3.0.2",
9495
"usehooks-ts": "^2.9.1"
9596
},
9697
"lint-staged": {

src/lib/accordion/accordion-item.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { useElementSize } from "../../hooks/useElementSize";
33
import Plus from "../../assets/svgs/accordion/plus.svg";
44
import Minus from "../../assets/svgs/accordion/minus.svg";
55

6-
import clsx from "clsx";
76
import { Button } from "react-aria-components";
7+
import { cn } from "../../utils";
88

99
interface AccordionItemProps {
1010
setExpanded: React.Dispatch<React.SetStateAction<number>>;
@@ -25,7 +25,7 @@ const AccordionItem: React.FC<AccordionItemProps> = ({
2525
return (
2626
<div className="my-2">
2727
<Button
28-
className={clsx(
28+
className={cn(
2929
"bg-klerosUIComponentsWhiteBackground border-klerosUIComponentsStroke border",
3030
"hover-medium-blue hover-short-transition hover:cursor-pointer",
3131
"rounded-[3px] px-8 py-[11.5px]",
@@ -35,18 +35,14 @@ const AccordionItem: React.FC<AccordionItemProps> = ({
3535
>
3636
{title}
3737
{expanded ? (
38-
<Minus
39-
className={clsx("fill-klerosUIComponentsPrimaryText h-4 w-4")}
40-
/>
38+
<Minus className={cn("fill-klerosUIComponentsPrimaryText h-4 w-4")} />
4139
) : (
42-
<Plus
43-
className={clsx("fill-klerosUIComponentsPrimaryText h-4 w-4")}
44-
/>
40+
<Plus className={cn("fill-klerosUIComponentsPrimaryText h-4 w-4")} />
4541
)}
4642
</Button>
4743
<div
4844
style={{ height: expanded ? `${height.toString()}px` : 0 }}
49-
className={clsx(
45+
className={cn(
5046
expanded ? `overflow-visible` : "overflow-hidden",
5147
"transition-[height] duration-(--klerosUIComponentsTransitionSpeed) ease-initial",
5248
)}

src/lib/accordion/custom.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { ReactNode, useState } from "react";
22
import AccordionItem from "./accordion-item";
3-
import clsx from "clsx";
3+
import { cn } from "../../utils";
44

55
interface AccordionItem {
66
title: ReactNode;
@@ -20,7 +20,7 @@ const CustomAccordion: React.FC<AccordionProps> = ({
2020
const [expanded, setExpanded] = useState(-1);
2121
return (
2222
<div
23-
className={clsx("box-border flex w-[1000px] flex-col", className)}
23+
className={cn("box-border flex w-[1000px] flex-col", className)}
2424
{...props}
2525
>
2626
{items.map((item, index) => (

src/lib/accordion/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { ReactNode, useState } from "react";
22
import AccordionItem from "./accordion-item";
3-
import clsx from "clsx";
3+
import { cn } from "../../utils";
44

55
interface AccordionItem {
66
title: string;
@@ -31,7 +31,7 @@ const Accordion: React.FC<AccordionProps> = ({
3131
const [expanded, setExpanded] = useState(defaultExpanded ?? -1);
3232
return (
3333
<div
34-
className={clsx("box-border flex w-[1000px] flex-col", className)}
34+
className={cn("box-border flex w-[1000px] flex-col", className)}
3535
{...props}
3636
>
3737
{items.map((item, index) => (

src/stories/accordion.stories.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import Accordion from "../lib/accordion/index";
77

88
const meta = {
99
component: Accordion,
10+
title: "Accordion",
11+
tags: ["autodocs"],
1012
} satisfies Meta<typeof Accordion>;
1113

1214
export default meta;

src/utils/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { twMerge } from "tailwind-merge";
2+
import clsx, { ClassValue } from "clsx";
3+
4+
export const cn = (...inputs: ClassValue[]) => {
5+
return twMerge(clsx(inputs));
6+
};

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,7 @@ __metadata:
12501250
smooth-scroll-into-view-if-needed: "npm:^1.1.33"
12511251
storybook: "npm:^8.6.4"
12521252
styled-components: "npm:^5.3.3"
1253+
tailwind-merge: "npm:^3.0.2"
12531254
tailwindcss: "npm:^4.0.11"
12541255
typescript: "npm:^5.8.2"
12551256
usehooks-ts: "npm:^2.9.1"
@@ -10394,6 +10395,13 @@ __metadata:
1039410395
languageName: node
1039510396
linkType: hard
1039610397

10398+
"tailwind-merge@npm:^3.0.2":
10399+
version: 3.0.2
10400+
resolution: "tailwind-merge@npm:3.0.2"
10401+
checksum: 10c0/73f528345e5130e7690c5c57701155849ae4f0834e0a4bf56bc03e25d4563d45d4905ff9c487a7dce9efdfa18689a223e78365962105ad0e2f2d1226216c66ef
10402+
languageName: node
10403+
linkType: hard
10404+
1039710405
"tailwindcss@npm:4.0.11, tailwindcss@npm:^4.0.11":
1039810406
version: 4.0.11
1039910407
resolution: "tailwindcss@npm:4.0.11"

0 commit comments

Comments
 (0)