postcss-flex-alias
Advanced tools
Comparing version 1.0.0 to 1.0.1
27
index.js
@@ -1,14 +0,15 @@ | ||
const postcss = require('postcss'); | ||
const flex = require('./lib/flex'); | ||
const postcss = require('postcss') | ||
module.exports = postcss.plugin('postcss-propro', opts => { | ||
return (root, result) => { | ||
root.walkRules(rule => { | ||
rule.walkDecls(decl => { | ||
decl.prop === 'display' && | ||
decl.value.startsWith('flex-') && | ||
flex(decl, opts, result); | ||
}); | ||
}); | ||
}; | ||
}); | ||
const flex = require('./lib/flex') | ||
module.exports = postcss.plugin('postcss-flex-alias', (opts = { }) => { | ||
return (root, result) => { | ||
root.walkRules(rule => { | ||
rule.walkDecls(decl => { | ||
decl.prop === 'display' && | ||
decl.value.startsWith('flex-') && | ||
flex(decl, opts, result) | ||
}) | ||
}) | ||
} | ||
}) |
246
lib/flex.js
@@ -1,151 +0,151 @@ | ||
function checkValue0(decl, value) { | ||
switch (value) { | ||
function checkValue0 (decl, value) { | ||
switch (value) { | ||
case 'y': | ||
decl.cloneBefore({ | ||
prop: 'flex-direction', | ||
value: 'column' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'flex-direction', | ||
value: 'column' | ||
}) | ||
break | ||
case 'w': | ||
decl.cloneBefore({ | ||
prop: 'flex-wrap', | ||
value: 'wrap' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'flex-wrap', | ||
value: 'wrap' | ||
}) | ||
break | ||
case 'm': | ||
decl.cloneBefore({ | ||
prop: 'flex-direction', | ||
value: 'column' | ||
}); | ||
decl.cloneBefore({ | ||
prop: 'flex-wrap', | ||
value: 'wrap' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'flex-direction', | ||
value: 'column' | ||
}) | ||
decl.cloneBefore({ | ||
prop: 'flex-wrap', | ||
value: 'wrap' | ||
}) | ||
break | ||
default: | ||
break; | ||
} | ||
break | ||
} | ||
} | ||
function checkValue1(decl, value) { | ||
switch (value) { | ||
function checkValue1 (decl, value) { | ||
switch (value) { | ||
case 's': | ||
decl.cloneBefore({ | ||
prop: 'justify-content', | ||
value: 'flex-start' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'justify-content', | ||
value: 'flex-start' | ||
}) | ||
break | ||
case 'a': | ||
decl.cloneBefore({ | ||
prop: 'justify-content', | ||
value: 'space-around' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'justify-content', | ||
value: 'space-around' | ||
}) | ||
break | ||
case 'b': | ||
decl.cloneBefore({ | ||
prop: 'justify-content', | ||
value: 'space-between' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'justify-content', | ||
value: 'space-between' | ||
}) | ||
break | ||
case 'c': | ||
decl.cloneBefore({ | ||
prop: 'justify-content', | ||
value: 'center' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'justify-content', | ||
value: 'center' | ||
}) | ||
break | ||
case 'e': | ||
decl.cloneBefore({ | ||
prop: 'justify-content', | ||
value: 'flex-end' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'justify-content', | ||
value: 'flex-end' | ||
}) | ||
break | ||
default: | ||
break; | ||
} | ||
break | ||
} | ||
} | ||
function checkValue2(decl, value) { | ||
switch (value) { | ||
function checkValue2 (decl, value) { | ||
switch (value) { | ||
case 's': | ||
decl.cloneBefore({ | ||
prop: 'align-items', | ||
value: 'flex-start' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'align-items', | ||
value: 'flex-start' | ||
}) | ||
break | ||
case 'b': | ||
decl.cloneBefore({ | ||
prop: 'align-items', | ||
value: 'baseline' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'align-items', | ||
value: 'baseline' | ||
}) | ||
break | ||
case 'c': | ||
decl.cloneBefore({ | ||
prop: 'align-items', | ||
value: 'center' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'align-items', | ||
value: 'center' | ||
}) | ||
break | ||
case 'e': | ||
decl.cloneBefore({ | ||
prop: 'align-items', | ||
value: 'flex-end' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'align-items', | ||
value: 'flex-end' | ||
}) | ||
break | ||
case 'h': | ||
decl.cloneBefore({ | ||
prop: 'align-items', | ||
value: 'stretch' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'align-items', | ||
value: 'stretch' | ||
}) | ||
break | ||
default: | ||
break; | ||
} | ||
break | ||
} | ||
} | ||
function checkValue3(decl, value) { | ||
switch (value) { | ||
function checkValue3 (decl, value) { | ||
switch (value) { | ||
case 's': | ||
decl.cloneBefore({ | ||
prop: 'align-content', | ||
value: 'flex-start' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'align-content', | ||
value: 'flex-start' | ||
}) | ||
break | ||
case 'a': | ||
decl.cloneBefore({ | ||
prop: 'align-content', | ||
value: 'space-around' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'align-content', | ||
value: 'space-around' | ||
}) | ||
break | ||
case 'b': | ||
decl.cloneBefore({ | ||
prop: 'align-content', | ||
value: 'space-between' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'align-content', | ||
value: 'space-between' | ||
}) | ||
break | ||
case 'c': | ||
decl.cloneBefore({ | ||
prop: 'align-content', | ||
value: 'center' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'align-content', | ||
value: 'center' | ||
}) | ||
break | ||
case 'e': | ||
decl.cloneBefore({ | ||
prop: 'align-content', | ||
value: 'flex-end' | ||
}); | ||
break; | ||
decl.cloneBefore({ | ||
prop: 'align-content', | ||
value: 'flex-end' | ||
}) | ||
break | ||
default: | ||
break; | ||
} | ||
break | ||
} | ||
} | ||
module.exports = function (decl) { | ||
const values = decl.value.split('-')[1].split(''); | ||
decl.cloneBefore({ | ||
prop: 'display', | ||
value: 'flex' | ||
}); | ||
checkValue0(decl, values[0]); | ||
checkValue1(decl, values[1]); | ||
checkValue2(decl, values[2]); | ||
if (values[0] === 'w' || values[0] === 'm') { | ||
checkValue3(decl, values[3]); | ||
} | ||
decl.remove(); | ||
}; | ||
let values = decl.value.split('-')[1].split('') | ||
decl.cloneBefore({ | ||
prop: 'display', | ||
value: 'flex' | ||
}) | ||
checkValue0(decl, values[0]) | ||
checkValue1(decl, values[1]) | ||
checkValue2(decl, values[2]) | ||
if (values[0] === 'w' || values[0] === 'm') { | ||
checkValue3(decl, values[3]) | ||
} | ||
decl.remove() | ||
} |
{ | ||
"name": "postcss-flex-alias", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "easily write flex", | ||
@@ -21,18 +21,29 @@ "keywords": [ | ||
"dependencies": { | ||
"postcss": "^6.0.16" | ||
"postcss": "^7.0.18" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^4.18.2", | ||
"eslint-config-postcss": "^2.0.2", | ||
"jest": "^22.4.2" | ||
"@logux/eslint-config": "^33.0.0", | ||
"eslint": "^6.5.1", | ||
"eslint-config-postcss": "^3.0.7", | ||
"eslint-config-standard": "^14.1.0", | ||
"eslint-plugin-es5": "^1.4.1", | ||
"eslint-plugin-import": "^2.18.2", | ||
"eslint-plugin-jest": "^22.19.0", | ||
"eslint-plugin-node": "^10.0.0", | ||
"eslint-plugin-prefer-let": "^1.0.1", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-security": "^1.4.0", | ||
"eslint-plugin-standard": "^4.0.1", | ||
"eslint-plugin-unicorn": "^12.1.0", | ||
"jest": "^24.9.0" | ||
}, | ||
"scripts": { | ||
"test": "jest && eslint *.js" | ||
"test": "jest && eslint ." | ||
}, | ||
"eslintConfig": { | ||
"extends": "eslint-config-postcss/es5", | ||
"env": { | ||
"jest": true | ||
} | ||
"extends": "eslint-config-postcss" | ||
}, | ||
"engines": { | ||
"node": ">=8.0.0" | ||
}, | ||
"jest": { | ||
@@ -39,0 +50,0 @@ "testEnvironment": "node" |
@@ -51,3 +51,3 @@ # PostCSS flex-alias [![Build Status][ci-img]][ci] | ||
``` css | ||
// input | ||
/* input */ | ||
.foo { | ||
@@ -58,3 +58,3 @@ display: flex-xcc; | ||
``` css | ||
// output | ||
/* output */ | ||
.foo { | ||
@@ -68,4 +68,4 @@ display: flex; | ||
``` js | ||
// input | ||
``` css | ||
/* input */ | ||
.foo { | ||
@@ -76,3 +76,3 @@ display: flex-wbc; | ||
``` css | ||
// output | ||
/* output */ | ||
.foo { | ||
@@ -79,0 +79,0 @@ display: flex; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
7097
14
5
163
1
+ Addedpicocolors@0.2.1(transitive)
+ Addedpostcss@7.0.39(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedpostcss@6.0.23(transitive)
- Removedsupports-color@5.5.0(transitive)
Updatedpostcss@^7.0.18