WIP
This commit is contained in:
parent
ae71f5ce84
commit
76c584d981
6 changed files with 163 additions and 1 deletions
53
src/components/dialogs/nudges/index.tsx
Normal file
53
src/components/dialogs/nudges/index.tsx
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import React from 'react'
|
||||
|
||||
import * as Dialog from '#/components/Dialog'
|
||||
|
||||
import {TenMillion} from '#/components/dialogs/nudges/TenMillion'
|
||||
|
||||
type Context = {
|
||||
controls: {
|
||||
tenMillion: Dialog.DialogOuterProps['control']
|
||||
}
|
||||
}
|
||||
|
||||
const Context = React.createContext<Context>({
|
||||
// @ts-ignore
|
||||
controls: {}
|
||||
})
|
||||
|
||||
export function useContext() {
|
||||
return React.useContext(Context)
|
||||
}
|
||||
|
||||
let SHOWN = false
|
||||
|
||||
export function NudgeDialogs() {
|
||||
const tenMillion = Dialog.useDialogControl()
|
||||
|
||||
const ctx = React.useMemo(() => {
|
||||
return {
|
||||
controls: {
|
||||
tenMillion
|
||||
}
|
||||
}
|
||||
}, [tenMillion])
|
||||
|
||||
React.useEffect(() => {
|
||||
const t = setTimeout(() => {
|
||||
if (!SHOWN) {
|
||||
SHOWN = true
|
||||
ctx.controls.tenMillion.open()
|
||||
}
|
||||
}, 2e3)
|
||||
|
||||
return () => {
|
||||
clearTimeout(t)
|
||||
}
|
||||
}, [ctx])
|
||||
|
||||
return (
|
||||
<Context.Provider value={ctx}>
|
||||
<TenMillion />
|
||||
</Context.Provider>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue