postcss-apply
Advanced tools
Comparing version 0.8.0 to 0.9.0
@@ -8,3 +8,8 @@ # postcss-apply change Log | ||
## [unreleased] | ||
## [0.9.0] - 2018-03-10 | ||
### Added | ||
* Allow both object and string types for the `sets` option. | ||
## [0.8.0] - 2017-05-28 | ||
@@ -59,3 +64,4 @@ ### Added | ||
[Unreleased]: https://github.com/pascalduez/postcss-apply/compare/0.8.0...HEAD | ||
[Unreleased]: https://github.com/pascalduez/postcss-apply/compare/0.9.0...HEAD | ||
[0.9.0]: https://github.com/pascalduez/postcss-apply/compare/0.8.0...0.9.0 | ||
[0.8.0]: https://github.com/pascalduez/postcss-apply/compare/0.7.0...0.8.0 | ||
@@ -62,0 +68,0 @@ [0.7.0]: https://github.com/pascalduez/postcss-apply/compare/0.6.1...0.7.0 |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.default = kebabify; | ||
exports.kebabify = kebabify; | ||
function kebabify(prop) { | ||
@@ -16,2 +16,6 @@ var upperToHyphen = function upperToHyphen(match, offset, string) { | ||
return prop.replace(/[A-Z]/g, upperToHyphen); | ||
} | ||
} | ||
var isPlainObject = exports.isPlainObject = function isPlainObject(arg) { | ||
return Object.prototype.toString.call(arg) === '[object Object]'; | ||
}; |
@@ -25,4 +25,2 @@ 'use strict'; | ||
var _utils2 = _interopRequireDefault(_utils); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -52,2 +50,3 @@ | ||
// $FlowFixMe | ||
Object.keys(sets).forEach(function (setName) { | ||
@@ -57,10 +56,18 @@ var newRule = _postcss2.default.rule({ selector: `--${setName}` }); | ||
// $FlowFixMe | ||
(0, _entries2.default)(sets[setName]).forEach(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 2), | ||
prop = _ref2[0], | ||
value = _ref2[1]; | ||
var set = sets[setName]; | ||
newRule.prepend(_postcss2.default.decl({ prop: (0, _utils2.default)(prop), value })); | ||
}); | ||
if (typeof set === 'string') { | ||
newRule.prepend(set); | ||
} else if ((0, _utils.isPlainObject)(set)) { | ||
(0, _entries2.default)(set).forEach(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 2), | ||
prop = _ref2[0], | ||
value = _ref2[1]; | ||
newRule.prepend(_postcss2.default.decl({ prop: (0, _utils.kebabify)(prop), value })); | ||
}); | ||
} else { | ||
throw new Error(`Unrecognized set type \`${typeof set}\`, must be an object or string.`); | ||
} | ||
_this.cache[setName] = newRule; | ||
@@ -67,0 +74,0 @@ }); |
{ | ||
"name": "postcss-apply", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "PostCSS plugin enabling custom properties sets references", | ||
@@ -75,4 +75,4 @@ "keywords": [ | ||
"postcss-custom-properties": "^6.0.0", | ||
"postcss-reporter": "^3.0.0" | ||
"postcss-reporter": "^4.0.0" | ||
} | ||
} |
# postcss-apply | ||
[![CSS Standard Status][css-image]][css-url] | ||
[![npm version][npm-image]][npm-url] | ||
@@ -24,4 +25,4 @@ [![Build Status][travis-image]][travis-url] | ||
* https://github.com/w3c/csswg-drafts/issues/1047 | ||
## Installation | ||
@@ -125,6 +126,6 @@ | ||
### `sets` | ||
type: `Object` | ||
type: `{ [customPropertyName: string]: Object | string }` | ||
default: `{}` | ||
Allows you to pass an object of custom property sets for `:root`. | ||
These definitions will be prepended, in such overriden by the one declared in CSS if they share the same name. | ||
Allows you to pass an object or string of custom property sets for `:root`. | ||
These definitions will be prepended, in such overridden by the one declared in CSS if they share the same name. | ||
The keys are automatically prefixed with the CSS `--` to make it easier to share sets in your codebase. | ||
@@ -146,2 +147,4 @@ | ||
[css-url]: https://jonathantneal.github.io/css-db/#css-apply-rule | ||
[css-image]: https://jonathantneal.github.io/css-db/badge/css-apply-rule.svg | ||
[npm-url]: https://www.npmjs.org/package/postcss-apply | ||
@@ -148,0 +151,0 @@ [npm-image]: http://img.shields.io/npm/v/postcss-apply.svg?style=flat-square |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17335
201
158