Skip to content
Merged
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
1 change: 1 addition & 0 deletions .csscomb.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"node_modules/**"
],
"colon-space": true,
"color-case": "lower",
"leading-zero": false,
"rule-indent": true,
"block-indent": true,
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Example configuration:
{
"exclude": ["node_modules/**"],
"colon-space": true,
"color-case": "lower",
"leading-zero": false,
"rule-indent": true,
"block-indent": true,
Expand Down
1 change: 1 addition & 0 deletions lib/csscomb.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var Comb = function() {
this._handlers;
this._options = [
'always-semicolon',
'color-case',
'leading-zero',
'strip-spaces',
'stick-brace',
Expand Down
31 changes: 31 additions & 0 deletions lib/options/color-case.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {

/**
* Sets handler value.
*
* @param {String} value Option value
* @returns {Object}
*/
setValue: function(value) {
if (value === 'lower' || value === 'upper') {
this._value = value;
return this;
}
},

/**
* Processes tree node.
* @param {String} nodeType
* @param {node} node
*/
process: function(nodeType, node) {
if (nodeType === 'vhash') {
if (this._value === 'lower') {
node[0] = node[0].toLowerCase();
} else if (this._value === 'upper') {
node[0] = node[0].toUpperCase();
}
}
}

};
53 changes: 53 additions & 0 deletions test/color-case.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
var Comb = require('../lib/csscomb');
var assert = require('assert');

describe('options/color-case', function() {
var comb;

beforeEach(function() {
comb = new Comb();
});

it('Should switch colors to upper case', function() {
comb.configure({ 'color-case': 'upper' });
assert.equal(
comb.processString(
'div { color: #fff }'
),
'div { color: #FFF }'
);
});

it('Should switch colors to lower case', function() {
comb.configure({ 'color-case': 'lower' });
assert.equal(
comb.processString(
'div { color: #FFF }'
),
'div { color: #fff }'
);
});

it('Should switch color-case in complex rules', function() {
comb.configure({ 'color-case': 'lower' });
assert.equal(
comb.processString(
'div { background: url(img.png#RND) #E3E3E3 0 100% no-repeat;' +
' box-shadow: 1px 2px 3px 4px #F0F0F0 inset; }'
),
'div { background: url(img.png#RND) #e3e3e3 0 100% no-repeat;' +
' box-shadow: 1px 2px 3px 4px #f0f0f0 inset; }'
);
});

it('Should not switch selector case', function() {
comb.configure({ 'color-case': 'lower' });
assert.equal(
comb.processString(
'#Header { color: #FFF }'
),
'#Header { color: #fff }'
);
});

});
8 changes: 4 additions & 4 deletions test/integral.origin.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
/* :after — фон */
.radio-button_theme_normal .radio-button__radio:after
{
background: #fff;
background: -webkit-linear-gradient(top, #fff 0,#eee 100%);
background: -moz-linear-gradient(top, #fff 0, #eee 100%);
background: #fFf;
background: -webkit-linear-gradient(top, #Fff 0,#eeE 100%);
background: -moz-linear-gradient(top, #fff 0, #eEe 100%);
background: -o-linear-gradient(top, #fff 0,#eee 100%);
background: linear-gradient(to bottom, #fff 0,#eee 100%);
background: linear-gradient(to bottom, #fff 0,#eEe 100%);
}

/* _focused_yes */
Expand Down