Componentize confetti to isolate re-renders due to window size (#740)
* Componentize confetti to isolate re-renders due to window size * Clean up debug logging
This commit is contained in:
parent
b9f347b7f4
commit
4e8b94a28c
7
web/components/fullscreen-confetti.tsx
Normal file
7
web/components/fullscreen-confetti.tsx
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import Confetti, { Props as ConfettiProps } from 'react-confetti'
|
||||||
|
import { useWindowSize } from 'web/hooks/use-window-size'
|
||||||
|
|
||||||
|
export function FullscreenConfetti(props: ConfettiProps) {
|
||||||
|
const { width, height } = useWindowSize()
|
||||||
|
return <Confetti {...props} width={width} height={height} />
|
||||||
|
}
|
|
@ -4,7 +4,6 @@ import { useEffect, useState } from 'react'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { LinkIcon } from '@heroicons/react/solid'
|
import { LinkIcon } from '@heroicons/react/solid'
|
||||||
import { PencilIcon } from '@heroicons/react/outline'
|
import { PencilIcon } from '@heroicons/react/outline'
|
||||||
import Confetti from 'react-confetti'
|
|
||||||
|
|
||||||
import { getPortfolioHistory, User } from 'web/lib/firebase/users'
|
import { getPortfolioHistory, User } from 'web/lib/firebase/users'
|
||||||
import { CreatorContractsList } from './contract/contracts-grid'
|
import { CreatorContractsList } from './contract/contracts-grid'
|
||||||
|
@ -19,11 +18,11 @@ import { Row } from './layout/row'
|
||||||
import { genHash } from 'common/util/random'
|
import { genHash } from 'common/util/random'
|
||||||
import { QueryUncontrolledTabs } from './layout/tabs'
|
import { QueryUncontrolledTabs } from './layout/tabs'
|
||||||
import { UserCommentsList } from './comments-list'
|
import { UserCommentsList } from './comments-list'
|
||||||
import { useWindowSize } from 'web/hooks/use-window-size'
|
|
||||||
import { Comment, getUsersComments } from 'web/lib/firebase/comments'
|
import { Comment, getUsersComments } from 'web/lib/firebase/comments'
|
||||||
import { Contract } from 'common/contract'
|
import { Contract } from 'common/contract'
|
||||||
import { getContractFromId, listContracts } from 'web/lib/firebase/contracts'
|
import { getContractFromId, listContracts } from 'web/lib/firebase/contracts'
|
||||||
import { LoadingIndicator } from './loading-indicator'
|
import { LoadingIndicator } from './loading-indicator'
|
||||||
|
import { FullscreenConfetti } from 'web/components/fullscreen-confetti'
|
||||||
import { BetsList } from './bets-list'
|
import { BetsList } from './bets-list'
|
||||||
import { FollowersButton, FollowingButton } from './following-button'
|
import { FollowersButton, FollowingButton } from './following-button'
|
||||||
import { UserFollowButton } from './follow-button'
|
import { UserFollowButton } from './follow-button'
|
||||||
|
@ -82,7 +81,6 @@ export function UserPage(props: { user: User; currentUser?: User }) {
|
||||||
Dictionary<Contract> | undefined
|
Dictionary<Contract> | undefined
|
||||||
>()
|
>()
|
||||||
const [showConfetti, setShowConfetti] = useState(false)
|
const [showConfetti, setShowConfetti] = useState(false)
|
||||||
const { width, height } = useWindowSize()
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const claimedMana = router.query['claimed-mana'] === 'yes'
|
const claimedMana = router.query['claimed-mana'] === 'yes'
|
||||||
|
@ -124,12 +122,7 @@ export function UserPage(props: { user: User; currentUser?: User }) {
|
||||||
url={`/${user.username}`}
|
url={`/${user.username}`}
|
||||||
/>
|
/>
|
||||||
{showConfetti && (
|
{showConfetti && (
|
||||||
<Confetti
|
<FullscreenConfetti recycle={false} numberOfPieces={300} />
|
||||||
width={width ? width : 500}
|
|
||||||
height={height ? height : 500}
|
|
||||||
recycle={false}
|
|
||||||
numberOfPieces={300}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
{/* Banner image up top, with an circle avatar overlaid */}
|
{/* Banner image up top, with an circle avatar overlaid */}
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -25,8 +25,7 @@ import { Leaderboard } from 'web/components/leaderboard'
|
||||||
import { resolvedPayout } from 'common/calculate'
|
import { resolvedPayout } from 'common/calculate'
|
||||||
import { formatMoney } from 'common/util/format'
|
import { formatMoney } from 'common/util/format'
|
||||||
import { ContractTabs } from 'web/components/contract/contract-tabs'
|
import { ContractTabs } from 'web/components/contract/contract-tabs'
|
||||||
import { useWindowSize } from 'web/hooks/use-window-size'
|
import { FullscreenConfetti } from 'web/components/fullscreen-confetti'
|
||||||
import Confetti from 'react-confetti'
|
|
||||||
import { NumericBetPanel } from 'web/components/numeric-bet-panel'
|
import { NumericBetPanel } from 'web/components/numeric-bet-panel'
|
||||||
import { NumericResolutionPanel } from 'web/components/numeric-resolution-panel'
|
import { NumericResolutionPanel } from 'web/components/numeric-resolution-panel'
|
||||||
import { useIsIframe } from 'web/hooks/use-is-iframe'
|
import { useIsIframe } from 'web/hooks/use-is-iframe'
|
||||||
|
@ -166,8 +165,6 @@ export function ContractPageContent(
|
||||||
|
|
||||||
const tips = useTipTxns({ contractId: contract.id })
|
const tips = useTipTxns({ contractId: contract.id })
|
||||||
|
|
||||||
const { width, height } = useWindowSize()
|
|
||||||
|
|
||||||
const [showConfetti, setShowConfetti] = useState(false)
|
const [showConfetti, setShowConfetti] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -194,12 +191,7 @@ export function ContractPageContent(
|
||||||
return (
|
return (
|
||||||
<Page rightSidebar={rightSidebar}>
|
<Page rightSidebar={rightSidebar}>
|
||||||
{showConfetti && (
|
{showConfetti && (
|
||||||
<Confetti
|
<FullscreenConfetti recycle={false} numberOfPieces={300} />
|
||||||
width={width ? width : 500}
|
|
||||||
height={height ? height : 500}
|
|
||||||
recycle={false}
|
|
||||||
numberOfPieces={300}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{ogCardProps && (
|
{ogCardProps && (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user