Skip to content

Commit 8547aa4

Browse files
Merge pull request #5 from wimhendrikx/master
Upgrade packages, make it work for latest postcss and add longer shorthand
2 parents 679b803 + 391a7f3 commit 8547aa4

File tree

6 files changed

+57
-14
lines changed

6 files changed

+57
-14
lines changed

Diff for: .travis.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
sudo: false
22
language: node_js
33
node_js:
4-
- stable
5-
- "6"
6-
- "4"
4+
- 6
5+
- 7
6+
- 8
7+
- 9
8+
- 10
9+
- 11
10+
- 12
11+
- node

Diff for: README.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@
88

99
## Examples
1010

11+
### Shorthand `vertical` and `horizontal` declarations
12+
13+
```css
14+
.foo {
15+
padding-vertical: 2rem;
16+
margin-horizontal: auto;
17+
}
18+
```
19+
20+
```css
21+
.foo {
22+
padding-top: 2rem;
23+
padding-bottom: 2rem;
24+
margin-left: auto;
25+
margin-right: auto;
26+
}
27+
```
28+
1129
### Shorthand `vert` and `horz` declarations
1230

1331
```css
@@ -68,4 +86,4 @@
6886
postcss([ require('postcss-verthorz') ])
6987
```
7088

71-
See [PostCSS] docs for examples for your environment.
89+
See [PostCSS] docs for examples for your environment.

Diff for: gulpfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ gulp.task('test', function () {
1313
return gulp.src('test/*.js', { read: false }).pipe(mocha());
1414
});
1515

16-
gulp.task('default', ['lint', 'test']);
16+
gulp.task('default', gulp.series('lint', 'test'));

Diff for: index.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,23 @@ module.exports = postcss.plugin('postcss-verthorz', function () {
1010
};
1111

1212
var PROPS = {
13+
'padding-vertical': VALUES.pv,
14+
'padding-horizontal': VALUES.ph,
1315
'padding-vert': VALUES.pv,
1416
'padding-horz': VALUES.ph,
1517
'pv': VALUES.pv,
1618
'ph': VALUES.ph,
19+
'margin-vertical': VALUES.mv,
20+
'margin-horizontal': VALUES.mh,
1721
'margin-vert': VALUES.mv,
1822
'margin-horz': VALUES.mh,
1923
'mv': VALUES.mv,
2024
'mh': VALUES.mh
2125
};
2226

23-
return function (css) {
24-
css.each(function (rule) {
25-
rule.each(function(decl) {
27+
return function (root) {
28+
root.walkRules(function (rule) {
29+
rule.walkDecls(function(decl) {
2630

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

Diff for: package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postcss-verthorz",
3-
"version": "0.7.0",
3+
"version": "1.0.0",
44
"description": "PostCSS plugin to add vertical and horizontal spacing shorthand",
55
"keywords": [
66
"postcss",
@@ -17,13 +17,13 @@
1717
"url": "https://github.com/davidhemphill/postcss-verthorz.git"
1818
},
1919
"dependencies": {
20-
"postcss": "^6.0.13"
20+
"postcss": "^7.0.14"
2121
},
2222
"devDependencies": {
23-
"gulp-eslint": "^4.0.0",
24-
"gulp-mocha": "^4.3.1",
25-
"chai": "^4.1.2",
26-
"gulp": "^3.8.11"
23+
"chai": "^4.2.0",
24+
"gulp": "^4.0.1",
25+
"gulp-eslint": "^5.0.0",
26+
"gulp-mocha": "^6.0.0"
2727
},
2828
"scripts": {
2929
"test": "gulp"

Diff for: test/test.js

+16
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ var test = function (input, output, opts, done) {
1515

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

18+
it('handles padding-vertical', function (done) {
19+
test('a { padding-vertical: 20px; }', 'a { padding-top: 20px; padding-bottom: 20px; }', { }, done);
20+
});
21+
22+
it('handles padding-horizontal', function (done) {
23+
test('a { padding-horizontal: 1.5em; }', 'a { padding-left: 1.5em; padding-right: 1.5em; }', { }, done);
24+
});
25+
1826
it('handles padding-vert', function (done) {
1927
test('a { padding-vert: 20px; }', 'a { padding-top: 20px; padding-bottom: 20px; }', { }, done);
2028
});
@@ -39,6 +47,14 @@ describe('postcss-verthorz', function () {
3947
test('a { margin-horz: 2rem; }', 'a { margin-left: 2rem; margin-right: 2rem; }', { }, done);
4048
});
4149

50+
it('handles margin-vertical', function (done) {
51+
test('a { margin-vertical: 2rem; }', 'a { margin-top: 2rem; margin-bottom: 2rem; }', { }, done);
52+
});
53+
54+
it('handles margin-horizontal', function (done) {
55+
test('a { margin-horizontal: 2rem; }', 'a { margin-left: 2rem; margin-right: 2rem; }', { }, done);
56+
});
57+
4258
it('handles mv', function (done) {
4359
test('a { mv: 2rem; }', 'a { margin-top: 2rem; margin-bottom: 2rem; }', { }, done);
4460
});

0 commit comments

Comments
 (0)