Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,24 @@ | |||
|
|||
button { | |||
border-radius: 5px | |||
} | |||
|
|||
button { | |||
border-radius: top 5px | |||
} | |||
|
|||
button { | |||
border-radius: 5px 10px | |||
} | |||
|
|||
button { | |||
border-radius: top 5px bottom 10px | |||
} | |||
|
|||
button { | |||
border-radius: left 5px | |||
} | |||
|
|||
button { | |||
border-radius: left 5px right 2px | |||
} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,51 @@ | |||
|
|||
var rework = require('..') | |||
, read = require('fs').readFileSync; | |||
|
|||
var css = rework(read('examples/border-radius.css', 'utf8')) | |||
.use(rework.mixin({ 'border-radius': borderRadius })) | |||
.toString() | |||
|
|||
function borderRadius(str) { | |||
var vals = str.split(/\s+/); | |||
var pos; | |||
var ret; | |||
|
|||
for (var i = 0; i < vals.length; ++i) { | |||
var val = vals[i]; | |||
if (isPosition(val)) { | |||
ret = ret || {}; | |||
pos = val; | |||
val = vals[++i]; | |||
switch (pos) { | |||
case 'top': | |||
case 'bottom': | |||
ret['border-' + pos + '-left-radius'] = val; | |||
ret['border-' + pos + '-right-radius'] = val; | |||
break; | |||
case 'left': | |||
case 'right': | |||
ret['border-top-' + pos + '-radius'] = val; | |||
ret['border-bottom-' + pos + '-radius'] = val; | |||
break; | |||
} | |||
} | |||
} | |||
|
|||
if (!ret) { | |||
return { | |||
'border-radius': str | |||
} | |||
} | |||
|
|||
return ret; | |||
} | |||
|
|||
function isPosition(str) { | |||
return 'top' == str | |||
|| 'bottom' == str | |||
|| 'left' == str | |||
|| 'right' == str; | |||
} | |||
|
|||
console.log(css); |