vanilla-extract icon indicating copy to clipboard operation
vanilla-extract copied to clipboard

Export PatternOptions and VariantGroups types?

Open igor10k opened this issue 2 years ago • 0 comments

Could PatternOptions and VariantGroups be exported in @vanilla-extract/recipes to allow creating extendable recipes?

Example:

const createRecipe = <T extends VariantGroups>(
  extension: PatternOptions<T | typeof baseVariants>,
) => {
  return recipe({
    base: extension.base,
    variants: {
      ...baseVariants,
      ...extension.variants,
    },
    compoundVariants: extension.compoundVariants,
    defaultVariants: {
      ...baseDefaultVariants,
      ...extension.defaultVariants,
    },
  });
};

const button = createRecipe<typeof buttonVariants>({
  variants: buttonVariants,
  compoundVariants: [
    // mixing variants from baseVariants and buttonVariants here
  ]
});

There are ways to make it work without them but at the expense of losing auto-suggestions.

igor10k avatar May 24 '22 18:05 igor10k