Create modal component and store

This commit is contained in:
Ilja 2022-02-07 15:34:36 +02:00
parent d4f6d53a7d
commit 35947268a0
3 changed files with 50 additions and 0 deletions

View File

@ -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 (
<NextModal open={open} onClose={ModalStore.close}>
<NextModal.Header></NextModal.Header>
<NextModal.Body></NextModal.Body>
<NextModal.Footer></NextModal.Footer>
</NextModal>
)
}

View File

@ -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) {
<Layout initialized={initialized}>
<Component {...pageProps} />
</Layout>
<Modal />
</NextUIProvider>
</ThemeProvider>
)

View File

@ -0,0 +1,32 @@
import { proxy } from 'valtio'
/**
* Types
*/
interface State {
open: boolean
}
/**
* State
*/
const state = proxy<State>({
open: false
})
/**
* Store / Actions
*/
const ModalStore = {
state,
open() {
state.open = true
},
close() {
state.open = false
}
}
export default ModalStore