@mui/styles
Version:
MUI Styles - The legacy JSS-based styling solution of Material UI.
31 lines (29 loc) • 943 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = propsToClassKey;
var _utils = require("@mui/utils");
function isEmpty(string) {
return string.length === 0;
}
/**
* Generates string classKey based on the properties provided. It starts with the
* variant if defined, and then it appends all other properties in alphabetical order.
* @param {object} props - the properties for which the classKey should be created
*/
function propsToClassKey(props) {
const {
variant,
...other
} = props;
let classKey = variant || '';
Object.keys(other).sort().forEach(key => {
if (key === 'color') {
classKey += isEmpty(classKey) ? props[key] : (0, _utils.unstable_capitalize)(props[key]);
} else {
classKey += `${isEmpty(classKey) ? key : (0, _utils.unstable_capitalize)(key)}${(0, _utils.unstable_capitalize)(props[key].toString())}`;
}
});
return classKey;
}
;