Skip to content

Commit 8640239

Browse files
committed
Merge pull request #44 from ignovak/color-case
option: color-case
2 parents cdb7c72 + 9f09b7b commit 8640239

File tree

6 files changed

+91
-4
lines changed

6 files changed

+91
-4
lines changed

.csscomb.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"node_modules/**"
55
],
66
"colon-space": true,
7+
"color-case": "lower",
78
"leading-zero": false,
89
"rule-indent": true,
910
"block-indent": true,

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Example configuration:
3535
{
3636
"exclude": ["node_modules/**"],
3737
"colon-space": true,
38+
"color-case": "lower",
3839
"leading-zero": false,
3940
"rule-indent": true,
4041
"block-indent": true,

lib/csscomb.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var Comb = function() {
1212
this._handlers;
1313
this._options = [
1414
'always-semicolon',
15+
'color-case',
1516
'leading-zero',
1617
'strip-spaces',
1718
'stick-brace',

lib/options/color-case.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module.exports = {
2+
3+
/**
4+
* Sets handler value.
5+
*
6+
* @param {String} value Option value
7+
* @returns {Object}
8+
*/
9+
setValue: function(value) {
10+
if (value === 'lower' || value === 'upper') {
11+
this._value = value;
12+
return this;
13+
}
14+
},
15+
16+
/**
17+
* Processes tree node.
18+
* @param {String} nodeType
19+
* @param {node} node
20+
*/
21+
process: function(nodeType, node) {
22+
if (nodeType === 'vhash') {
23+
if (this._value === 'lower') {
24+
node[0] = node[0].toLowerCase();
25+
} else if (this._value === 'upper') {
26+
node[0] = node[0].toUpperCase();
27+
}
28+
}
29+
}
30+
31+
};

test/color-case.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
var Comb = require('../lib/csscomb');
2+
var assert = require('assert');
3+
4+
describe('options/color-case', function() {
5+
var comb;
6+
7+
beforeEach(function() {
8+
comb = new Comb();
9+
});
10+
11+
it('Should switch colors to upper case', function() {
12+
comb.configure({ 'color-case': 'upper' });
13+
assert.equal(
14+
comb.processString(
15+
'div { color: #fff }'
16+
),
17+
'div { color: #FFF }'
18+
);
19+
});
20+
21+
it('Should switch colors to lower case', function() {
22+
comb.configure({ 'color-case': 'lower' });
23+
assert.equal(
24+
comb.processString(
25+
'div { color: #FFF }'
26+
),
27+
'div { color: #fff }'
28+
);
29+
});
30+
31+
it('Should switch color-case in complex rules', function() {
32+
comb.configure({ 'color-case': 'lower' });
33+
assert.equal(
34+
comb.processString(
35+
'div { background: url(img.png#RND) #E3E3E3 0 100% no-repeat;' +
36+
' box-shadow: 1px 2px 3px 4px #F0F0F0 inset; }'
37+
),
38+
'div { background: url(img.png#RND) #e3e3e3 0 100% no-repeat;' +
39+
' box-shadow: 1px 2px 3px 4px #f0f0f0 inset; }'
40+
);
41+
});
42+
43+
it('Should not switch selector case', function() {
44+
comb.configure({ 'color-case': 'lower' });
45+
assert.equal(
46+
comb.processString(
47+
'#Header { color: #FFF }'
48+
),
49+
'#Header { color: #fff }'
50+
);
51+
});
52+
53+
});

test/integral.origin.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
/* :after — фон */
1717
.radio-button_theme_normal .radio-button__radio:after
1818
{
19-
background: #fff;
20-
background: -webkit-linear-gradient(top, #fff 0,#eee 100%);
21-
background: -moz-linear-gradient(top, #fff 0, #eee 100%);
19+
background: #fFf;
20+
background: -webkit-linear-gradient(top, #Fff 0,#eeE 100%);
21+
background: -moz-linear-gradient(top, #fff 0, #eEe 100%);
2222
background: -o-linear-gradient(top, #fff 0,#eee 100%);
23-
background: linear-gradient(to bottom, #fff 0,#eee 100%);
23+
background: linear-gradient(to bottom, #fff 0,#eEe 100%);
2424
}
2525

2626
/* _focused_yes */

0 commit comments

Comments
 (0)