mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 17:35:16 +00:00
63 lines
2.2 KiB
JavaScript
63 lines
2.2 KiB
JavaScript
|
"use strict";
|
||
|
|
||
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
exports.default = getStylesCreator;
|
||
|
|
||
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||
|
|
||
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
||
|
|
||
|
var _utils = require("@material-ui/utils");
|
||
|
|
||
|
var _noopTheme = _interopRequireDefault(require("./noopTheme"));
|
||
|
|
||
|
function getStylesCreator(stylesOrCreator) {
|
||
|
var themingEnabled = typeof stylesOrCreator === 'function';
|
||
|
|
||
|
if (process.env.NODE_ENV !== 'production') {
|
||
|
if ((0, _typeof2.default)(stylesOrCreator) !== 'object' && !themingEnabled) {
|
||
|
console.error(['Material-UI: The `styles` argument provided is invalid.', 'You need to provide a function generating the styles or a styles object.'].join('\n'));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
create: function create(theme, name) {
|
||
|
var styles;
|
||
|
|
||
|
try {
|
||
|
styles = themingEnabled ? stylesOrCreator(theme) : stylesOrCreator;
|
||
|
} catch (err) {
|
||
|
if (process.env.NODE_ENV !== 'production') {
|
||
|
if (themingEnabled === true && theme === _noopTheme.default) {
|
||
|
// TODO: prepend error message/name instead
|
||
|
console.error(['Material-UI: The `styles` argument provided is invalid.', 'You are providing a function without a theme in the context.', 'One of the parent elements needs to use a ThemeProvider.'].join('\n'));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
throw err;
|
||
|
}
|
||
|
|
||
|
if (!name || !theme.overrides || !theme.overrides[name]) {
|
||
|
return styles;
|
||
|
}
|
||
|
|
||
|
var overrides = theme.overrides[name];
|
||
|
var stylesWithOverrides = (0, _extends2.default)({}, styles);
|
||
|
Object.keys(overrides).forEach(function (key) {
|
||
|
if (process.env.NODE_ENV !== 'production') {
|
||
|
if (!stylesWithOverrides[key]) {
|
||
|
console.warn(['Material-UI: You are trying to override a style that does not exist.', "Fix the `".concat(key, "` key of `theme.overrides.").concat(name, "`.")].join('\n'));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
stylesWithOverrides[key] = (0, _utils.deepmerge)(stylesWithOverrides[key], overrides[key]);
|
||
|
});
|
||
|
return stylesWithOverrides;
|
||
|
},
|
||
|
options: {}
|
||
|
};
|
||
|
}
|