diff options
author | Eric Bailey <git@esb.lol> | 2024-09-09 20:57:32 -0500 |
---|---|---|
committer | Eric Bailey <git@esb.lol> | 2024-09-11 19:58:16 -0500 |
commit | 76c584d981f195a580e132b786e101b3d0d32380 (patch) | |
tree | 6b03b716dbab72a834e9b89ec67b7b3aefcf6c90 /src/components/dialogs/nudges/index.tsx | |
parent | ae71f5ce84165b683b880c4a585b5a617f2c36bb (diff) | |
download | voidsky-76c584d981f195a580e132b786e101b3d0d32380.tar.zst |
WIP
Diffstat (limited to 'src/components/dialogs/nudges/index.tsx')
-rw-r--r-- | src/components/dialogs/nudges/index.tsx | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/components/dialogs/nudges/index.tsx b/src/components/dialogs/nudges/index.tsx new file mode 100644 index 000000000..357d4e2b4 --- /dev/null +++ b/src/components/dialogs/nudges/index.tsx @@ -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> + ) +} |