native-recipe exports
Everything below is exported from @lynstack/native-recipe. Every export
is documented with TSDoc, so your editor shows the full reference.
Functions
Section titled “Functions”| Export | Signature (simplified) | Explained in |
|---|---|---|
createStyleRecipe |
(config: StyleRecipeConfig) => StyleRecipe |
createStyleRecipe |
createSlotStyleRecipe |
(config: SlotStyleRecipeConfig) => SlotStyleRecipe |
createSlotStyleRecipe |
createThemedRecipes |
<Theme extends object>() => ThemedRecipeCreators<Theme> |
createThemedRecipes |
TypeScript infers the type parameters of createStyleRecipe and
createSlotStyleRecipe from the config. Write only the Theme of
createThemedRecipes.
Types for components
Section titled “Types for components”You use these types in your own code.
| Export | Type parameters | Description | Explained in |
|---|---|---|---|
VariantsOf |
Recipe: the type of a recipe |
The variants a recipe accepts, a themed recipe included. Use it to type a component’s props. | Typing recipes |
NativeStyle |
None | The style of a React Native element: a view, a text, or an image. | Typing recipes |
StyleRecipeVariants |
None | The variants of a style recipe’s config, for variant names not known at compile time. | Typing recipes |
SlotStyleRecipeVariants |
None | The variants of a slot style recipe’s config, for variant names not known at compile time. | Typing recipes |
Types of recipes and configs
Section titled “Types of recipes and configs”TypeScript infers these types. You rarely write them, but your editor shows them.
| Export | Type parameters | Description | Explained in |
|---|---|---|---|
StyleRecipe |
Props, Style, Composition |
A function that returns the style of one element for a selection, with variantKeys, variantOptions, and defaultVariants. |
createStyleRecipe |
StyleRecipeConfig |
Variants, Base, Compounds, DefaultedName, Composed |
The config of createStyleRecipe. |
createStyleRecipe |
StyleCompoundVariant |
Variants, Style |
A compound variant of a style recipe: variants and style. |
createStyleRecipe |
SlotStyleRecipe |
Props, Styles, Composition |
A function that returns the style of every slot for a selection, with its variants listed as a StyleRecipe lists them. |
createSlotStyleRecipe |
SlotStyleRecipeConfig |
Slot, Variants, Base, Compounds, DefaultedName, Composed |
The config of createSlotStyleRecipe. |
createSlotStyleRecipe |
SlotStyleCompoundVariant |
Variants, Styles |
A compound variant of a slot style recipe: variants and styles. |
createSlotStyleRecipe |
SlotStyles |
Slot |
Styles for some of a slot recipe’s slots, keyed by slot name. | createSlotStyleRecipe |
ThemedRecipe |
Theme, Props, Result, Composition |
A recipe whose styles are built from a theme. It takes the theme and a selection, and has withTheme. |
createThemedRecipes |
ThemedRecipeCreators |
Theme |
The recipe creators and the themeToken that createThemedRecipes returns. |
createThemedRecipes |
StyleRecipeOf |
Config, Composed |
The type of the recipe that createStyleRecipe returns for a config declared as const. Annotates an exported recipe. |
Exporting recipes |
SlotStyleRecipeOf |
Config, Composed |
The type of the slot recipe that createSlotStyleRecipe returns for a config declared as const. |
Exporting recipes |
ThemedStyleRecipeOf |
Config, Composed |
The type of the themed recipe that a config function of type Config, which takes the theme as its typed parameter, returns. |
Exporting recipes |
ThemedSlotStyleRecipeOf |
Config, Composed |
The type of the themed slot recipe that a config function of type Config, which takes the theme as its typed parameter, returns. |
Exporting recipes |
VariantSelection |
Variants, DefaultedName |
The variants a selection names, with the optional ones marked optional. | Variants |
VariantOption |
Options |
The values accepted for one variant: its option names, numbers for number names, and booleans for a boolean variant. | Variants |
DefaultVariants |
Variants, DefaultedName |
The option each variant with a default uses when a selection leaves it out. | Variants |
CompoundCondition |
Variants |
The condition of a compound variant: the options it matches for each variant it names. | Variants |
RecipeFunction |
Props, Result |
A function that takes a selection, whose argument is optional when every variant is. | createStyleRecipe |
KindRecipe |
Props, Result, Composition |
The type of a plain recipe, such as one that withTheme returns; StyleRecipe and SlotStyleRecipe are forms of it. |
createThemedRecipes |
RecipeComposition |
Variants, DefaultedName, Value, Slots |
What a recipe passes on to the recipes that compose it, in its type only. | Composing recipes |
ComposedSlot |
Composed, Slot |
The slots of a slot recipe that composes others: theirs, then its own. | Composing recipes |
ComposedVariants |
Composed, Variants |
The variants of a config together with those of the recipes it composes. | Exporting and wrapping recipes |
ComposableKindRecipe |
Value |
Any recipe that composes accepts; use ComposableKindRecipe<NativeStyle>. |
Exporting and wrapping recipes |
ComposableKindSlotRecipe |
Value |
Any slot recipe that a slot recipe’s composes accepts; use ComposableKindSlotRecipe<NativeStyle>. |
Exporting and wrapping recipes |
The Composition parameter carries, in the types only, what a recipe
passes on to the recipes that compose it. The last six types come from
@lynstack/recipe, which native-recipe re-exports so that you need not
install it. KindRecipe and RecipeComposition are part of the type of
a recipe, so a module that emits declarations names them through
native-recipe. ComposedVariants, ComposableKindRecipe, and
ComposableKindSlotRecipe type a function whose configs compose recipes
(see
When the configs compose recipes).