11import { TextStyle , ViewStyle } from 'react-native' ;
22
3- import { Theme } from '../../theme/ThemeInterface' ;
3+ import { ButtonColor , Theme } from '../../theme/ThemeInterface' ;
4+ import { darken } from './changeColor' ;
45
56export type ButtonColorProps = ViewStyle & {
7+ backgroundColor : string ;
68 color : string ;
7- focusColor : string ;
89 loadingBackgroundColor ?: string ;
910} ;
1011
11- export interface ButtonColors {
12- default : ButtonColorProps ;
13- danger : ButtonColorProps ;
14- primary : ButtonColorProps ;
15- secondary : ButtonColorProps ;
16- }
17-
18- export type ButtonColor = keyof ButtonColors ;
19-
2012export interface ButtonAppearances {
21- minimal : ButtonColors ;
22- primary : ButtonColors ;
23- outline : ButtonColors ;
13+ minimal : { [ size in ButtonColor ] : ButtonColorProps } ;
14+ primary : { [ size in ButtonColor ] : ButtonColorProps } ;
15+ outline : { [ size in ButtonColor ] : ButtonColorProps } ;
2416}
2517
2618export type ButtonAppearance = keyof ButtonAppearances ;
@@ -57,65 +49,47 @@ export const getButtonVariables = (theme: Theme): ButtonVariables => {
5749 default : {
5850 backgroundColor : theme . colors . background . content ,
5951 color : theme . colors . text . default ,
60-
61- focusColor : theme . colors . background . greyDefault ,
6252 } ,
6353
6454 danger : {
6555 backgroundColor : theme . colors . background . content ,
6656 color : theme . colors . text . danger ,
67-
68- focusColor : theme . colors . background . greyDefault ,
6957 } ,
7058 primary : {
7159 backgroundColor : theme . colors . background . content ,
7260 color : theme . colors . text . primary ,
73-
74- focusColor : theme . colors . background . greyDefault ,
7561 } ,
7662 secondary : {
7763 backgroundColor : theme . colors . background . content ,
78- color : theme . colors . text . secondary
79- ? theme . colors . text . secondary
80- : theme . colors . text . default ,
81-
82- focusColor : theme . colors . background . greyDefault ,
64+ color : theme . colors . text . secondary ,
8365 } ,
8466 } ,
8567 primary : {
8668 default : {
87- backgroundColor : theme . colors . background . greyLight ,
88- borderColor : theme . colors . border . default ,
89- color : theme . colors . text . default ,
69+ backgroundColor : theme . colors . button . default ,
70+ color : theme . colors . button . defaultText ,
9071
91- focusColor : theme . colors . background . greyDefault ,
9272 loadingBackgroundColor : theme . colors . background . overlay ,
9373 } ,
9474
9575 danger : {
96- backgroundColor : theme . colors . background . dangerDefault ,
97- borderColor : theme . colors . border . danger ,
98- color : theme . colors . text . white ,
76+ backgroundColor : theme . colors . button . danger ,
77+ color : theme . colors . button . dangerText ,
9978
100- focusColor : theme . colors . background . dangerDark ,
10179 loadingBackgroundColor : theme . colors . background . dangerLight ,
10280 } ,
10381
10482 primary : {
105- backgroundColor : theme . colors . background . primaryDefault ,
106- borderColor : theme . colors . border . primary ,
107- color : theme . colors . text . white ,
83+ backgroundColor : theme . colors . button . primary ,
84+ color : theme . colors . button . primaryText ,
10885
109- focusColor : theme . colors . background . primaryDark ,
11086 loadingBackgroundColor : theme . colors . background . primaryLight ,
11187 } ,
11288
11389 secondary : {
114- backgroundColor : theme . colors . background . secondaryDefault ,
115- borderColor : theme . colors . border . secondary ,
116- color : theme . colors . text . white ,
90+ backgroundColor : theme . colors . button . secondary ,
91+ color : theme . colors . button . secondaryText ,
11792
118- focusColor : theme . colors . background . secondaryDark ,
11993 loadingBackgroundColor : theme . colors . background . secondaryLight ,
12094 } ,
12195 } ,
@@ -126,40 +100,32 @@ export const getButtonVariables = (theme: Theme): ButtonVariables => {
126100 borderColor : theme . colors . text . default ,
127101 borderWidth : 3 ,
128102 color : theme . colors . text . default ,
129-
130- focusColor : theme . colors . background . greyDefault ,
131103 } ,
132104
133105 danger : {
134106 backgroundColor : theme . colors . background . content ,
135107 borderColor : theme . colors . border . danger ,
136108 borderWidth : 3 ,
137109 color : theme . colors . text . danger ,
138-
139- focusColor : theme . colors . background . dangerLight ,
140110 } ,
141111
142112 primary : {
143113 backgroundColor : theme . colors . background . content ,
144114 borderColor : theme . colors . border . primary ,
145115 borderWidth : 3 ,
146116 color : theme . colors . text . primary ,
147-
148- focusColor : theme . colors . background . primaryLight ,
149117 } ,
150118
151119 secondary : {
152120 backgroundColor : theme . colors . background . content ,
153121 borderColor : theme . colors . border . secondary ,
154122 borderWidth : 3 ,
155123 color : theme . colors . text . secondary ,
156-
157- focusColor : theme . colors . background . secondaryLight ,
158124 } ,
159125 } ,
160126 } ,
161127 disabled : {
162- backgroundColor : theme . colors . background . greyDark ,
128+ backgroundColor : theme . colors . button . disabled ,
163129
164130 color : theme . colors . text . muted ,
165131 } ,
@@ -232,7 +198,6 @@ export const getButtonStyles: GetButtonStyles = (buttonStyleProps, theme) => {
232198
233199 const {
234200 color : textColor ,
235- focusColor,
236201 loadingBackgroundColor,
237202 ...buttonStyle
238203 } = appearances [ appearance ] [ color ] ;
@@ -261,7 +226,10 @@ export const getButtonStyles: GetButtonStyles = (buttonStyleProps, theme) => {
261226 }
262227 : { } ) ,
263228 } ,
264- focusColor,
229+ focusColor :
230+ appearance === 'minimal' || appearance === 'outline'
231+ ? theme . colors . button . default
232+ : darken ( buttonStyle . backgroundColor , 0.05 ) ,
265233 textStyle : {
266234 alignItems : 'center' ,
267235 color : isDisabled ? disabledButtonTextColor : textColor ,
0 commit comments