25 lines
824 B
JavaScript
25 lines
824 B
JavaScript
|
import { getPath } from '@mui/system';
|
||
|
import { alpha } from '@mui/system/colorManipulator';
|
||
|
export const colorTransformations = {
|
||
|
primary: 'primary.main',
|
||
|
textPrimary: 'text.primary',
|
||
|
secondary: 'secondary.main',
|
||
|
textSecondary: 'text.secondary',
|
||
|
error: 'error.main'
|
||
|
};
|
||
|
const transformDeprecatedColors = color => {
|
||
|
return colorTransformations[color] || color;
|
||
|
};
|
||
|
const getTextDecoration = ({
|
||
|
theme,
|
||
|
ownerState
|
||
|
}) => {
|
||
|
const transformedColor = transformDeprecatedColors(ownerState.color);
|
||
|
const color = getPath(theme, `palette.${transformedColor}`, false) || ownerState.color;
|
||
|
const channelColor = getPath(theme, `palette.${transformedColor}Channel`);
|
||
|
if ('vars' in theme && channelColor) {
|
||
|
return `rgba(${channelColor} / 0.4)`;
|
||
|
}
|
||
|
return alpha(color, 0.4);
|
||
|
};
|
||
|
export default getTextDecoration;
|