UNPKG

782 BJavaScriptView Raw
1import { alpha, getPath } from '@mui/system';
2export const colorTransformations = {
3 primary: 'primary.main',
4 textPrimary: 'text.primary',
5 secondary: 'secondary.main',
6 textSecondary: 'text.secondary',
7 error: 'error.main'
8};
9
10const transformDeprecatedColors = color => {
11 return colorTransformations[color] || color;
12};
13
14const getTextDecoration = ({
15 theme,
16 ownerState
17}) => {
18 const transformedColor = transformDeprecatedColors(ownerState.color);
19 const color = getPath(theme, `palette.${transformedColor}`, false) || ownerState.color;
20 const channelColor = getPath(theme, `palette.${transformedColor}Channel`);
21
22 if ('vars' in theme && channelColor) {
23 return `rgba(${channelColor} / 0.4)`;
24 }
25
26 return alpha(color, 0.4);
27};
28
29export default getTextDecoration;
\No newline at end of file