Allow variant definitions as functions that receive the current variant value #1011
jake-carpenter
started this conversation in
Feature Requests
Replies: 1 comment 2 replies
-
|
Why not dynamic function? type Appearance = 'round' | 'square'
const styles = StyleSheet.create((theme) => ({
container: (value: Appearance) => ({
...theme.components.myComponent.appearance[value],
}),
})) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I would like variant definitions in the StyleSheet to be functions that receive the currently selected variant value and return a style object (or style fragment). This makes it easy to map a variant directly to theme data without duplicating keys for each variant value.
Example of what I might have today:
In a situation where my theme has defined these 1:1, a function could simplify this:
Beta Was this translation helpful? Give feedback.
All reactions