Skip to content

Commit 0920a65

Browse files
committed
Type: Compound Variants Util Function
1 parent c1a1e2d commit 0920a65

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/css/src/rules/types.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ export type PatternOptions<
8585
ConditionalVariants<Variants, ToggleVariants>
8686
>;
8787
compoundVariants?: Array<
88-
CompoundVariant<ConditionalVariants<Variants, ToggleVariants>>
88+
| CompoundVariant<ConditionalVariants<Variants, ToggleVariants>>
89+
| CompoundFnType<VariantGroups>
8990
>;
9091
};
9192

@@ -106,6 +107,16 @@ export type RulesVariants<RuleFn extends RuntimeFn<VariantGroups>> =
106107
export type RecipeVariants<RecipeFn extends RuntimeFn<VariantGroups>> =
107108
RulesVariants<RecipeFn>;
108109

110+
type CompoundCondition<Variants extends VariantGroups> = {
111+
[K in keyof Variants]: { [key in keyof Variants[K]]: string };
112+
};
113+
export type CompoundFnType<Variants extends VariantGroups> = (
114+
context: Variants
115+
) => Array<{
116+
condition: CompoundCondition<Variants>;
117+
style: RecipeStyleRule;
118+
}>;
119+
109120
// == Tests ====================================================================
110121
if (import.meta.vitest) {
111122
const { describe, it, assertType, expectTypeOf } = import.meta.vitest;

0 commit comments

Comments
 (0)