This repository has been archived by the owner on Feb 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
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 #9 from jonathantneal/feature/postcss6-and-updates
Use PostCSS 6 and improve accuracy of the plugin
- Loading branch information
Showing
7 changed files
with
36 additions
and
24 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 |
---|---|---|
@@ -1 +1,3 @@ | ||
language: node_js | ||
node_js: | ||
- 4 |
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 |
---|---|---|
@@ -1,20 +1,23 @@ | ||
/** | ||
* Module dependencies. | ||
*/ | ||
var postcss = require("postcss") | ||
var color = require("color")("rebeccapurple").rgbString() | ||
const postcss = require("postcss") | ||
const valueParser = require("postcss-value-parser") | ||
const color = "#639" | ||
|
||
/** | ||
* PostCSS plugin to convert colors | ||
*/ | ||
module.exports = postcss.plugin("postcss-color-rebeccapurple", function() { | ||
return function(style) { | ||
style.walkDecls(function(decl) { | ||
var value = decl.value; | ||
module.exports = postcss.plugin("postcss-color-rebeccapurple", () => (style) => { | ||
style.walkDecls((decl) => { | ||
const value = decl.value; | ||
|
||
if (value && value.indexOf("rebeccapurple") !== -1) { | ||
decl.value = value.replace(/(rebeccapurple)\b/gi, color) | ||
} | ||
}) | ||
} | ||
if (value && value.indexOf("rebeccapurple") !== -1) { | ||
decl.value = valueParser(value).walk((node) => { | ||
if (node.type === "word" && node.value === "rebeccapurple") { | ||
node.value = color | ||
} | ||
}).toString() | ||
} | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
body { | ||
color: rgb(102, 51, 153); | ||
background: linear-gradient(rgb(102, 51, 153), blue 50%, rgb(102, 51, 153)); | ||
color: #639; | ||
background: linear-gradient(#639, blue 50%, #639); | ||
} | ||
|
||
a { | ||
color: oldrebeccapurple; | ||
} |