I've created a custom Button component that looks like the following:
export interface ButtonProps {
label?: string;
onPress: () => any;
}
type iProps = SpacingProps<Theme> &
BorderProps<Theme> &
BackgroundColorProps<Theme> &
ButtonProps &
VariantProps<Theme, 'buttonVariants'>;
const variant = createVariant<Theme>({
themeKey: 'buttonVariants',
defaults: {
color: 'testColor',
margin: {
phone: 's',
tablet: 'm',
},
backgroundColor: 'mainForeground',
},
});
const Button = ({onPress, label, ...props}: iProps): JSX.Element => {
const restyledProps = useRestyle([variant as any], props);
return (
<TouchableOpacity onPress={onPress}>
<Box
justifyContent="center"
alignItems="center"
{...restyledProps}>
<Text variant="button">{label}</Text>
</Box>
</TouchableOpacity>
);
};
How can I make it so that when I call <Button variant="primary" ... /> I can do:
<Button variant="primary" textVariant="button2" ..../>
I know I could do it manually on the ButtonProps interface, but I'd like a more intelligent way of doing this dynamically.