Skip to content

Commit

Permalink
feat: update to tailwind-merge v2
Browse files Browse the repository at this point in the history
  • Loading branch information
mskelton committed Jan 20, 2024
1 parent ed21cdd commit d2564da
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 45 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"test": "jest --verbose"
},
"dependencies": {
"tailwind-merge": "^1.14.0"
"tailwind-merge": "^2.2.0"
},
"devDependencies": {
"@commitlint/cli": "^17.2.0",
Expand Down
63 changes: 38 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 17 additions & 15 deletions src/__tests__/tv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ import {tv, cn} from "../index";
const COMMON_UNITS = ["small", "medium", "large"];

const twMergeConfig = {
theme: {
opacity: ["disabled"],
spacing: ["divider", "unit", "unit-2", "unit-4", "unit-6"],
borderWidth: COMMON_UNITS,
borderRadius: COMMON_UNITS,
},
classGroups: {
shadow: [{shadow: COMMON_UNITS}],
"font-size": [{text: ["tiny", ...COMMON_UNITS]}],
"bg-image": ["bg-stripe-gradient"],
"min-w": [
{
"min-w": ["unit", "unit-2", "unit-4", "unit-6"],
},
],
extend: {
theme: {
opacity: ["disabled"],
spacing: ["divider", "unit", "unit-2", "unit-4", "unit-6"],
borderWidth: COMMON_UNITS,
borderRadius: COMMON_UNITS,
},
classGroups: {
shadow: [{shadow: COMMON_UNITS}],
"font-size": [{text: ["tiny", ...COMMON_UNITS]}],
"bg-image": ["bg-stripe-gradient"],
"min-w": [
{
"min-w": ["unit", "unit-2", "unit-4", "unit-6"],
},
],
},
},
};

Expand Down
8 changes: 4 additions & 4 deletions src/config.d.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import type {Config as TwMergeConfig} from "tailwind-merge";
import type {extendTailwindMerge} from "tailwind-merge";
import type {TVVariants} from "./index";
import type {TVGeneratedScreens} from "./generated";

export type TWMConfig = {
/**
* Whether to merge the class names with `tailwind-merge` library.
* It's avoid to have duplicate tailwind classes. (Recommended)
* @see https://github.com/dcastil/tailwind-merge/blob/v1.8.1/README.md
* @see https://github.com/dcastil/tailwind-merge/blob/v2.2.0/README.md
* @default true
*/
twMerge?: boolean;
/**
* The config object for `tailwind-merge` library.
* @see https://github.com/dcastil/tailwind-merge/blob/v1.8.1/docs/configuration.md
* @see https://github.com/dcastil/tailwind-merge/blob/v2.2.0/docs/configuration.md
*/
twMergeConfig?: Partial<TwMergeConfig>;
twMergeConfig?: Parameters<typeof extendTailwindMerge>[0];
};

export type TVConfig<
Expand Down

0 comments on commit d2564da

Please sign in to comment.