Skip to content

Commit 768ba1d

Browse files
committed
new name for example of recolour
1 parent 625fe0a commit 768ba1d

File tree

9 files changed

+145
-0
lines changed

9 files changed

+145
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.postCssLogo path {
2+
fill: purple;
3+
}

examples/recolor/package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"description": "Switch color themes via postcss-import-sub",
3+
"main": "index.js",
4+
"scripts": {
5+
"test": "echo \"Error: no test specified\" && exit 1",
6+
"start": "node start.js"
7+
},
8+
"keywords": [
9+
"postcss",
10+
"postcss-import-sub"
11+
],
12+
"author": "Vladimir Kalmykov <[email protected]>",
13+
"license": "MIT",
14+
"devDependencies": {
15+
"chalk": "^1.1.3",
16+
"express": "^4.14.0",
17+
"gulp": "^3.9.1",
18+
"gulp-postcss": "^6.2.0",
19+
"opn": "^4.0.2",
20+
"postcss-import-sub": "^1.1.0",
21+
"postcss-simple-vars": "^3.0.0"
22+
}
23+
}

examples/recolor/postcss.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"use strict";
2+
const themeName = process.env.COLOR || 'default';
3+
4+
module.exports = {
5+
plugins: [
6+
require('../../index.js')([
7+
{
8+
base: /src/,
9+
id: /color\.css/,
10+
path: "<root>/themes/"+themeName+"/"
11+
}
12+
]),
13+
require('postcss-simple-vars')
14+
]
15+
}

examples/recolor/public/index.html

Lines changed: 35 additions & 0 deletions
Large diffs are not rendered by default.

examples/recolor/readme.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Color theme
2+
--
3+
4+
postcss-import-sub example
5+
==
6+
7+
# Usage
8+
9+
Run with normal theme:
10+
```shell
11+
npm start
12+
```
13+
14+
Run with purple theme:
15+
```shell
16+
COLOR=purple npm start
17+
```

examples/recolor/src/color.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$logoColor: red;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@import "color.css";
2+
3+
.postCssLogo path {
4+
fill: $logoColor;
5+
}

examples/recolor/start.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"use strict";
2+
const gulp = require('gulp');
3+
const express = require('express');
4+
const themeName = process.env.COLOR || 'default';
5+
const chalk = require('chalk');
6+
const launch = require('opn');
7+
const path = require('path');
8+
const subImport = require('postcss-import-sub');
9+
10+
console.log(chalk.magenta('Build...'));
11+
12+
if (themeName !== 'default') {
13+
console.log(chalk.magenta('Using '+themeName+' theme'));
14+
}
15+
16+
var postcss = require('gulp-postcss');
17+
18+
gulp.src('src/postcss-logo.css')
19+
.pipe( postcss([
20+
subImport([
21+
{
22+
base: /src/,
23+
id: /color\.css/,
24+
path: "<root>/themes/"+themeName+"/"
25+
}
26+
]),
27+
require('postcss-simple-vars')
28+
]) )
29+
.pipe( gulp.dest('./build/') )
30+
.on('end', function() {
31+
console.log(chalk.magenta('Completed'));
32+
33+
const app = express();
34+
35+
app.use(express.static('public'));
36+
37+
app.get('/style.css', function (req, res) {
38+
res.sendFile(path.resolve(__dirname, './build/postcss-logo.css'));
39+
})
40+
41+
app.listen(3000);
42+
43+
console.log(chalk.magenta('Open http://localhost:3000/ to see result.'));
44+
launch('http://localhost:3000');
45+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$logoColor: purple;

0 commit comments

Comments
 (0)