Skip to content

Commit 0e20943

Browse files
committed
chore: update deps and refactor a little
1 parent 8093f74 commit 0e20943

12 files changed

+159
-156
lines changed

lib/test-setup.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
'use strict'
22

3-
var chai = require('chai')
4-
var jsdom = require('jsdom').jsdom
5-
var sinonChai = require('sinon-chai')
6-
7-
var exposedProperties = ['window', 'navigator', 'document']
3+
const chai = require('chai')
4+
const jsdom = require('jsdom').jsdom
5+
const sinonChai = require('sinon-chai')
86

97
// http://airbnb.io/enzyme/docs/guides/jsdom.html
108
global.document = jsdom('')
@@ -16,7 +14,6 @@ global.document.createRange = () => ({
1614
global.window = document.defaultView
1715
Object.keys(document.defaultView).forEach((property) => {
1816
if (typeof global[property] === 'undefined') {
19-
exposedProperties.push(property)
2017
global[property] = document.defaultView[property]
2118
}
2219
})
@@ -26,11 +23,15 @@ global.navigator = {
2623
}
2724
global.Node = {}
2825
global.requestAnimationFrame = (fn) => fn()
26+
global.cancelAnimationFrame = () => {}
2927

3028
// enzyme, and therefore chai-enzyme, needs to be required after
3129
// global.navigator is set up (https://github.com/airbnb/enzyme/issues/395)
32-
var chaiEnzyme = require('chai-enzyme')
30+
const enzyme = require('enzyme')
31+
const EnzymeAdapter = require('enzyme-adapter-react-16')
32+
const chaiEnzyme = require('chai-enzyme')
3333

34+
enzyme.configure({ adapter: new EnzymeAdapter() })
3435
chai.use(chaiEnzyme())
3536
chai.use(sinonChai)
3637
global.expect = chai.expect

package.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
"scripts": {
77
"build": "node ./scripts/build-dev.js",
88
"build-prod": "node ./scripts/build-prod.js",
9-
"lint": "eslint --fix src/*.js src/*.jsx",
9+
"lint": "eslint --fix src/*.jsx",
1010
"precommit": "npm run lint",
1111
"prepublish": "npm run build-prod",
12-
"pretest": "npm run lint",
1312
"start": "node ./scripts/watch.js --port 8888",
1413
"test": "node ./scripts/test.js",
15-
"semantic-release":
16-
"semantic-release pre && npm publish --access public && semantic-release post"
14+
"semantic-release": "semantic-release pre && npm publish --access public && semantic-release post"
1715
},
1816
"repository": {
1917
"type": "git",
@@ -28,36 +26,38 @@
2826
"dist"
2927
],
3028
"dependencies": {
31-
"popper.js": "^1.12.9",
32-
"prop-types": "15.6.0"
29+
"popper.js": "^1.14.4"
3330
},
3431
"devDependencies": {
35-
"babel-eslint": "^7.2.3",
36-
"chai": "^3.5.0",
37-
"chai-enzyme": "0.5.1",
32+
"babel-eslint": "^10.0.1",
33+
"chai": "^4.2.0",
34+
"chai-enzyme": "1.0.0-beta.1",
3835
"condition-circle": "1.5.0",
3936
"dont-crack": "1.2.1",
40-
"enzyme": "2.4.1",
41-
"eslint": "^4.12.1",
42-
"eslint-plugin-cypress-dev": "^1.1.1",
43-
"eslint-plugin-mocha": "^4.11.0",
44-
"eslint-plugin-react": "^7.5.1",
37+
"enzyme": "3.7.0",
38+
"enzyme-adapter-react-16": "1.6.0",
39+
"eslint": "^5.6.1",
40+
"eslint-plugin-cypress-dev": "^1.1.2",
41+
"eslint-plugin-mocha": "^5.2.0",
42+
"eslint-plugin-react": "^7.11.1",
43+
"fs-extra": "7.0.0",
4544
"github-post-release": "1.13.1",
4645
"jsdom": "^9.5.0",
47-
"lodash": "^4.0.0",
48-
"react": "15.6.2",
49-
"react-addons-test-utils": "15.6.2",
50-
"react-dom": "15.6.2",
46+
"lodash": "^4.17.11",
47+
"prop-types": "^15.6.2",
48+
"react": "16.5.2",
49+
"react-dom": "16.5.2",
5150
"semantic-release": "8.2.0",
5251
"simple-commit-message": "3.3.1",
53-
"sinon": "^1.17.6",
54-
"sinon-chai": "^2.8.0",
55-
"zunder": "5.5.1"
52+
"sinon": "^6.3.5",
53+
"sinon-chai": "^3.2.0",
54+
"zunder": "6.2.0"
5655
},
5756
"peerDependencies": {
58-
"lodash": "^4.0.0",
59-
"react": "^15.3.2",
60-
"react-dom": "^15.3.2"
57+
"lodash": "^4.17.11",
58+
"prop-types": "^15.6.2",
59+
"react": "^16.5.2",
60+
"react-dom": "^16.5.2"
6161
},
6262
"release": {
6363
"verifyConditions": "condition-circle",

scripts/build-dev.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
var z = require('zunder')
2-
var u = z.undertaker
3-
var setZunderConfig = require('./set-zunder-config')
1+
const z = require('zunder')
2+
const u = z.undertaker
3+
const setZunderConfig = require('./set-zunder-config')
4+
const copyScss = require('./copy-scss')
45

56
setZunderConfig(z)
67

78
u.series(
89
z.applyDevEnv,
910
z.cleanDev,
10-
u.parallel(
11-
z.copyDevScripts,
12-
z.buildDevStylesheets
13-
)
11+
z.copyDevScripts,
12+
z.buildDevStylesheets,
13+
copyScss(z.config.devDir)
1414
)()

scripts/build-prod.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1-
var fs = require('fs')
2-
var path = require('path')
3-
var z = require('zunder')
4-
var u = z.undertaker
5-
var setZunderConfig = require('./set-zunder-config')
1+
const z = require('zunder')
2+
const u = z.undertaker
3+
const setZunderConfig = require('./set-zunder-config')
4+
const copyScss = require('./copy-scss')
65

76
setZunderConfig(z)
87

9-
var copyScss = () => {
10-
var from = path.join(__dirname, '..', 'src', 'main.scss')
11-
var to = path.join(z.config.prodDir, 'tooltip.scss')
12-
13-
return fs.createReadStream(from)
14-
.pipe(fs.createWriteStream(to))
15-
}
16-
178
u.series(
189
z.applyProdEnv,
1910
z.cleanProd,
2011
z.copyProdScripts,
2112
z.buildProdStylesheets,
22-
copyScss
13+
copyScss(z.config.prodDir)
2314
)()

scripts/copy-scss.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
4+
module.exports = (dir) => () => {
5+
const from = path.join(__dirname, '..', 'src', 'main.scss')
6+
const to = path.join(dir, 'tooltip.scss')
7+
8+
return fs.createReadStream(from)
9+
.pipe(fs.createWriteStream(to))
10+
}

scripts/set-zunder-config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ module.exports = function setZunderConfig (zunder) {
22
zunder.setConfig({
33
cacheBust: false,
44
prodDir: 'dist',
5-
stylesheetName: 'tooltip.css',
5+
stylesheets: {
6+
'src/main.scss': {
7+
watch: ['src/**/*.scss'],
8+
output: 'tooltip.css',
9+
},
10+
},
611
testDir: 'dist',
712
})
813
}

scripts/watch.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
1-
var z = require('zunder')
2-
var u = z.undertaker
3-
var setZunderConfig = require('./set-zunder-config')
1+
const fs = require('fs-extra')
2+
const z = require('zunder')
3+
const u = z.undertaker
4+
const setZunderConfig = require('./set-zunder-config')
5+
const copyScss = require('./copy-scss')
6+
7+
const ensureDevDir = () => fs.ensureDir(z.config.devDir)
48

59
setZunderConfig(z)
610

11+
// TODO: watch scss, so it's copied on change
12+
713
u.series(
814
z.applyDevEnv,
915
z.cleanDev,
16+
ensureDevDir,
17+
copyScss(z.config.devDir),
1018
u.parallel(
11-
z.watchServer,
12-
z.watchStaticAssets,
19+
// need these for 'design' mode, but z.watchScripts conflicts with z.watchTests
20+
// because testDir and devDir are the same. need to fix in zunder
21+
// z.watchServer,
22+
// z.watchStaticAssets,
23+
// z.watchScripts,
1324
z.watchTests,
14-
z.watchScripts,
1525
z.watchStylesheets
1626
)
1727
)()

src/portal-popper.jsx

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,10 @@ class PortalPopper extends Component {
2929
className: '',
3030
}
3131

32-
constructor (...props) {
33-
super(...props)
34-
35-
this.state = {
36-
arrowProps: initialArrowProps,
37-
popperProps: initialPopperProps,
38-
flipped: false,
39-
}
32+
state = {
33+
arrowProps: initialArrowProps,
34+
popperProps: initialPopperProps,
35+
flipped: false,
4036
}
4137

4238
render () {
@@ -45,32 +41,33 @@ class PortalPopper extends Component {
4541
const flippedClass = this.state.flipped ? ` ${prefix}-flipped` : ''
4642

4743
return (
48-
<Portal
49-
ref='portal'
50-
className={`${className} ${prefix}-${placement}${flippedClass}`}
51-
style={this._getPopperStyle()}
52-
appendTo={this.props.appendTo}
53-
>
54-
<span>{title}</span>
44+
<Portal appendTo={this.props.appendTo}>
5545
<div
56-
ref='arrow'
57-
className={`${prefix}-arrow`}
58-
style={this._getArrowStyle()}
46+
ref={(node) => this.portalNode = node}
47+
className={`${className} ${prefix}-${placement}${flippedClass}`}
48+
style={this._getPopperStyle()}
5949
>
60-
<svg xmlns='http://www.w3.org/2000/svg' version='1.1'>
61-
<polygon points='5,0 10,5 5,10 0,5' />
62-
</svg>
50+
<span>{title}</span>
51+
<div
52+
ref={(node) => this.arrowNode = node}
53+
className={`${prefix}-arrow`}
54+
style={this._getArrowStyle()}
55+
>
56+
<svg xmlns='http://www.w3.org/2000/svg' version='1.1'>
57+
<polygon points='5,0 10,5 5,10 0,5' />
58+
</svg>
59+
</div>
6360
</div>
6461
</Portal>
6562
)
6663
}
6764

6865
componentDidMount () {
69-
this.popper = new this.props.Popper(this.props.getTargetNode(), this.refs.portal.domNode, {
66+
this.popper = new this.props.Popper(this.props.getTargetNode(), this.portalNode, {
7067
content: this.props.title,
7168
placement: this.props.placement,
7269
modifiers: {
73-
arrow: { element: this.refs.arrow },
70+
arrow: { element: this.arrowNode },
7471
preventOverflow: {
7572
boundariesElement: this.props.boundary,
7673
},

0 commit comments

Comments
 (0)