@@ -26,12 +26,35 @@ export type ButtonProps = {
26
26
rightIcon ?: boolean
27
27
style ?: ViewStyle
28
28
fontOverride ?: TextStyle
29
+ bgColorsOverride ?: Colors
30
+ fgColorsOverride ?: Colors
29
31
} & Omit < PressableProps , 'style' | 'children' >
30
32
31
33
export const Button = ( props : ButtonProps ) => {
32
- const { type, size, title, icon : Icon , isLoading, rightIcon, disabled, style, fontOverride, ...rest } = props
33
-
34
- const { styles, iconProps, iconPropsPressed} = useStyles ( { type, size, rightIcon, disabled, fontOverride} )
34
+ const {
35
+ type,
36
+ size,
37
+ title,
38
+ icon : Icon ,
39
+ isLoading,
40
+ rightIcon,
41
+ disabled,
42
+ style,
43
+ fontOverride,
44
+ bgColorsOverride,
45
+ fgColorsOverride,
46
+ ...rest
47
+ } = props
48
+
49
+ const { styles, iconProps, iconPropsPressed} = useStyles ( {
50
+ type,
51
+ size,
52
+ rightIcon,
53
+ disabled,
54
+ fontOverride,
55
+ bgColorsOverride,
56
+ fgColorsOverride,
57
+ } )
35
58
36
59
return (
37
60
< Pressable
@@ -72,48 +95,57 @@ const useStyles = ({
72
95
rightIcon,
73
96
disabled,
74
97
fontOverride,
75
- } : Pick < ButtonProps , 'type' | 'size' | 'rightIcon' | 'disabled' | 'fontOverride' > ) => {
98
+ bgColorsOverride,
99
+ fgColorsOverride,
100
+ } : Pick <
101
+ ButtonProps ,
102
+ 'type' | 'size' | 'rightIcon' | 'disabled' | 'fontOverride' | 'bgColorsOverride' | 'fgColorsOverride'
103
+ > ) => {
76
104
const { color, atoms} = useTheme ( )
77
105
78
- const backgroundColors : Colors = {
79
- [ ButtonType . Primary ] : { idle : color . primary_500 , pressed : color . primary_600 , disabled : color . primary_200 } ,
80
- [ ButtonType . Secondary ] : { idle : 'transparent' , pressed : color . primary_100 , disabled : 'transparent' } ,
81
- [ ButtonType . Critical ] : {
82
- idle : color . sys_magenta_500 ,
83
- pressed : color . sys_magenta_600 ,
84
- disabled : color . sys_magenta_300 ,
85
- } ,
86
- [ ButtonType . Text ] : { idle : 'transparent' , pressed : color . gray_100 , disabled : 'transparent' } ,
87
- [ ButtonType . SecondaryText ] : { idle : 'transparent' , pressed : color . gray_100 , disabled : 'transparent' } ,
88
- [ ButtonType . Circle ] : { idle : color . primary_500 , pressed : color . primary_600 , disabled : color . primary_200 } ,
89
- [ ButtonType . Link ] : { idle : 'transparent' , pressed : 'transparent' , disabled : 'transparent' } ,
90
- } [ type ]
91
-
92
- const foregroundColors : Colors = {
93
- [ ButtonType . Primary ] : { idle : color . white_static , pressed : color . white_static , disabled : color . gray_min } ,
94
- [ ButtonType . Secondary ] : {
95
- idle : color . text_primary_medium ,
96
- pressed : color . text_primary_max ,
97
- disabled : color . text_primary_min ,
98
- } ,
99
- [ ButtonType . Critical ] : { idle : color . gray_min , pressed : color . gray_min , disabled : color . gray_min } ,
100
- [ ButtonType . Text ] : {
101
- idle : color . text_primary_medium ,
102
- pressed : color . text_primary_max ,
103
- disabled : color . text_primary_min ,
104
- } ,
105
- [ ButtonType . SecondaryText ] : {
106
- idle : color . text_gray_medium ,
107
- pressed : color . text_gray_max ,
108
- disabled : color . text_gray_min ,
109
- } ,
110
- [ ButtonType . Circle ] : { idle : color . white_static , pressed : color . white_static , disabled : color . gray_min } ,
111
- [ ButtonType . Link ] : {
112
- idle : color . text_primary_medium ,
113
- pressed : color . text_primary_max ,
114
- disabled : color . text_primary_min ,
115
- } ,
116
- } [ type ]
106
+ const backgroundColors : Colors =
107
+ bgColorsOverride ??
108
+ {
109
+ [ ButtonType . Primary ] : { idle : color . primary_500 , pressed : color . primary_600 , disabled : color . primary_200 } ,
110
+ [ ButtonType . Secondary ] : { idle : 'transparent' , pressed : color . primary_100 , disabled : 'transparent' } ,
111
+ [ ButtonType . Critical ] : {
112
+ idle : color . sys_magenta_500 ,
113
+ pressed : color . sys_magenta_600 ,
114
+ disabled : color . sys_magenta_300 ,
115
+ } ,
116
+ [ ButtonType . Text ] : { idle : 'transparent' , pressed : color . gray_100 , disabled : 'transparent' } ,
117
+ [ ButtonType . SecondaryText ] : { idle : 'transparent' , pressed : color . gray_100 , disabled : 'transparent' } ,
118
+ [ ButtonType . Circle ] : { idle : color . primary_500 , pressed : color . primary_600 , disabled : color . primary_200 } ,
119
+ [ ButtonType . Link ] : { idle : 'transparent' , pressed : 'transparent' , disabled : 'transparent' } ,
120
+ } [ type ]
121
+
122
+ const foregroundColors : Colors =
123
+ fgColorsOverride ??
124
+ {
125
+ [ ButtonType . Primary ] : { idle : color . white_static , pressed : color . white_static , disabled : color . gray_min } ,
126
+ [ ButtonType . Secondary ] : {
127
+ idle : color . text_primary_medium ,
128
+ pressed : color . text_primary_max ,
129
+ disabled : color . text_primary_min ,
130
+ } ,
131
+ [ ButtonType . Critical ] : { idle : color . gray_min , pressed : color . gray_min , disabled : color . gray_min } ,
132
+ [ ButtonType . Text ] : {
133
+ idle : color . text_primary_medium ,
134
+ pressed : color . text_primary_max ,
135
+ disabled : color . text_primary_min ,
136
+ } ,
137
+ [ ButtonType . SecondaryText ] : {
138
+ idle : color . text_gray_medium ,
139
+ pressed : color . text_gray_max ,
140
+ disabled : color . text_gray_min ,
141
+ } ,
142
+ [ ButtonType . Circle ] : { idle : color . white_static , pressed : color . white_static , disabled : color . gray_min } ,
143
+ [ ButtonType . Link ] : {
144
+ idle : color . text_primary_medium ,
145
+ pressed : color . text_primary_max ,
146
+ disabled : color . text_primary_min ,
147
+ } ,
148
+ } [ type ]
117
149
118
150
const backgroundColor = disabled ? backgroundColors . disabled : backgroundColors . idle
119
151
const foregroundColor = disabled ? foregroundColors . disabled : foregroundColors . idle
0 commit comments