Skip to content

Commit

Permalink
Merge pull request #5 from wimhendrikx/master
Browse files Browse the repository at this point in the history
Upgrade packages, make it work for latest postcss and add longer shorthand
  • Loading branch information
davidhemphill authored Apr 26, 2019
2 parents 679b803 + 391a7f3 commit 8547aa4
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 14 deletions.
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
sudo: false
language: node_js
node_js:
- stable
- "6"
- "4"
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- node
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@

## Examples

### Shorthand `vertical` and `horizontal` declarations

```css
.foo {
padding-vertical: 2rem;
margin-horizontal: auto;
}
```

```css
.foo {
padding-top: 2rem;
padding-bottom: 2rem;
margin-left: auto;
margin-right: auto;
}
```

### Shorthand `vert` and `horz` declarations

```css
Expand Down Expand Up @@ -68,4 +86,4 @@
postcss([ require('postcss-verthorz') ])
```

See [PostCSS] docs for examples for your environment.
See [PostCSS] docs for examples for your environment.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ gulp.task('test', function () {
return gulp.src('test/*.js', { read: false }).pipe(mocha());
});

gulp.task('default', ['lint', 'test']);
gulp.task('default', gulp.series('lint', 'test'));
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ module.exports = postcss.plugin('postcss-verthorz', function () {
};

var PROPS = {
'padding-vertical': VALUES.pv,
'padding-horizontal': VALUES.ph,
'padding-vert': VALUES.pv,
'padding-horz': VALUES.ph,
'pv': VALUES.pv,
'ph': VALUES.ph,
'margin-vertical': VALUES.mv,
'margin-horizontal': VALUES.mh,
'margin-vert': VALUES.mv,
'margin-horz': VALUES.mh,
'mv': VALUES.mv,
'mh': VALUES.mh
};

return function (css) {
css.each(function (rule) {
rule.each(function(decl) {
return function (root) {
root.walkRules(function (rule) {
rule.walkDecls(function(decl) {

var declArray = decl.value.split(' ');

Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-verthorz",
"version": "0.7.0",
"version": "1.0.0",
"description": "PostCSS plugin to add vertical and horizontal spacing shorthand",
"keywords": [
"postcss",
Expand All @@ -17,13 +17,13 @@
"url": "https://github.com/davidhemphill/postcss-verthorz.git"
},
"dependencies": {
"postcss": "^6.0.13"
"postcss": "^7.0.14"
},
"devDependencies": {
"gulp-eslint": "^4.0.0",
"gulp-mocha": "^4.3.1",
"chai": "^4.1.2",
"gulp": "^3.8.11"
"chai": "^4.2.0",
"gulp": "^4.0.1",
"gulp-eslint": "^5.0.0",
"gulp-mocha": "^6.0.0"
},
"scripts": {
"test": "gulp"
Expand Down
16 changes: 16 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ var test = function (input, output, opts, done) {

describe('postcss-verthorz', function () {

it('handles padding-vertical', function (done) {
test('a { padding-vertical: 20px; }', 'a { padding-top: 20px; padding-bottom: 20px; }', { }, done);
});

it('handles padding-horizontal', function (done) {
test('a { padding-horizontal: 1.5em; }', 'a { padding-left: 1.5em; padding-right: 1.5em; }', { }, done);
});

it('handles padding-vert', function (done) {
test('a { padding-vert: 20px; }', 'a { padding-top: 20px; padding-bottom: 20px; }', { }, done);
});
Expand All @@ -39,6 +47,14 @@ describe('postcss-verthorz', function () {
test('a { margin-horz: 2rem; }', 'a { margin-left: 2rem; margin-right: 2rem; }', { }, done);
});

it('handles margin-vertical', function (done) {
test('a { margin-vertical: 2rem; }', 'a { margin-top: 2rem; margin-bottom: 2rem; }', { }, done);
});

it('handles margin-horizontal', function (done) {
test('a { margin-horizontal: 2rem; }', 'a { margin-left: 2rem; margin-right: 2rem; }', { }, done);
});

it('handles mv', function (done) {
test('a { mv: 2rem; }', 'a { margin-top: 2rem; margin-bottom: 2rem; }', { }, done);
});
Expand Down

0 comments on commit 8547aa4

Please sign in to comment.