@@ -49,6 +49,10 @@ const getButtonBackgroundColor = ({
4949} : BaseProps & {
5050 customButtonColor ?: string ;
5151} ) => {
52+ const {
53+ colors : { surfaceDisabled, elevation, primary, secondaryContainer } ,
54+ } = theme ;
55+
5256 if ( customButtonColor && ! disabled ) {
5357 return customButtonColor ;
5458 }
@@ -58,19 +62,19 @@ const getButtonBackgroundColor = ({
5862 return 'transparent' ;
5963 }
6064
61- return theme . colors . surfaceDisabled ;
65+ return surfaceDisabled ;
6266 }
6367
6468 if ( isMode ( 'elevated' ) ) {
65- return theme . colors . elevation . level1 ;
69+ return elevation . level1 ;
6670 }
6771
6872 if ( isMode ( 'contained' ) ) {
69- return theme . colors . primary ;
73+ return primary ;
7074 }
7175
7276 if ( isMode ( 'contained-tonal' ) ) {
73- return theme . colors . secondaryContainer ;
77+ return secondaryContainer ;
7478 }
7579
7680 return 'transparent' ;
@@ -88,12 +92,15 @@ const getButtonTextColor = ({
8892 backgroundColor : string ;
8993 dark ?: boolean ;
9094} ) => {
95+ const {
96+ colors : { onSurfaceDisabled, primary, onPrimary, onSecondaryContainer } ,
97+ } = theme ;
9198 if ( customTextColor && ! disabled ) {
9299 return customTextColor ;
93100 }
94101
95102 if ( disabled ) {
96- return theme . colors . onSurfaceDisabled ;
103+ return onSurfaceDisabled ;
97104 }
98105
99106 if ( typeof dark === 'boolean' ) {
@@ -107,27 +114,31 @@ const getButtonTextColor = ({
107114 }
108115
109116 if ( isMode ( 'outlined' ) || isMode ( 'text' ) || isMode ( 'elevated' ) ) {
110- return theme . colors . primary ;
117+ return primary ;
111118 }
112119
113120 if ( isMode ( 'contained' ) ) {
114- return theme . colors . onPrimary ;
121+ return onPrimary ;
115122 }
116123
117124 if ( isMode ( 'contained-tonal' ) ) {
118- return theme . colors . onSecondaryContainer ;
125+ return onSecondaryContainer ;
119126 }
120127
121- return theme . colors . primary ;
128+ return primary ;
122129} ;
123130
124131const getButtonBorderColor = ( { isMode, disabled, theme } : BaseProps ) => {
132+ const {
133+ colors : { surfaceDisabled, outline } ,
134+ } = theme ;
135+
125136 if ( disabled && isMode ( 'outlined' ) ) {
126- return theme . colors . surfaceDisabled ;
137+ return surfaceDisabled ;
127138 }
128139
129140 if ( isMode ( 'outlined' ) ) {
130- return theme . colors . outline ;
141+ return outline ;
131142 }
132143
133144 return 'transparent' ;
0 commit comments