-
-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: recipe extension #1414
feat: recipe extension #1414
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
🦋 Changeset detectedLatest commit: 8623ca4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 25 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
and also merge config.base with assignTo
so it can be used in outdir/types/global.d.ts
1be99df
to
e11dc44
Compare
5261bcb
to
91c6ea3
Compare
Looks awesome. Could we make the changelog rich. i.e. live examples for all the usecases, and add it to the docs too. |
test: expectTypeOf slots.assignTo fix: defineSlotRecipe assignTo fallback typings
This PR and feature have grown stale over time. We still need more requests for this to be in the core library. I'm closing this for now to keep the API surface as is. Another thing we can do is to ship this as a standalone library and see how folks adopt it. Let's go ahead and revisit this in the future. |
That's a lot of work on the contribution to let slip away. Is this even possible as a standalone library, there are plugin interfaces and a way to make this happen? We could use this as well, since we constantly have to |
done & published here https://github.com/astahmer/pandabox/tree/main/packages/define-recipe tho it sounds like you'd prefer using |
Would be a cleaner PR if it didn't modify 70+ files if it wasn't necessary (was there a file rename in here?) |
wow, cool. yes, |
It's basically a need to do small patches to different parts of the cva in a clean way.
|
Add support for Config Recipe (and Slot) extensions
You can now extend config Recipes and config Slots Recipes to easily compose them together.
Added
New
defineRecipeConfigs
identity function that takes an object ofRecipeConfig
objects (or the newRecipeBuilder
interface !) and returns the same object with less strict typing. This can be useful to help Typescript checking
performance when using a large number of recipes or when using complex recipes, with a large number of variants and/or a
large number of styles.
Changed
Config Recipe
The
defineRecipe
method will now return aRecipeBuilder
object instead of aRecipeConfig
object. TheRecipeBuilder
object has the following methods:extend
: add additional variants to or override variants of a recipe.resulting in:
merge
: deep merge a recipe with another recipe. It takes a partialRecipeConfig
object as an argument, which caninclude new (or existing) variants, compound variants, and default variants.
resulting in:
pick
: pick only specified variants from a recipe. It takes a list of variant keys as arguments and returns a newRecipeBuilder
object with only the specified variants. This will also filter out any compound variants that includeany of the omitted variants.
resulting in:
omit
: omit specified variants from a recipe. It takes a list of variant keys as arguments and returns a newRecipeBuilder
object without the specified variants. This will also filter out any compound variants that includeany of the omitted variants.
resulting in:
cast
: make the recipe generic to simplify the typings. It returns a newRecipeConfig
object with the finalcomputed variants, without the
RecipeBuilder
methods.Each of these methods return a new
RecipeBuilder
object, so they can be chained together.Config Slot Recipe
The
defineSlotRecipe
method will now return aSlotRecipeBuilder
object instead of aSlotRecipeConfig
object. TheSlotRecipeBuilder
object has the same following methods as theRecipeBuilder
object:extend
,merge
,pick
, andomit
.In addition, the
SlotRecipeBuilder
object has an object property calledslots
that is aSlotRecipeBuilder
, whichhas the following methods:
add
: add additional slots to a slot recipe. It takes a list of slot names as arguments and returns a newSlotRecipeBuilder
object with the updated slots.resulting in:
pick
: pick only specified slots from a slot recipe. It takes a list of slot keys as arguments and returns a newSlotRecipeBuilder
object with only the specified slots. This will also filter out any styles defined in a slot thatis not picked, as well as any compound variants that include any of the omitted slots.
resulting in:
omit
: omit specified slots from a slot recipe. It takes a list of slot keys as arguments and returns a newSlotRecipeBuilder
object without the specified slots. This will also filter out any styles defined in a slot that isnot picked, as well as any compound variants that include any of the omitted slots.
resulting in:
assignTo
: assign a simple (without slots) recipe to a slot of the current slot recipe. It takes a slot name and arecipe config as arguments and returns a new
SlotRecipeBuilder
object with the updated slot recipe. If a slot namealready has styles defined in a matching (both defined in the simple recipe to assign from and the current slot recipe
being assigned to) variant, the styles will be merged with the existing slot recipe, with priority given to the styles
defined in the simple recipe to assign from.
resulting in: