Skip to content

Commit 7940bfe

Browse files
authored
Upgrade project (#333)
* chore: upgrade dependencies * docs: refactor storybook to latest version Add emotion for styling, and framer-motion for animations * docs: rewrite hooks to csf * docs: rewrite inView component to csf
1 parent 5c9b811 commit 7940bfe

File tree

24 files changed

+6517
-1959
lines changed

24 files changed

+6517
-1959
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,3 @@ jobs:
2626
CI: true
2727
- name: Build
2828
run: yarn build
29-

.storybook/.babelrc

Lines changed: 0 additions & 8 deletions
This file was deleted.

.storybook/addons.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

.storybook/config.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
11
import React from 'react'
2-
import { addParameters, configure } from '@storybook/react'
2+
import { addDecorator, addParameters } from '@storybook/react'
33
import { create } from '@storybook/theming'
44
import 'intersection-observer'
5-
import './base.css'
6-
import pck from '../package'
5+
import { Global } from '@emotion/react'
76

87
addParameters({
98
options: {
109
theme: create({
1110
base: 'dark',
12-
brandTitle: pck.name,
13-
brandUrl: pck.repository.url,
11+
brandTitle: 'react-intersection-observer',
12+
brandUrl: 'https://github.com/thebuilder/react-intersection-observer',
1413
}),
1514
isFullscreen: false,
1615
panelPosition: 'bottom',
1716
},
1817
})
1918

20-
/**
21-
* Use require.context to load dynamically: https://webpack.github.io/docs/context.html
22-
*/
23-
const req = require.context('../stories', true, /story\.tsx$/)
24-
25-
function loadStories() {
26-
req.keys().forEach(req)
27-
}
28-
29-
configure(loadStories, module)
19+
addDecorator((storyFn) => (
20+
<>
21+
<Global
22+
styles={{
23+
'html, body': {
24+
fontFamily:
25+
"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif",
26+
padding: 0,
27+
margin: 0,
28+
color: '#0c0c0c',
29+
fontSize: '16px',
30+
},
31+
}}
32+
/>
33+
{storyFn()}
34+
</>
35+
))

.storybook/main.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const path = require('path')
2+
3+
module.exports = {
4+
stories: ['../src/stories/**/*.(story|stories).(ts|tsx|js|jsx|mdx)'],
5+
addons: [
6+
'@storybook/addon-actions',
7+
'@storybook/addon-viewport',
8+
{
9+
name: '@storybook/preset-create-react-app',
10+
options: {
11+
tsDocgenLoaderOptions: {
12+
tsconfigPath: path.resolve(__dirname, '../tsconfig.json'),
13+
},
14+
},
15+
},
16+
// {
17+
// name: '@storybook/addon-docs',
18+
// options: {
19+
// configureJSX: true,
20+
// },
21+
// },
22+
],
23+
}

.storybook/webpack.config.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ function Component(props) {
203203

204204
// Use `useCallback` so we don't recreate the function on each render - Could result in infinite loop
205205
const setRefs = useCallback(
206-
node => {
206+
(node) => {
207207
// Ref's from useRef needs to have the node assigned to `current`
208208
ref.current = node
209209
// Callback refs, like the one from `useInView`, is a function that takes the node as an argument

package.json

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -132,54 +132,58 @@
132132
"react": "^15.0.0 || ^16.0.0 || ^17.0.0"
133133
},
134134
"devDependencies": {
135-
"@babel/cli": "^7.5.0",
136-
"@babel/core": "^7.5.4",
137-
"@babel/plugin-proposal-class-properties": "^7.5.0",
138-
"@babel/plugin-transform-runtime": "^7.5.0",
139-
"@babel/preset-env": "^7.5.4",
140-
"@babel/preset-flow": "^7.0.0",
141-
"@babel/preset-react": "^7.0.0",
142-
"@babel/preset-typescript": "^7.1.0",
143-
"@storybook/addon-actions": "^5.0.0",
144-
"@storybook/addon-knobs": "^5.0.6",
145-
"@storybook/components": "^5.0.0",
146-
"@storybook/react": "^5.0.0",
147-
"@storybook/theming": "^5.0.11",
148-
"@testing-library/jest-dom": "^5.0.0",
149-
"@testing-library/react": "^9.4.0",
150-
"@types/jest": "^25.1.2",
151-
"@types/react": "^16.9.19",
152-
"@types/react-dom": "^16.9.5",
153-
"@typescript-eslint/eslint-plugin": "^2.19.2",
154-
"@typescript-eslint/parser": "^2.19.2",
155-
"babel-eslint": "^10.0.3",
156-
"babel-jest": "^25.1.0",
157-
"babel-loader": "^8.0.5",
135+
"@babel/cli": "^7.8.4",
136+
"@babel/core": "^7.9.0",
137+
"@babel/plugin-proposal-class-properties": "^7.8.3",
138+
"@babel/plugin-transform-runtime": "^7.9.0",
139+
"@babel/preset-env": "^7.9.5",
140+
"@babel/preset-flow": "^7.9.0",
141+
"@babel/preset-react": "^7.9.4",
142+
"@babel/preset-typescript": "^7.9.0",
143+
"@emotion/react": "^11.0.0-next.12",
144+
"@storybook/addon-actions": "^5.3.18",
145+
"@storybook/addon-viewport": "^5.3.18",
146+
"@storybook/components": "^5.3.18",
147+
"@storybook/preset-create-react-app": "^2.1.1",
148+
"@storybook/react": "^5.3.18",
149+
"@storybook/theming": "^5.3.18",
150+
"@testing-library/jest-dom": "^5.5.0",
151+
"@testing-library/react": "^10.0.2",
152+
"@types/jest": "^25.2.1",
153+
"@types/react": "^16.9.34",
154+
"@types/react-dom": "^16.9.6",
155+
"@typescript-eslint/eslint-plugin": "^2.27.0",
156+
"@typescript-eslint/parser": "^2.27.0",
157+
"babel-eslint": "^10.1.0",
158+
"babel-jest": "^25.3.0",
159+
"babel-loader": "^8.1.0",
158160
"babel-plugin-dev-expression": "^0.2.2",
159161
"concurrently": "^5.1.0",
160-
"coveralls": "^3.0.5",
162+
"coveralls": "^3.0.11",
161163
"eslint": "^6.8.0",
162-
"eslint-config-react-app": "^5.2.0",
163-
"eslint-plugin-flowtype": "^4.6.0",
164-
"eslint-plugin-import": "^2.20.1",
164+
"eslint-config-react-app": "^5.2.1",
165+
"eslint-plugin-flowtype": "^4.7.0",
166+
"eslint-plugin-import": "^2.20.2",
165167
"eslint-plugin-jsx-a11y": "^6.2.3",
166-
"eslint-plugin-react": "^7.18.3",
167-
"eslint-plugin-react-hooks": "^2.0.1",
168-
"husky": "^4.2.3",
168+
"eslint-plugin-react": "^7.19.0",
169+
"eslint-plugin-react-hooks": "^3.0.0",
170+
"framer-motion": "^1.10.3",
171+
"husky": "^4.2.5",
169172
"intersection-observer": "^0.7.0",
170-
"jest": "^25.1.0",
171-
"lint-staged": "^10.0.7",
173+
"jest": "^25.3.0",
174+
"lint-staged": "^10.1.3",
172175
"npm-run-all": "^4.1.5",
173-
"prettier": "^1.16.2",
174-
"react": "^16.9.0",
175-
"react-dom": "^16.9.0",
176-
"react-test-renderer": "^16.9.0",
177-
"rollup": "^1.31.1",
178-
"rollup-plugin-babel": "^4.2.0",
176+
"prettier": "^2.0.4",
177+
"react": "^16.13.1",
178+
"react-dom": "^16.13.1",
179+
"react-scripts": "^3.4.1",
180+
"react-test-renderer": "^16.13.1",
181+
"rollup": "^2.6.0",
182+
"rollup-plugin-babel": "^4.4.0",
179183
"rollup-plugin-commonjs": "^10.0.1",
180184
"rollup-plugin-node-resolve": "^5.2.0",
181185
"rollup-plugin-replace": "^2.1.0",
182-
"rollup-plugin-terser": "^5.2.0",
183-
"typescript": "^3.7.5"
186+
"rollup-plugin-terser": "^5.3.0",
187+
"typescript": "^3.8.3"
184188
}
185189
}

rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { terser } from 'rollup-plugin-terser'
88
import pkg from './package.json'
99

1010
const root = process.platform === 'win32' ? path.resolve('/') : '/'
11-
const external = id => !id.startsWith('.') && !id.startsWith(root)
11+
const external = (id) => !id.startsWith('.') && !id.startsWith(root)
1212
const extensions = ['.js', '.jsx', '.ts', '.tsx']
1313
const globals = {
1414
react: 'React',

scripts/build-copy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const rootDir = path.resolve(__dirname, '../')
55
const distDir = path.resolve(__dirname, '../dist')
66

77
const filesToCopy = ['package.json', 'README.md', 'LICENSE']
8-
filesToCopy.forEach(file => {
8+
filesToCopy.forEach((file) => {
99
fs.copyFileSync(path.resolve(rootDir, file), path.resolve(distDir, file))
1010
})
1111

@@ -23,7 +23,7 @@ const packageFieldsToRemove = [
2323
'np',
2424
]
2525

26-
packageFieldsToRemove.forEach(field => {
26+
packageFieldsToRemove.forEach((field) => {
2727
delete pck[field]
2828
})
2929

0 commit comments

Comments
 (0)