Skip to content

Commit

Permalink
fix: default config assigned to the config prop (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrgarciadev authored Jun 30, 2023
1 parent 6df5a52 commit c41079c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const cnBase = (...classes) => voidEmpty(classes.flat(Infinity).filter(Bo

export const cn =
(...classes) =>
(config = defaultConfig) => {
(config) => {
if (!config.twMerge) {
return cnBase(classes);
}
Expand All @@ -46,7 +46,7 @@ const joinObjects = (obj1, obj2) => {
return mergedObj;
};

export const tv = (options, config = defaultConfig) => {
export const tv = (options, configProp) => {
const {
slots: slotProps = {},
variants: variantsProps = {},
Expand All @@ -55,6 +55,8 @@ export const tv = (options, config = defaultConfig) => {
defaultVariants: defaultVariantsProps = {},
} = options;

const config = Object.assign({}, defaultConfig, configProp);

const base = cnBase(options?.extend?.base, options?.base);
const variants = mergeObjects(variantsProps, options?.extend?.variants);
const defaultVariants = Object.assign({}, options?.extend?.defaultVariants, defaultVariantsProps);
Expand Down

0 comments on commit c41079c

Please sign in to comment.