Multiple arguments in utils functions #1070
-
It would make sense if utils could use multiple arguments. For example, there is a way to parse a single string argument. Is there any other ideas to achieve like this? createStitches({
utils: {
paddingVH: (v, h) => ({
paddingTop: v,
paddingBottom: v,
paddingLeft: h,
paddingRight: h,
}),
},
}); |
Beta Was this translation helpful? Give feedback.
Answered by
sandgraham
Aug 9, 2022
Replies: 1 comment 1 reply
-
I've been using an array or object to wrap the arguments into a single argument. createStitches({
utils: {
paddingVH: ([v, h]: [number, number]) => ({
paddingTop: v,
paddingBottom: v,
paddingLeft: h,
paddingRight: h,
}),
},
});
css({ paddingVH: [2, 3] }); Can also use type Size = Stitches.PropertyValue<'sizes'>;
createStitches({
utils: {
paddingVH: ([v, h]: [Size, Size]) => ({
paddingTop: v,
paddingBottom: v,
paddingLeft: h,
paddingRight: h,
}),
},
});
css({ paddingVH: ["$2", "$3"] }); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
nob3110
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've been using an array or object to wrap the arguments into a single argument.
Can also use
Stitches.PropertyValue
to keep the types theme aware: