flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
47
VISUALIZACION/node_modules/polished/lib/helpers/important.js
generated
vendored
Executable file
47
VISUALIZACION/node_modules/polished/lib/helpers/important.js
generated
vendored
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = important;
|
||||
var _errors = _interopRequireDefault(require("../internalHelpers/_errors"));
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
||||
/**
|
||||
* Helper for targeting rules in a style block generated by polished modules that need !important-level specificity. Can optionally specify a rule (or rules) to target specific rules.
|
||||
*
|
||||
* @example
|
||||
* // Styles as object usage
|
||||
* const styles = {
|
||||
* ...important(cover())
|
||||
* }
|
||||
*
|
||||
* // styled-components usage
|
||||
* const div = styled.div`
|
||||
* ${important(cover())}
|
||||
* `
|
||||
*
|
||||
* // CSS as JS Output
|
||||
*
|
||||
* div: {
|
||||
* 'position': 'absolute !important',
|
||||
* 'top': '0 !important',
|
||||
* 'right: '0 !important',
|
||||
* 'bottom': '0 !important',
|
||||
* 'left: '0 !important'
|
||||
* }
|
||||
*/
|
||||
function important(styleBlock, rules) {
|
||||
if (typeof styleBlock !== 'object' || styleBlock === null) {
|
||||
throw new _errors["default"](75, typeof styleBlock);
|
||||
}
|
||||
var newStyleBlock = {};
|
||||
Object.keys(styleBlock).forEach(function (key) {
|
||||
if (typeof styleBlock[key] === 'object' && styleBlock[key] !== null) {
|
||||
newStyleBlock[key] = important(styleBlock[key], rules);
|
||||
} else if (!rules || rules && (rules === key || rules.indexOf(key) >= 0)) {
|
||||
newStyleBlock[key] = styleBlock[key] + " !important";
|
||||
} else {
|
||||
newStyleBlock[key] = styleBlock[key];
|
||||
}
|
||||
});
|
||||
return newStyleBlock;
|
||||
}
|
||||
module.exports = exports.default;
|
||||
Loading…
Add table
Add a link
Reference in a new issue