Skip to content

Commit 6accf72

Browse files
authored
💥[BREAKING] Switch, TextField APIs; commonjs/module build changes (#10)
* 💥 [BREAKING] [Switch] [TextField] remove auto-generated aria-labeledby (breaks SSR hydration) * [Switch] [TextField] update docs for new labelId prop * fix linter errs * 💥 fix CommonJS, Module builds * [karma.conf.js] Fix broken IE11 test (has-flag module uses arrow fns) * [BottomNavigation] fix missing import * [Ripple] fix missing import * [Switch] [TextField] simplify export syntax * delete unused webpack config file
1 parent 3c1d9ed commit 6accf72

File tree

17 files changed

+257
-106
lines changed

17 files changed

+257
-106
lines changed

.babelrc

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,48 @@
11
{
22
"env": {
3-
"production": {
3+
"commonjs": {
4+
"presets": [
5+
[
6+
"@babel/preset-env",
7+
{
8+
"modules": "commonjs",
9+
"targets": {
10+
"browsers": ["last 2 versions"]
11+
}
12+
}
13+
]
14+
],
415
"plugins": [
516
"babel-plugin-transform-react-remove-prop-types",
617
[
7-
"babel-plugin-transform-define", {
8-
"__TEST__": false
18+
"babel-plugin-css-modules-transform",
19+
{
20+
"generateScopedName": "[name].[local]",
21+
"prepend": [ "./postcss.config.js" ],
22+
"keepImport": true,
23+
"extractCss": {
24+
"dir": "./dist/",
25+
"relativeRoot": "./src/",
26+
"filename": "[path]/[name].css"
27+
}
28+
}
29+
]
30+
]
31+
},
32+
"module": {
33+
"plugins": [
34+
"babel-plugin-transform-react-remove-prop-types",
35+
[
36+
"babel-plugin-css-modules-transform",
37+
{
38+
"generateScopedName": "[name].[local]",
39+
"prepend": [ "./postcss.config.js" ],
40+
"keepImport": true,
41+
"extractCss": {
42+
"dir": "./es/",
43+
"relativeRoot": "./src/",
44+
"filename": "[path]/[name].css"
45+
}
946
}
1047
]
1148
]
@@ -14,7 +51,12 @@
1451
"plugins": [
1552
"@babel/plugin-proposal-class-properties",
1653
"@babel/plugin-proposal-object-rest-spread",
17-
"@babel/plugin-transform-runtime"
54+
"@babel/plugin-transform-runtime",
55+
[
56+
"babel-plugin-transform-define", {
57+
"__TEST__": false
58+
}
59+
]
1860
],
1961
"presets": [
2062
[
@@ -23,7 +65,7 @@
2365
"modules": false,
2466
"targets": {
2567
"browsers": ["last 2 versions"]
26-
},
68+
}
2769
}
2870
],
2971
"@babel/preset-react"

docs/pages/Switch/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class SwitchDocs extends React.Component {
1313
checked: true,
1414
disabled: false,
1515
label: 'Switch Label',
16+
labelId: 'foobar',
1617
primaryColor: Colors.$primary,
1718
switch1: false,
1819
switch2: true,
@@ -27,7 +28,7 @@ class SwitchDocs extends React.Component {
2728
}
2829

2930
render() {
30-
const {checked, disabled, label, primaryColor} = this.state;
31+
const {checked, disabled, label, labelId, primaryColor} = this.state;
3132
return (
3233
<Page
3334
componentName="Switch"
@@ -37,6 +38,7 @@ class SwitchDocs extends React.Component {
3738
onChange={e => (this.onControlPanel('checked', e.target.checked))}
3839
disabled={disabled}
3940
label={label}
41+
labelId={labelId}
4042
checked={checked}
4143
primaryColor={primaryColor}
4244
style={{justifyContent: 'center'}}
@@ -59,6 +61,11 @@ class SwitchDocs extends React.Component {
5961
label="label"
6062
value={label}
6163
/>,
64+
<TextField
65+
onChange={e => (this.onControlPanel('labelId', e.target.value))}
66+
label="labelId"
67+
value={labelId}
68+
/>,
6269
<TextField
6370
onChange={e => (this.onControlPanel('primaryColor', e.target.value))}
6471
label="primaryColor"

docs/pages/TextField/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class TextFieldDocs extends React.Component {
1212
this.onControlPanel = this.onControlPanel.bind(this);
1313
this.state = {
1414
label: 'Label',
15+
labelId: 'foobar',
1516
value: '',
1617
disabled: false,
1718
placeholder: 'Placeholder',
@@ -39,7 +40,7 @@ class TextFieldDocs extends React.Component {
3940
}
4041

4142
render() {
42-
const {label, helperText, placeholder, primaryColor,
43+
const {label, labelId, helperText, placeholder, primaryColor,
4344
errorColor, value, disabled, multiline, width} = this.state;
4445
return (
4546
<Page
@@ -48,6 +49,7 @@ class TextFieldDocs extends React.Component {
4849
<TextField
4950
onChange={e => (this.onControlPanel('value', e.target.value))}
5051
label={label}
52+
labelId={labelId}
5153
value={value}
5254
disabled={disabled}
5355
placeholder={placeholder}
@@ -64,6 +66,11 @@ class TextFieldDocs extends React.Component {
6466
label="label"
6567
value={label}
6668
/>,
69+
<TextField
70+
onChange={e => (this.onControlPanel('labelId', e.target.value))}
71+
label="labelId"
72+
value={labelId}
73+
/>,
6774
<TextField
6875
onChange={e => (this.onControlPanel('helperText', e.target.value))}
6976
label="helperText"

karma.conf.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ function getBrowserStackConfig(config) {
7878
const babelOptions = {
7979
plugins: [
8080
'@babel/plugin-proposal-class-properties',
81+
'@babel/plugin-proposal-object-rest-spread',
82+
[
83+
"babel-plugin-transform-define", {
84+
"__TEST__": true
85+
}
86+
],
8187
[
8288
'babel-plugin-istanbul', {
8389
exclude: [
@@ -204,7 +210,6 @@ module.exports = function (config) {
204210
},
205211
plugins: [
206212
new webpack.DefinePlugin({
207-
__TEST__: true,
208213
'process.env': {
209214
NODE_ENV: JSON.stringify('development')
210215
}

package-lock.json

Lines changed: 125 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@
1313
"material-ui"
1414
],
1515
"scripts": {
16-
"build": "npm-run-all build:dist:* build:es:*",
17-
"build:dist:js": "webpack --config webpack.config.dist.js -p",
18-
"build:dist:main": "babel src/index.js > dist/index.js",
16+
"build": "npm-run-all build:*",
17+
"build:commonjs": "BABEL_ENV=commonjs babel src --out-dir dist --ignore '**/*.spec.js'",
1918
"build:docs": "NODE_ENV=production webpack --config webpack.config.docs.js --env.docs",
20-
"build:es:css": "postcss src/**/*.css --base src --dir es",
21-
"build:es:js": "NODE_ENV=production babel src --ignore *.spec.js --out-dir es",
22-
"build:es:main": "cp src/index.js es/index.js",
19+
"build:module": "BABEL_ENV=module babel src --out-dir es --ignore '**/*.spec.js'",
2320
"build:ssr": "webpack --config webpack.config.ssr.js",
2421
"coverage:open": "open .coverage/lcov-report/index.html",
2522
"lint": "npm run lint:css && npm run lint:js",
@@ -44,8 +41,7 @@
4441
"material-design-icons": "3.0.1",
4542
"react-scrollbar-size": "2.1.0",
4643
"react-transition-group": "1.2.1",
47-
"tinycolor2": "1.4.1",
48-
"uuid": "3.3.2"
44+
"tinycolor2": "1.4.1"
4945
},
5046
"devDependencies": {
5147
"@babel/cli": "7.0.0-rc.1",
@@ -59,6 +55,7 @@
5955
"babel-core": "7.0.0-bridge.0",
6056
"babel-eslint": "8.2.6",
6157
"babel-loader": "7.1.5",
58+
"babel-plugin-css-modules-transform": "1.6.1",
6259
"babel-plugin-istanbul": "4.1.6",
6360
"babel-plugin-transform-define": "1.3.0",
6461
"babel-plugin-transform-react-remove-prop-types": "0.4.14",

postcss.config.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
const cssvariables = require('./src/variables');
22

33
module.exports = () => ({
4-
plugins: {
5-
'postcss-simple-vars': {
4+
plugins: [
5+
require('postcss-simple-vars')({
66
variables: () => (
77
cssvariables
88
)
9-
},
10-
autoprefixer: {
9+
}),
10+
require('autoprefixer')({
1111
browsers: [
1212
'last 4 versions',
1313
'Android >= 4.4',
@@ -18,6 +18,6 @@ module.exports = () => ({
1818
'iOS >= 8.4',
1919
'Safari >= 8'
2020
]
21-
}
22-
}
21+
})
22+
]
2323
});

0 commit comments

Comments
 (0)