From 35947268a06e2c6d54f2cc25432ed217a2c25fd7 Mon Sep 17 00:00:00 2001 From: Ilja Date: Mon, 7 Feb 2022 15:34:36 +0200 Subject: [PATCH] Create modal component and store --- .../react-wallet-v2/src/components/Modal.tsx | 15 +++++++++ wallets/react-wallet-v2/src/pages/_app.tsx | 3 ++ .../react-wallet-v2/src/store/ModalStore.ts | 32 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 wallets/react-wallet-v2/src/components/Modal.tsx create mode 100644 wallets/react-wallet-v2/src/store/ModalStore.ts diff --git a/wallets/react-wallet-v2/src/components/Modal.tsx b/wallets/react-wallet-v2/src/components/Modal.tsx new file mode 100644 index 0000000..9769432 --- /dev/null +++ b/wallets/react-wallet-v2/src/components/Modal.tsx @@ -0,0 +1,15 @@ +import ModalStore from '@/store/ModalStore' +import { Modal as NextModal } from '@nextui-org/react' +import { useSnapshot } from 'valtio' + +export default function Modal() { + const { open } = useSnapshot(ModalStore.state) + + return ( + + + + + + ) +} diff --git a/wallets/react-wallet-v2/src/pages/_app.tsx b/wallets/react-wallet-v2/src/pages/_app.tsx index 921b993..20581a7 100644 --- a/wallets/react-wallet-v2/src/pages/_app.tsx +++ b/wallets/react-wallet-v2/src/pages/_app.tsx @@ -1,4 +1,5 @@ import Layout from '@/components/Layout' +import Modal from '@/components/Modal' import useInitialization from '@/hooks/useInitialization' import useWalletConnectEventsManager from '@/hooks/useWalletConnectEventsManager' import { darkTheme, lightTheme } from '@/utils/ThemeUtil' @@ -26,6 +27,8 @@ export default function App({ Component, pageProps }: AppProps) { + + ) diff --git a/wallets/react-wallet-v2/src/store/ModalStore.ts b/wallets/react-wallet-v2/src/store/ModalStore.ts new file mode 100644 index 0000000..da0a18c --- /dev/null +++ b/wallets/react-wallet-v2/src/store/ModalStore.ts @@ -0,0 +1,32 @@ +import { proxy } from 'valtio' + +/** + * Types + */ +interface State { + open: boolean +} + +/** + * State + */ +const state = proxy({ + open: false +}) + +/** + * Store / Actions + */ +const ModalStore = { + state, + + open() { + state.open = true + }, + + close() { + state.open = false + } +} + +export default ModalStore