diff --git a/package.json b/package.json index 7570e71d..8656025b 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,8 @@ "react-dom": "^18.3.1", "redux": "^4.0.5", "scroll-lock": "^2.1.4", - "swr": "^2.2.5" + "swr": "^2.2.5", + "tailwind-merge": "^2.5.5" }, "bugs": { "url": "https://github.com/ably/ably-ui/issues" diff --git a/src/core/Accordion.tsx b/src/core/Accordion.tsx index 4292cfe1..6bf8a20e 100644 --- a/src/core/Accordion.tsx +++ b/src/core/Accordion.tsx @@ -5,7 +5,6 @@ import { AccordionTrigger, Accordion as RadixAccordion, } from "@radix-ui/react-accordion"; -import clsx from "clsx"; import Icon from "./Icon"; import type { IconName } from "./Icon/types"; @@ -20,6 +19,7 @@ import { isNonTransparentTheme, isStaticTheme, } from "./Accordion/utils"; +import cn from "./utils/cn"; type AccordionRowProps = { children: ReactNode; @@ -85,13 +85,13 @@ const AccordionRow = ({ return ( > = ({ }) => { return ( } > - {clsx( + {cn( size.className[type], { [iconModifierClasses[size.key ?? "md"].left]: index === 1, diff --git a/src/core/styles/Typography.stories.tsx b/src/core/styles/Typography.stories.tsx index 281da70c..b3539cba 100644 --- a/src/core/styles/Typography.stories.tsx +++ b/src/core/styles/Typography.stories.tsx @@ -1,5 +1,5 @@ -import clsx from "clsx"; import React from "react"; +import cn from "../utils/cn"; export default { title: "Styles/Typography", @@ -53,7 +53,7 @@ const styles = { const fontCell = (style) => (
-
+
Sub-header XS
@@ -254,7 +254,7 @@ exports[`Styles/Typography Lists smoke-test 1`] = ` exports[`Styles/Typography Primary smoke-test 1`] = `
-
+
Title XL
@@ -270,7 +270,7 @@ exports[`Styles/Typography Primary smoke-test 1`] = ` .ui-text-title
-
+
Title XS
@@ -278,7 +278,7 @@ exports[`Styles/Typography Primary smoke-test 1`] = ` .ui-text-title.text-title-xs
-
+
h1 XL
@@ -294,7 +294,7 @@ exports[`Styles/Typography Primary smoke-test 1`] = ` .ui-text-h1
-
+
h1 XS
@@ -302,7 +302,7 @@ exports[`Styles/Typography Primary smoke-test 1`] = ` .ui-text-h1.text-h1-xs
-
+
h2 XL
@@ -318,7 +318,7 @@ exports[`Styles/Typography Primary smoke-test 1`] = ` .ui-text-h2
-
+
h2 XS
diff --git a/src/core/utils/cn.ts b/src/core/utils/cn.ts new file mode 100644 index 00000000..05fae746 --- /dev/null +++ b/src/core/utils/cn.ts @@ -0,0 +1,8 @@ +import { twMerge } from "tailwind-merge"; +import clsx, { ClassValue } from "clsx"; + +const cn = (...inputs: ClassValue[]) => { + return twMerge(clsx(inputs)); +}; + +export default cn; diff --git a/yarn.lock b/yarn.lock index 6afcc915..3d57e5c3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7762,6 +7762,11 @@ swr@^2.2.5: client-only "^0.0.1" use-sync-external-store "^1.2.0" +tailwind-merge@^2.5.5: + version "2.5.5" + resolved "https://registry.yarnpkg.com/tailwind-merge/-/tailwind-merge-2.5.5.tgz#98167859b856a2a6b8d2baf038ee171b9d814e39" + integrity sha512-0LXunzzAZzo0tEPxV3I297ffKZPlKDrjj7NXphC8V5ak9yHC5zRmxnOe2m/Rd/7ivsOMJe3JZ2JVocoDdQTRBA== + tailwindcss@^3.3.6: version "3.4.15" resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.4.15.tgz#04808bf4bf1424b105047d19e7d4bfab368044a9"