-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a185e7
commit 206e608
Showing
10 changed files
with
320 additions
and
163 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
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,37 +1,95 @@ | ||
import React, { useState, CSSProperties } from 'react' | ||
import { Fireworks } from '../src/react' | ||
import { FireworksOptions } from '../src/fireworks' | ||
import { CSSProperties } from 'react' | ||
import { Fireworks, useFireworks } from 'fireworks-js/dist/react' | ||
|
||
export const App: React.FC = () => { | ||
const [isEnable, setEnable] = useState(true) | ||
|
||
const options: FireworksOptions = { | ||
speed: 3, | ||
mouse: { | ||
max: 3, | ||
move: false, | ||
click: true | ||
export default function App() { | ||
const { | ||
setEnabled, | ||
setOptions, | ||
enabled, | ||
options, | ||
} = useFireworks({ | ||
initialStart: true, | ||
initialOptions: { | ||
hue: { | ||
min: 0, | ||
max: 345 | ||
}, | ||
delay: { | ||
min: 15, | ||
max: 15 | ||
}, | ||
rocketsPoint: 50, | ||
speed: 10, | ||
acceleration: 1.2, | ||
friction: 0.96, | ||
gravity: 1, | ||
particles: 90, | ||
trace: 3, | ||
explosion: 6, | ||
autoresize: true, | ||
brightness: { | ||
min: 50, | ||
max: 80, | ||
decay: { | ||
min: 0.015, | ||
max: 0.03 | ||
} | ||
}, | ||
boundaries: { | ||
visible: true | ||
}, | ||
sound: { | ||
enable: false, | ||
files: [ | ||
'https://fireworks.js.org/sounds/explosion0.mp3', | ||
'https://fireworks.js.org/sounds/explosion1.mp3', | ||
'https://fireworks.js.org/sounds/explosion2.mp3' | ||
], | ||
volume: { | ||
min: 1, | ||
max: 2 | ||
} | ||
}, | ||
mouse: { | ||
click: true, | ||
move: false, | ||
max: 3 | ||
} | ||
} | ||
} | ||
}) | ||
|
||
const style: CSSProperties = { | ||
left: 0, | ||
top: 0, | ||
left: 0, | ||
width: '100%', | ||
height: '100%', | ||
position: 'fixed', | ||
background: '#000' | ||
} | ||
|
||
const toggleSound = () => { | ||
setOptions({ sound: { enable: !options.sound!.enable } }) | ||
} | ||
|
||
return ( | ||
<div> | ||
<button | ||
onClick={() => setEnable(!isEnable)} | ||
style={{ position: 'absolute', zIndex: 9999 }} | ||
> | ||
{isEnable ? 'Stop' : 'Start'} | ||
</button> | ||
{isEnable && <Fireworks options={options} style={style} />} | ||
</div> | ||
<Fireworks | ||
style={style} | ||
enabled={enabled} | ||
options={options} | ||
> | ||
<div style={{ | ||
gap: '6px', | ||
padding: '6px', | ||
display: 'flex', | ||
background: '#607d8b' | ||
}}> | ||
<button onClick={() => setEnabled()}> | ||
Fireworks {enabled ? 'enabled' : 'disabled'} | ||
</button> | ||
<button onClick={() => toggleSound()}> | ||
Sound {options.sound!.enable ? 'enabled' : 'disabled'} | ||
</button> | ||
</div> | ||
</Fireworks> | ||
) | ||
} |
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 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
Oops, something went wrong.