-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: show holiday header during December * add winter background * feat: snow on the home screen * specify a low number of pieces to keep CPU from getting fried Co-authored-by: Jeremy Kahn <[email protected]>
- Loading branch information
1 parent
1e2c9c8
commit 8ea81c0
Showing
9 changed files
with
534 additions
and
19 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
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,44 @@ | ||
import React from 'react' | ||
import useWindowSize from 'react-use/lib/useWindowSize' | ||
import Confetti from 'react-confetti' | ||
|
||
const randomInt = (min: number, max: number) => { | ||
return Math.floor(min + Math.random() * (max - min + 1)) | ||
} | ||
|
||
// Taken from: | ||
// https://github.com/alampros/react-confetti/blob/484bad0a0aaddbcfcc2fb4c1a4a7eeceaa6d4879/stories/snow.story.jsx#L7-L24 | ||
const drawSnowflake = function(ctx) { | ||
const numPoints = this.numPoints || randomInt(3, 4) * 2 | ||
this.numPoints = numPoints | ||
const innerRadius = this.radius * 0.2 | ||
const outerRadius = this.radius * 0.8 | ||
ctx.beginPath() | ||
ctx.moveTo(0, 0 - outerRadius) | ||
|
||
for (let n = 1; n < numPoints * 2; n++) { | ||
const radius = n % 2 === 0 ? outerRadius : innerRadius | ||
const x = radius * Math.sin((n * Math.PI) / numPoints) | ||
const y = -1 * radius * Math.cos((n * Math.PI) / numPoints) | ||
ctx.lineTo(x, y) | ||
} | ||
ctx.fill() | ||
ctx.stroke() | ||
ctx.closePath() | ||
} | ||
|
||
export const SnowBackground = () => { | ||
const { width, height } = useWindowSize() | ||
return ( | ||
<Confetti | ||
style={{ position: 'fixed' }} | ||
width={width} | ||
height={height} | ||
drawShape={drawSnowflake} | ||
colors={['#FFFFFF', '#CBDDF8']} | ||
gravity={0.03} | ||
numberOfPieces={10} | ||
wind={0.01} | ||
/> | ||
) | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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