-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use webpack instead of rollup to reduce number of bundlers.
- Loading branch information
Showing
9 changed files
with
4,858 additions
and
711 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
dist/* | ||
node_modules/ | ||
www/public/ | ||
!.storybook/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import '@storybook/addon-knobs/register' | ||
import '@storybook/addon-storysource/register' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { configure } from '@storybook/react' | ||
|
||
// automatically import all files ending in *.stories.js | ||
const req = require.context('../stories', true, /.stories.jsx?$/) | ||
function loadStories() { | ||
req.keys().forEach(filename => req(filename)) | ||
} | ||
|
||
configure(loadStories, module) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = ({ config, mode }) => { | ||
config.module.rules.push({ | ||
test: /\.tsx?$/, | ||
use: ['babel-loader'], | ||
}) | ||
config.module.rules.push({ | ||
test: /.stories.jsx?$/, | ||
use: [require.resolve('@storybook/addon-storysource/loader')], | ||
enforce: 'pre', | ||
}) | ||
config.resolve.extensions.push('.ts', '.tsx') | ||
return config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import React from 'react' | ||
import { useWindowSize } from 'react-use' | ||
import { withKnobs, boolean, number } from '@storybook/addon-knobs' | ||
import { storiesOf } from '@storybook/react' | ||
|
||
import ReactConfetti from '../src/ReactConfetti' | ||
|
||
const SizedConfetti = (passedProps) => { | ||
const { width, height } = useWindowSize() | ||
return ( | ||
<ReactConfetti | ||
width={width} | ||
height={height} | ||
{...passedProps} | ||
/> | ||
) | ||
} | ||
|
||
const PointConfetti = (passedProps) => { | ||
const { width, height } = useWindowSize() | ||
return ( | ||
<ReactConfetti | ||
width={width} | ||
height={height} | ||
confettiSource={{ | ||
w: 10, | ||
h: 10, | ||
x: width / 2, | ||
y: height / 2, | ||
}} | ||
{...passedProps} | ||
/> | ||
) | ||
} | ||
|
||
storiesOf('Confetti', module) | ||
.addDecorator(withKnobs) | ||
.add('Props', () => ( | ||
<SizedConfetti | ||
run={boolean('Run', true)} | ||
recycle={boolean('Recycle', true)} | ||
numberOfPieces={number('# Pieces', 200, { | ||
range: true, | ||
min: 0, | ||
max: 2000, | ||
step: 10, | ||
})} | ||
wind={number('Wind', 0, { | ||
range: true, | ||
min: -0.5, | ||
max: 0.5, | ||
step: 0.001, | ||
})} | ||
gravity={number('Gravity', 0.1, { | ||
range: true, | ||
min: -1, | ||
max: 1, | ||
step: 0.01, | ||
})} | ||
opacity={number('Opacity', 100, { | ||
range: true, | ||
min: 0, | ||
max: 100, | ||
step: 1, | ||
}) / 100} | ||
/> | ||
)) | ||
.add('Custom Source', () => ( | ||
<PointConfetti | ||
run={boolean('Run', true)} | ||
recycle={boolean('Recycle', true)} | ||
numberOfPieces={number('# Pieces', 200, { | ||
range: true, | ||
min: 0, | ||
max: 2000, | ||
step: 10, | ||
})} | ||
wind={number('Wind', 0, { | ||
range: true, | ||
min: -0.5, | ||
max: 0.5, | ||
step: 0.001, | ||
})} | ||
gravity={number('Gravity', 0.1, { | ||
range: true, | ||
min: -1, | ||
max: 1, | ||
step: 0.01, | ||
})} | ||
opacity={number('Opacity', 100, { | ||
range: true, | ||
min: 0, | ||
max: 100, | ||
step: 1, | ||
}) / 100} | ||
/> | ||
)) | ||
.add('Default', () => <ReactConfetti />) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const path = require('path') | ||
|
||
const base = { | ||
mode: 'development', | ||
devtool: 'source-map', | ||
entry: { | ||
'react-confetti': ['./src/ReactConfetti.tsx'], | ||
}, | ||
output: { | ||
path: path.join(__dirname, 'dist'), | ||
filename: '[name].js', | ||
library: 'ReactConfetti', | ||
libraryTarget: 'umd', | ||
libraryExport: 'default', | ||
globalObject: 'typeof self !== "undefined" ? self : this', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, | ||
loaders: ['babel-loader'], | ||
exclude: [/node_modules/], | ||
}, | ||
], | ||
}, | ||
externals: { | ||
react: { | ||
root: 'React', | ||
commonjs2: 'react', | ||
commonjs: 'react', | ||
amd: 'react', | ||
}, | ||
}, | ||
resolve: { | ||
extensions: ['.js', '.jsx', '.ts', '.tsx'], | ||
}, | ||
} | ||
|
||
module.exports = [ | ||
base, | ||
{ | ||
...base, | ||
mode: 'production', | ||
output: { | ||
...base.output, | ||
filename: '[name].min.js', | ||
}, | ||
}, | ||
] |
Oops, something went wrong.