Skip to content

Commit 97ea209

Browse files
author
Chris Brown
committed
Fixed publishing issues
Fixed carbon.sh screenshot path issues. Updated CodeSandbox link. Visualizer for bundle. Externalize all dependencies.
1 parent e90eeea commit 97ea209

File tree

8 files changed

+1041
-62
lines changed

8 files changed

+1041
-62
lines changed

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ yarn-error.log*
2020
.next/
2121
out/
2222

23-
2423
# TypeScript
2524
*.tsbuildinfo
2625

@@ -33,6 +32,11 @@ out/
3332
dist
3433
build
3534
spring/styles.css
35+
framer/styles.css
36+
37+
# rollup-plugin-visualizer
38+
spring/stats
39+
framer/stats
3640

3741
# Testing
3842
coverage

examples/typescript/package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
"cra-template-typescript": "^1.0.3",
1010
"react": "^17.0.1",
1111
"react-dom": "^17.0.1",
12-
"react-scripts": "^4.0.1",
13-
"react-spring": "^8.0.27",
14-
"react-spring-modal": "1.0.8"
12+
"react-scripts": "^4.0.1"
1513
},
1614
"scripts": {
1715
"start": "react-scripts start",

spring/README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ A component library for animatable and accessible modals built with react-spring
1414

1515
## Usage
1616

17-
![Example usage of CenterModal, ModalTitle, and ModalCloseTarget to make a "confirmation" modal](assets/carbon.png)
17+
![Example usage of CenterModal, ModalTitle, and ModalCloseTarget to make a "confirmation" modal](/spring/assets/carbon.png)
1818

1919
### Installation
2020

@@ -32,9 +32,7 @@ npm i react-spring-modal react react-dom react-spring
3232

3333
### Example
3434

35-
<!-- TODO: update example after publishing -->
36-
37-
You can [view comprehensive live examples on CodeSandbox.io](https://codesandbox.io/embed/react-spring-modalall-b3wp2?fontsize=14&hidenavigation=1&theme=dark)
35+
You can [view comprehensive live examples on CodeSandbox.io](https://codesandbox.io/s/react-spring-modalexamples-v2-lcjc5?file=/src/examples/Bottom.tsx)
3836

3937
To use this package you'll need to choose a modal and import the CSS file. In our example, we'll be using `<BottomModal>` to animate it's HTML contents up from the bottom of the screen with a white background.
4038

spring/package.json

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "react-spring-modal",
3-
"version": "2.0.1",
2+
"name": "@chrisbrownie55/react-spring-modal",
3+
"version": "2.0.7",
44
"description": "Animatable and accessible modals built with react-spring and @reach/dialog",
55
"author": "Chris Brown <[email protected]> (https://chrisbrownie.dev)",
66
"license": "MIT",
@@ -37,11 +37,10 @@
3737
},
3838
"types": "./dist/modern/index.d.ts",
3939
"files": [
40-
"./dist",
41-
"./styles.css",
42-
"./src",
43-
"./package.json",
44-
"./README.md"
40+
"dist",
41+
"styles.css",
42+
"src",
43+
"assets"
4544
],
4645
"scripts": {
4746
"emit": "",
@@ -59,20 +58,20 @@
5958
"@types/react-dom": "^17.0.1",
6059
"react": "^17.0.1",
6160
"react-dom": "^17.0.1",
62-
"react-spring": "^8.0.27",
6361
"rollup": "^2.36.1",
6462
"rollup-plugin-css-only": "^3.1.0",
6563
"rollup-plugin-delete": "^2.0.0",
64+
"rollup-plugin-node-externals": "^2.2.0",
65+
"rollup-plugin-visualizer": "^4.2.2",
6666
"typescript": "^4.2.0-beta"
6767
},
6868
"peerDependencies": {
6969
"react": ">=16.8.0",
70-
"react-dom": ">=16.8.0",
71-
"react-spring": ">=8"
70+
"react-dom": ">=16.8.0"
7271
},
7372
"dependencies": {
74-
"@reach/auto-id": "^0.12.1",
75-
"@reach/dialog": ">=0.12",
76-
"react-focus-lock": "^2.5.0"
73+
"@reach/auto-id": "^0.14.0",
74+
"@reach/dialog": "^0.14.0",
75+
"react-spring": "^8.0.21"
7776
}
7877
}

spring/rollup.config.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import typescript from 'typescript';
22
import pluginTypeScript from '@rollup/plugin-typescript';
33
import del from 'rollup-plugin-delete';
4+
import externals from 'rollup-plugin-node-externals';
5+
import visualize from 'rollup-plugin-visualizer';
46

57
import tsConfig from './tsconfig.json';
68
import pkg from './package.json';
@@ -49,8 +51,9 @@ function copyStyles() {
4951
export default [
5052
{
5153
input: pkg.source,
52-
external: externalDependencies,
5354
plugins: [
55+
externals({ deps: true }), // automatic externalization of dependencies
56+
visualize({ filename: 'stats/commonjs.html' }), // creates a visualization of the bundle
5457
// so Rollup can convert TypeScript to JavaScript
5558
pluginTypeScript({ ...TypeScriptConfigs.legacy, declarationDir: './dist/commonjs/' }),
5659
copyStyles(), // so we can have CSS!
@@ -60,14 +63,20 @@ export default [
6063
},
6164
{
6265
input: pkg.source,
63-
external: externalDependencies,
64-
plugins: [pluginTypeScript({ ...TypeScriptConfigs.legacy, declarationDir: './dist/module/' })],
66+
plugins: [
67+
externals({ deps: true }),
68+
visualize({ filename: 'stats/module.html' }),
69+
pluginTypeScript({ ...TypeScriptConfigs.legacy, declarationDir: './dist/module/' })
70+
],
6571
output: { dir: './dist/module/', format: 'es', sourcemap: true }
6672
},
6773
{
6874
input: pkg.source,
69-
external: externalDependencies,
70-
plugins: [pluginTypeScript(TypeScriptConfigs.modern)],
75+
plugins: [
76+
visualize({ filename: 'stats/modern.html' }),
77+
externals({ deps: true }),
78+
pluginTypeScript(TypeScriptConfigs.modern)
79+
],
7180
output: { dir: './dist/modern/', format: 'es', sourcemap: true }
7281
}
7382
];

spring/src/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export function BaseModal({
131131
...transitionConfig,
132132
onRest(isOpen: boolean, animationStatus: string) {
133133
if (typeof transitionConfig.onRest === 'function') {
134-
transitionConfig.onRest(isOpen, animationStatus);
134+
transitionConfig?.onRest(isOpen, animationStatus);
135135
}
136136
if (animationStatus === 'update') setStatus(isOpen ? 'focus-locked' : 'focus-unlocked'); // if done opening, lock focus. if done closing, unlock focus
137137
}

0 commit comments

Comments
 (0)