@@ -4,20 +4,23 @@ import { TextStyle, StyleProp, View, ActivityIndicator } from 'react-native';
44import { IconProps } from '@nomada-sh/react-native-eyecandy-icons' ;
55
66import { Body } from '../../typography' ;
7- import { ButtonBase , ButtonBaseProps } from '../ButtonBase' ;
7+ import { ButtonBase , ButtonBaseProps , ButtonBaseStyles } from '../ButtonBase' ;
88
99import useStyles from './useStyles' ;
1010
11- export interface ButtonProps extends Omit < ButtonBaseProps , 'children' > {
11+ export interface ButtonStyles extends ButtonBaseStyles {
12+ text ?: StyleProp < TextStyle > ;
13+ }
14+ export interface ButtonProps
15+ extends Omit < ButtonBaseProps , 'children' | 'styles' > {
1216 children ?: string ;
13- text ?: string ;
1417 textStyle ?: StyleProp < TextStyle > ;
1518 icon ?: React . ComponentType < IconProps > | React . ReactElement < any > | null ;
1619 loadingOverlay ?: boolean ;
20+ styles ?: ButtonStyles ;
1721}
1822
1923export function Button ( {
20- text,
2124 color,
2225 inverse,
2326 textStyle,
@@ -26,6 +29,7 @@ export function Button({
2629 loading : loadingProp ,
2730 disabled : disabledProp ,
2831 loadingOverlay,
32+ styles : customStyles ,
2933 ...props
3034} : ButtonProps ) {
3135 const styles = useStyles ( { color, inverse } ) ;
@@ -59,12 +63,19 @@ export function Button({
5963 inverse = { inverse }
6064 disabled = { disabled }
6165 loading = { loading }
66+ styles = { customStyles }
6267 { ...props }
6368 >
6469 { icon ? < View style = { styles . loadingContainer } > { icon } </ View > : null }
65- < Body weight = "bold" size = "large" style = { [ styles . text , textStyle ] } >
66- { children ?? text }
67- </ Body >
70+ { typeof children === 'string' ? (
71+ < Body
72+ weight = "bold"
73+ size = "large"
74+ style = { [ styles . text , textStyle , customStyles ?. text ] }
75+ >
76+ { children }
77+ </ Body >
78+ ) : null }
6879 </ ButtonBase >
6980 ) ;
7081}
0 commit comments