Skip to content

Commit d915826

Browse files
committed
added an example where a file is being imported and composed
1 parent 323d49d commit d915826

File tree

7 files changed

+36
-9
lines changed

7 files changed

+36
-9
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"dependencies": {
1010
"postcss": "^4.1.11",
11-
"postcss-modules-extract-imports": "^0.0.5",
11+
"postcss-modules-extract-imports": "^0.0.6",
1212
"postcss-modules-local-by-default": "^0.0.9",
1313
"postcss-modules-scope": "^0.0.8"
1414
},

src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import postcss from 'postcss'
22
import localByDefault from 'postcss-modules-local-by-default'
33
import extractImports from 'postcss-modules-extract-imports'
44
import scope from 'postcss-modules-scope'
5-
import wip from "./wip"
5+
import constants from "./postcss-modules-constants"
66

77
import Parser from './parser'
88

@@ -27,4 +27,4 @@ export default class Core {
2727
Core.localByDefault = localByDefault
2828
Core.extractImports = extractImports
2929
Core.scope = scope
30-
Core.defaultPlugins = [wip, localByDefault, extractImports, scope]
30+
Core.defaultPlugins = [constants, localByDefault, extractImports, scope]
File renamed without changes.

test/test-cases/constants/colors.css

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1-
@let primary: aquamarine;
2-
@let secondary: red;
1+
@let primary: #f01;
2+
@let secondary: #2f2;
3+
4+
.text-primary {
5+
color: primary;
6+
}
7+
.bg-primary {
8+
background-color: primary;
9+
}
10+
11+
.text-secondary {
12+
color: secondary;
13+
}
14+
.bg-secondary {
15+
background-color: secondary;
16+
}

test/test-cases/constants/expected.css

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
._constants_borders__dashed {
22
border: 4px dashed;
33
}
4+
._constants_colors__text-primary {
5+
color: #f01;
6+
}
7+
._constants_colors__bg-primary {
8+
background-color: #f01;
9+
}
410

11+
._constants_colors__text-secondary {
12+
color: #2f2;
13+
}
14+
._constants_colors__bg-secondary {
15+
background-color: #2f2;
16+
}
517

618
._constants_source__foo {
7-
background: aquamarine;
8-
border-color: red;
19+
box-shadow: 0 0 10px #f01;
20+
border-color: #2f2;
921
}
1022

1123
@media (max-width: 599px) {
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"borders": "\"./borders.css\"",
33
"breakpoints": "\"./breakpoints.css\"",
4-
"foo": "_constants_source__foo _constants_borders__dashed"
4+
"foo": "_constants_source__foo _constants_borders__dashed _constants_colors__text-secondary"
55
}

test/test-cases/constants/source.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
.foo {
66
composes: dashed from borders;
7-
background: blue;
7+
composes: text-secondary from "./colors.css";
8+
box-shadow: 0 0 10px blue;
89
border-color: secondary;
910
}
1011

0 commit comments

Comments
 (0)