Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix 4 values padding/margin #11

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/engine.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var css = require('css');
var shorthands = require('./properties');

module.exports = function(cssString) {
module.exports = function(cssString, options) {
var cssObject = css.parse(cssString);
var longPropertiesPositions = [];

Expand All @@ -19,6 +19,10 @@ module.exports = function(cssString) {
shorthands.forEach(function(shorthand) {
var shorthandValue = shorthand.getShorthandValue(shorthand, declarations); // Defined in properties.js

if(options.ignore.some(prop => prop === shorthand.shorthandProperty)) {
return;
}

if (shorthandValue !== "") { // If there are no the specific properties of the shorthand, "getShorthandValue" returns an empty string
var newDeclarations = [];

Expand Down
2 changes: 1 addition & 1 deletion lib/shorthanders/margin-padding.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function(shorthand, declarations) {
}
else { // If all 4 margins are different
// 4-value notation
return basicShorthandReplace(shorthand, declarations);
return declarations[propertyName + '-top'].value + ' ' + declarations[propertyName + '-right'].value + ' ' + declarations[propertyName + '-bottom'].value + ' ' + declarations[propertyName + '-left'].value;
}
}
else { // Not all margin sides are defined
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shrthnd",
"version": "0.0.6",
"name": "shrt-css",
"version": "0.1.1",
"description": "Makes your CSS files lighter and more readable by converting and combining CSS properties into their shorthand versions when possible.",
"main": "index.js",
"files": [
Expand Down