forked from CITKParus/P8-Panels
44 lines
1.8 KiB
JavaScript
44 lines
1.8 KiB
JavaScript
//---------------------
|
|
//Подключение библиотек
|
|
//---------------------
|
|
|
|
import { alpha } from "@mui/material/styles"; //Интерфейсные стили компонентов
|
|
|
|
//----------------
|
|
//Интерфейс модуля
|
|
//----------------
|
|
|
|
//Универсальное определение цвета кнопки
|
|
export const getButtonColorStyles = (color, theme, isOutlined = false) => {
|
|
//Определяем цвет
|
|
const colorObj = !color ? theme.palette.primary : theme.palette[color];
|
|
//Если цвет неопределен или нет разбивки на оттенки
|
|
if (!colorObj || typeof colorObj !== "object" || !colorObj.main) {
|
|
return {};
|
|
}
|
|
//Возвращаем результат
|
|
return {
|
|
backgroundColor: !isOutlined ? colorObj.main : null,
|
|
color: !isOutlined ? colorObj.contrastText || "#FFF" : colorObj.main,
|
|
...(isOutlined ? { border: `1px solid ${colorObj.main}` } : {}),
|
|
"&:hover": {
|
|
textDecoration: "none",
|
|
backgroundColor: !isOutlined ? colorObj.dark || colorObj.main : alpha(colorObj.dark, 0.04),
|
|
...(!isOutlined
|
|
? { boxShadow: "0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12)" }
|
|
: {})
|
|
},
|
|
"&:active": {
|
|
backgroundColor: !isOutlined ? colorObj.light || colorObj.main : null,
|
|
...(!isOutlined
|
|
? { boxShadow: "0px 5px 5px -3px rgba(0, 0, 0, 0.2) 0px 8px 10px 1px rgba(0, 0, 0, 0.14) 0px 3px 14px 2px rgba(0, 0, 0, 0.12)" }
|
|
: {})
|
|
},
|
|
"&.Mui-disabled": {
|
|
boxShadow: "none",
|
|
backgroundColor: "rgba(0, 0, 0, 0.12)",
|
|
color: "rgba(0, 0, 0, 0.26)"
|
|
}
|
|
};
|
|
};
|