Skip to content

Commit 6d2d1da

Browse files
rschamplifeinchords
authored andcommitted
Use postcss-simple-vars for variables (scratchfoundation#125)
Using postcss-modules-values with imported values failed on our current basic usage; it is apparently not mature enough to be used yet. The syntax used by postcss-simple-vars is already familiar to most people familiar with modern CSS build systems.
1 parent 1cec825 commit 6d2d1da

File tree

4 files changed

+44
-44
lines changed

4 files changed

+44
-44
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@
4949
"lodash.pick": "4.4.0",
5050
"minilog": "3.1.0",
5151
"opt-cli": "1.5.1",
52+
"postcss-import": "9.1.0",
5253
"postcss-loader": "1.3.1",
53-
"postcss-modules-values": "1.2.2",
54+
"postcss-simple-vars": "3.0.0",
5455
"react": "15.4.2",
5556
"react-dom": "15.4.2",
5657
"react-modal": "1.6.5",

src/components/gui/gui.css

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,90 @@
1-
/*
2-
OQ: convention: _ for variables?
3-
TODO: refactor into resuable vars file
4-
https://github.com/css-modules/css-modules/blob/master/docs/values-variables.md
5-
*/
6-
@value _space: 0.5rem;
1+
@import "../../css/units.css";
72

83
.page-wrapper {
94
height: 100%;
105
}
116

127
.body-wrapper {
13-
/*
8+
/*
149
Calc the height by subtracting the menu bar height
1510
TODO: Make height a reusable variable, link to use in .menu-bar
1611
*/
17-
height: calc(100% - 3rem);
12+
height: calc(100% - 3rem);
1813
background-color: #e8edf1;
1914
}
2015

2116
.flex-wrapper {
2217
display: flex;
2318

24-
/*
25-
Make 2 columns:
26-
a) for the blocks + workspace panes, and
27-
b) for combined stage menu + stage + sprite/stage selectors
19+
/*
20+
Make 2 columns:
21+
a) for the blocks + workspace panes, and
22+
b) for combined stage menu + stage + sprite/stage selectors
2823
*/
29-
flex-direction: row;
24+
flex-direction: row;
3025
height: 100%;
3126
}
3227

3328
.blocks-wrapper {
34-
/*
35-
scratch-blocks is based on absolute positioning, which injects
29+
/*
30+
scratch-blocks is based on absolute positioning, which injects
3631
inside this element and becomes the child
3732
*/
38-
position: relative;
33+
position: relative;
3934

4035
flex-basis: 600px;
4136
flex-grow: 1;
4237
flex-shrink: 0;
4338

44-
/*
45-
Normally we'd use padding, but the absolute positioning ignores it,
46-
so use margin instead. Temporary, until tabs are inserted.
39+
/*
40+
Normally we'd use padding, but the absolute positioning ignores it,
41+
so use margin instead. Temporary, until tabs are inserted.
4742
*/
48-
margin-top: 3rem;
43+
margin-top: 3rem;
4944

5045
background: #e8edf1;
5146
}
5247

5348
.stage-and-target-wrapper {
54-
/*
55-
Make rows for children:
49+
/*
50+
Make rows for children:
5651
1) stage menu
5752
2) stage
5853
3) sprite/stage selectors
59-
Only reason we need this, is so .targetWrapper, which holds the selectors,
54+
Only reason we need this, is so .targetWrapper, which holds the selectors,
6055
goes to full vertical height of the window
6156
*/
6257
display: flex;
63-
flex-direction: column;
58+
flex-direction: column;
6459

65-
/*
66-
Calc the minimum width for this pane, accounting for left + right spacing.
67-
If and when the width doesn't need to be fixed, we can move the spacing out
68-
of this calc, and into padding instead
60+
/*
61+
Calc the minimum width for this pane, accounting for left + right spacing.
62+
If and when the width doesn't need to be fixed, we can move the spacing out
63+
of this calc, and into padding instead
6964
*/
70-
flex-basis: calc(480px + (_space * 2));
71-
}
65+
flex-basis: calc(480px + ($space * 2));
66+
}
7267

7368
.stage-wrapper {
74-
padding-left: _space;
75-
padding-right: _space;
69+
padding-left: $space;
70+
padding-right: $space;
7671
}
7772

7873
.target-wrapper {
7974
/* Take all the available vertical space available.
80-
Works in tandem with height: 100%; which is set on the child: .targetPane
81-
TODO: Not working in Safari, not great in FFx
75+
Works in tandem with height: 100%; which is set on the child: .targetPane
76+
TODO: Not working in Safari, not great in FFx
8277
*/
8378
flex-grow: 1;
8479
flex-basis: 0;
8580

86-
padding-top: _space;
87-
padding-left: _space;
88-
padding-right: _space;
89-
90-
/*
81+
padding-top: $space;
82+
padding-left: $space;
83+
padding-right: $space;
84+
85+
/*
9186
For making the sprite-selector a scrollable pane.
92-
TODO: Not working in Safari
87+
TODO: Not working in Safari
9388
*/
9489
overflow: hidden;
9590
}
@@ -99,5 +94,5 @@
9994
flex-shrink: 0;
10095
align-items: center;
10196
height: 3rem;
102-
padding: _space;
97+
padding: $space;
10398
}

src/css/units.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$space: 0.5rem;

webpack.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ var HtmlWebpackPlugin = require('html-webpack-plugin');
77

88
// PostCss
99
var autoprefixer = require('autoprefixer');
10-
var values = require('postcss-modules-values');
10+
var postcssVars = require('postcss-simple-vars');
11+
var postcssImport = require('postcss-import');
1112

1213
module.exports = {
1314
devServer: {
@@ -52,9 +53,11 @@ module.exports = {
5253
}, {
5354
loader: 'postcss-loader',
5455
options: {
56+
ident: 'postcss',
5557
plugins: function () {
5658
return [
57-
values,
59+
postcssImport,
60+
postcssVars,
5861
autoprefixer({
5962
browsers: ['last 3 versions', 'Safari >= 8', 'iOS >= 8']
6063
})

0 commit comments

Comments
 (0)