({
isMode,
theme,
disabled,
customTextColor,
backgroundColor,
dark,
}: BaseProps & {
customTextColor?: string;
backgroundColor: string;
dark?: boolean;
})
| 90 | }; |
| 91 | |
| 92 | const getButtonTextColor = ({ |
| 93 | isMode, |
| 94 | theme, |
| 95 | disabled, |
| 96 | customTextColor, |
| 97 | backgroundColor, |
| 98 | dark, |
| 99 | }: BaseProps & { |
| 100 | customTextColor?: string; |
| 101 | backgroundColor: string; |
| 102 | dark?: boolean; |
| 103 | }) => { |
| 104 | if (customTextColor && !disabled) { |
| 105 | return customTextColor; |
| 106 | } |
| 107 | |
| 108 | if (theme.isV3) { |
| 109 | if (disabled) { |
| 110 | return theme.colors.onSurfaceDisabled; |
| 111 | } |
| 112 | |
| 113 | if (typeof dark === 'boolean') { |
| 114 | if ( |
| 115 | isMode('contained') || |
| 116 | isMode('contained-tonal') || |
| 117 | isMode('elevated') |
| 118 | ) { |
| 119 | return isDark({ dark, backgroundColor }) ? white : black; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | if (isMode('outlined') || isMode('text') || isMode('elevated')) { |
| 124 | return theme.colors.primary; |
| 125 | } |
| 126 | |
| 127 | if (isMode('contained')) { |
| 128 | return theme.colors.onPrimary; |
| 129 | } |
| 130 | |
| 131 | if (isMode('contained-tonal')) { |
| 132 | return theme.colors.onSecondaryContainer; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | if (disabled) { |
| 137 | return color(theme.dark ? white : black) |
| 138 | .alpha(0.32) |
| 139 | .rgb() |
| 140 | .string(); |
| 141 | } |
| 142 | |
| 143 | if (isMode('contained')) { |
| 144 | return isDark({ dark, backgroundColor }) ? white : black; |
| 145 | } |
| 146 | |
| 147 | return theme.colors.primary; |
| 148 | }; |
| 149 |
no test coverage detected
searching dependent graphs…