-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from kristerkari/feature/lowercase
Format properties and values to lowercase
- Loading branch information
Showing
11 changed files
with
156 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
var cssColors = require('css-color-list') | ||
var namedColorsRegex = new RegExp(cssColors().join('|'), 'ig') | ||
var hslRegex = /hsla?\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*(,\s*[\d\.]+)?\s*\)/ig | ||
var hexRegex = /#[a-f0-9]{3}([a-f0-9]{3})?/ig | ||
var rgbRegex = /rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*(,\s*[\d\.]+)?\s*\)/ig | ||
|
||
function toLowerCase(value) { | ||
return value.toLowerCase() | ||
} | ||
|
||
function colorsToLowerCase(value) { | ||
return value.replace(namedColorsRegex, toLowerCase) | ||
.replace(hslRegex, toLowerCase) | ||
.replace(hexRegex, toLowerCase) | ||
.replace(rgbRegex, toLowerCase) | ||
} | ||
|
||
function formatColors(value) { | ||
return colorsToLowerCase(value) | ||
} | ||
|
||
module.exports = formatColors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
var transformTypes = [ | ||
'translate', | ||
'matrix', | ||
'rotate', | ||
'scale', | ||
'skew' | ||
] | ||
var transformRegex = new RegExp('(' + transformTypes.join('|') + ')[xyz]?(3d)?\\(', 'ig') | ||
var matrixRegex = /matrix\(/ig | ||
var xyzRegex = /[xyz]{1}(?=\()/g | ||
|
||
function transformsToLowerCase(value) { | ||
return value.replace(transformRegex, function(value) { | ||
if (matrixRegex.test(value)) { | ||
return value.toLowerCase() | ||
} | ||
return value.toLowerCase().replace(xyzRegex, function(value) { | ||
return value.toUpperCase() | ||
}) | ||
}) | ||
} | ||
|
||
function formatTransforms(value) { | ||
return transformsToLowerCase(value) | ||
} | ||
|
||
module.exports = formatTransforms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
@charset "UTF-8"; | ||
|
||
$myVar: TRANSLATEX(0); | ||
$myVar2: RGB(255,255,255); | ||
$myVar3: MAROON; | ||
$myVar4: HSLA(120,100%,50%,0.3); | ||
$myVar5: RGBA(0,0,0,0.5); | ||
$myVar6: HSL(120,100%,50%); | ||
$myVar7: linear-gradient(to right, RGBA(0,0,0,0.5), RGB(255,255,255)); | ||
|
||
.class-1 { | ||
BACKGROUND: HSL(120, 100%, 50%); | ||
BACKGROUND: linear-gradient(to right, $myVar2, RGB(255,255,255)); | ||
COLOR: RGB(0, 0, 0); | ||
TRANSFORM: TRANSLATE(0,0) TRANSLATEX(0) TRANSLATEY(0) TRANSLATEZ(0) TRANSLATE3D(0,0,0) MATRIX(1,1,1,1); | ||
TRANSFORM: TRANSLATE(0,0); | ||
TRANSFORM: TRANSLATEX(0); | ||
TRANSFORM: TRANSLATEY(0); | ||
TRANSFORM: TRANSLATE3D(0,0,0); | ||
TRANSFORM: MATRIX(1,1,1,1); | ||
transform: translateY(0) $myVar; | ||
} | ||
|
||
.class-2 { | ||
BACKGROUND-COLOR: INDIGO; | ||
BACKGROUND: HSLA(120, 100%, 50%, 0.3); | ||
COLOR: RGBA(0, 0, 0, 0.5); | ||
TRANSFORM: ROTATE(1deg) ROTATEX(1deg) ROTATEY(1deg) ROTATEZ(1deg) ROTATE3D(0,0,1,1deg) SKEW(1deg) SKEWX(1deg) SKEWY(1deg) SCALE(1, 1) SCALEX(1) SCALEY(1); | ||
TRANSFORM: ROTATE(1deg); | ||
TRANSFORM: ROTATEX(1deg); | ||
TRANSFORM: ROTATEY(1deg); | ||
TRANSFORM: ROTATEZ(1deg); | ||
TRANSFORM: ROTATE3D(0,0,1,1deg); | ||
TRANSFORM: SKEW(1deg); | ||
TRANSFORM: SKEWX(1deg); | ||
TRANSFORM: SKEWY(1deg); | ||
TRANSFORM: SCALE(1, 1); | ||
TRANSFORM: SCALEX(1); | ||
TRANSFORM: SCALEY(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
@charset "utf-8"; | ||
$myVar: translateX(0); | ||
$myVar2: rgb(255, 255, 255); | ||
$myVar3: maroon; | ||
$myVar4: hsla(120, 100%, 50%, 0.3); | ||
$myVar5: rgba(0, 0, 0, 0.5); | ||
$myVar6: hsl(120, 100%, 50%); | ||
$myVar7: linear-gradient(to right, rgba(0, 0, 0, 0.5), rgb(255, 255, 255)); | ||
|
||
.class-1 { | ||
background: hsl(120, 100%, 50%); | ||
background: linear-gradient(to right, $myVar2, rgb(255, 255, 255)); | ||
color: rgb(0, 0, 0); | ||
transform: translate(0, 0) translateX(0) translateY(0) translateZ(0) translate3d(0, 0, 0) matrix(1, 1, 1, 1); | ||
transform: translate(0, 0); | ||
transform: translateX(0); | ||
transform: translateY(0); | ||
transform: translate3d(0, 0, 0); | ||
transform: matrix(1, 1, 1, 1); | ||
transform: translateY(0) $myVar; | ||
} | ||
|
||
.class-2 { | ||
background-color: indigo; | ||
background: hsla(120, 100%, 50%, 0.3); | ||
color: rgba(0, 0, 0, 0.5); | ||
transform: rotate(1deg) rotateX(1deg) rotateY(1deg) rotateZ(1deg) rotate3d(0, 0, 1, 1deg) skew(1deg) skewX(1deg) skewY(1deg) scale(1, 1) scaleX(1) scaleY(1); | ||
transform: rotate(1deg); | ||
transform: rotateX(1deg); | ||
transform: rotateY(1deg); | ||
transform: rotateZ(1deg); | ||
transform: rotate3d(0, 0, 1, 1deg); | ||
transform: skew(1deg); | ||
transform: skewX(1deg); | ||
transform: skewY(1deg); | ||
transform: scale(1, 1); | ||
transform: scaleX(1); | ||
transform: scaleY(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters