@@ -49,6 +49,10 @@ const getButtonBackgroundColor = ({
49
49
} : BaseProps & {
50
50
customButtonColor ?: string ;
51
51
} ) => {
52
+ const {
53
+ colors : { surfaceDisabled, elevation, primary, secondaryContainer } ,
54
+ } = theme ;
55
+
52
56
if ( customButtonColor && ! disabled ) {
53
57
return customButtonColor ;
54
58
}
@@ -58,19 +62,19 @@ const getButtonBackgroundColor = ({
58
62
return 'transparent' ;
59
63
}
60
64
61
- return theme . colors . surfaceDisabled ;
65
+ return surfaceDisabled ;
62
66
}
63
67
64
68
if ( isMode ( 'elevated' ) ) {
65
- return theme . colors . elevation . level1 ;
69
+ return elevation . level1 ;
66
70
}
67
71
68
72
if ( isMode ( 'contained' ) ) {
69
- return theme . colors . primary ;
73
+ return primary ;
70
74
}
71
75
72
76
if ( isMode ( 'contained-tonal' ) ) {
73
- return theme . colors . secondaryContainer ;
77
+ return secondaryContainer ;
74
78
}
75
79
76
80
return 'transparent' ;
@@ -88,12 +92,15 @@ const getButtonTextColor = ({
88
92
backgroundColor : string ;
89
93
dark ?: boolean ;
90
94
} ) => {
95
+ const {
96
+ colors : { onSurfaceDisabled, primary, onPrimary, onSecondaryContainer } ,
97
+ } = theme ;
91
98
if ( customTextColor && ! disabled ) {
92
99
return customTextColor ;
93
100
}
94
101
95
102
if ( disabled ) {
96
- return theme . colors . onSurfaceDisabled ;
103
+ return onSurfaceDisabled ;
97
104
}
98
105
99
106
if ( typeof dark === 'boolean' ) {
@@ -107,27 +114,31 @@ const getButtonTextColor = ({
107
114
}
108
115
109
116
if ( isMode ( 'outlined' ) || isMode ( 'text' ) || isMode ( 'elevated' ) ) {
110
- return theme . colors . primary ;
117
+ return primary ;
111
118
}
112
119
113
120
if ( isMode ( 'contained' ) ) {
114
- return theme . colors . onPrimary ;
121
+ return onPrimary ;
115
122
}
116
123
117
124
if ( isMode ( 'contained-tonal' ) ) {
118
- return theme . colors . onSecondaryContainer ;
125
+ return onSecondaryContainer ;
119
126
}
120
127
121
- return theme . colors . primary ;
128
+ return primary ;
122
129
} ;
123
130
124
131
const getButtonBorderColor = ( { isMode, disabled, theme } : BaseProps ) => {
132
+ const {
133
+ colors : { surfaceDisabled, outline } ,
134
+ } = theme ;
135
+
125
136
if ( disabled && isMode ( 'outlined' ) ) {
126
- return theme . colors . surfaceDisabled ;
137
+ return surfaceDisabled ;
127
138
}
128
139
129
140
if ( isMode ( 'outlined' ) ) {
130
- return theme . colors . outline ;
141
+ return outline ;
131
142
}
132
143
133
144
return 'transparent' ;
0 commit comments