1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

all successes need confetti

This commit is contained in:
Matthias Kretschmann 2020-10-16 10:00:16 +02:00
parent c72e01c9ec
commit f33b3bb023
Signed by: m
GPG Key ID: 606EEEF3C479A91F
5 changed files with 38 additions and 32 deletions

View File

@ -0,0 +1,4 @@
.action {
text-align: center;
display: block;
}

View File

@ -1,8 +1,7 @@
import Alert from '../../atoms/Alert' import Alert from './Alert'
import Button from '../../atoms/Button' import React, { ReactElement, ReactNode, useEffect } from 'react'
import React, { ReactElement, useEffect } from 'react'
import { confetti } from 'dom-confetti' import { confetti } from 'dom-confetti'
import styles from './Success.module.css' import styles from './SuccessConfetti.module.css'
const confettiConfig = { const confettiConfig = {
angle: 90, angle: 90,
@ -24,33 +23,29 @@ const confettiConfig = {
] ]
} }
export default function Success({ export default function SuccessConfetti({
success, success,
did action
}: { }: {
success: string success: string
did: string action: ReactNode
}): ReactElement { }): ReactElement {
// Have some confetti upon success // Have some confetti upon success
useEffect(() => { useEffect(() => {
if (!success || typeof window === 'undefined') return if (!success || typeof window === 'undefined') return
const startElement: HTMLElement = document.querySelector('a[data-confetti]') const startElement: HTMLElement = document.querySelector(
'span[data-confetti]'
)
confetti(startElement, confettiConfig) confetti(startElement, confettiConfig)
}, [success]) }, [success])
return ( return (
<> <>
<Alert text={success} state="success" /> <Alert text={success} state="success" />
<Button <span className={styles.action} data-confetti>
style="primary" {action}
size="small" </span>
href={`/asset/${did}`}
className={styles.action}
data-confetti
>
Go to data set
</Button>
</> </>
) )
} }

View File

@ -1,9 +1,9 @@
import React, { ReactElement } from 'react' import React, { ReactElement } from 'react'
import Loader from '../../../atoms/Loader' import Loader from '../../../atoms/Loader'
import Button from '../../../atoms/Button' import Button from '../../../atoms/Button'
import Alert from '../../../atoms/Alert'
import styles from './Actions.module.css' import styles from './Actions.module.css'
import EtherscanLink from '../../../atoms/EtherscanLink' import EtherscanLink from '../../../atoms/EtherscanLink'
import SuccessConfetti from '../../../atoms/SuccessConfetti'
export default function Actions({ export default function Actions({
isLoading, isLoading,
@ -30,15 +30,14 @@ export default function Actions({
)} )}
</div> </div>
{txId && ( {txId && (
<> <SuccessConfetti
<Alert success="Successfully added liquidity."
text={`Successfully added liquidity. Transaction ID: ${txId}`} action={
state="success" <EtherscanLink network="rinkeby" path={`/tx/${txId}`}>
/> See on Etherscan
<EtherscanLink network="rinkeby" path={`/tx/${txId}`}> </EtherscanLink>
Etherscan }
</EtherscanLink> />
</>
)} )}
</> </>
) )

View File

@ -1,9 +1,9 @@
import Alert from '../../atoms/Alert' import Alert from '../../atoms/Alert'
import Success from './Success'
import Button from '../../atoms/Button' import Button from '../../atoms/Button'
import Loader from '../../atoms/Loader' import Loader from '../../atoms/Loader'
import React, { ReactElement } from 'react' import React, { ReactElement } from 'react'
import styles from './Feedback.module.css' import styles from './Feedback.module.css'
import SuccessConfetti from '../../atoms/SuccessConfetti'
export default function Feedback({ export default function Feedback({
error, error,
@ -18,6 +18,17 @@ export default function Feedback({
publishStepText: string publishStepText: string
setError: (error: string) => void setError: (error: string) => void
}): ReactElement { }): ReactElement {
const SuccessAction = () => (
<Button
style="primary"
size="small"
href={`/asset/${did}`}
className={styles.action}
>
Go to data set
</Button>
)
return ( return (
<div className={styles.feedback}> <div className={styles.feedback}>
<div className={styles.box}> <div className={styles.box}>
@ -35,7 +46,7 @@ export default function Feedback({
</Button> </Button>
</> </>
) : success ? ( ) : success ? (
<Success success={success} did={did} /> <SuccessConfetti success={success} action={<SuccessAction />} />
) : ( ) : (
<Loader message={publishStepText} /> <Loader message={publishStepText} />
)} )}

View File

@ -1,3 +0,0 @@
.action {
margin-top: calc(var(--spacer) / 1.5);
}