From 41d4f29750c4f9de321720a226e22cbeb3240a8e Mon Sep 17 00:00:00 2001 From: lavi <62757958+lavi27@users.noreply.github.com> Date: Fri, 19 Jan 2024 11:36:11 +0900 Subject: [PATCH] =?UTF-8?q?style:=20modal=20=EA=B8=B0=EB=8A=A5=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81=20=EB=B0=8F=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=EC=B6=94=EB=A1=A0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composables/useModal.ts | 28 +++++++++++++++++++++++ layouts/modal.vue | 14 ++++++------ pages/dashboard/invite.vue | 45 ++++++++++++++----------------------- pages/dashboard/members.vue | 36 +++++++++++------------------ pages/dashboard/verify.vue | 29 +++++++++--------------- utils/types.ts | 18 +++++++++++++++ 6 files changed, 94 insertions(+), 76 deletions(-) create mode 100644 composables/useModal.ts create mode 100644 utils/types.ts diff --git a/composables/useModal.ts b/composables/useModal.ts new file mode 100644 index 0000000..22dc2a0 --- /dev/null +++ b/composables/useModal.ts @@ -0,0 +1,28 @@ +import type { Cast, MyExtract, ArrayElement } from '~/utils/types' + +export default (modalNames: T) => { + type ModalName = ArrayElement + + const modalsIsShow = useState>('useModal', () => { + return Object.keys(modalNames).reduce((acc, name) => { + acc[name as ModalName] = false + return acc + }, {} as Record) + }) + + const modalShow = (name: ModalName) => { + modalsIsShow.value[name] = true + } + + const modalClose = (name: ModalName) => { + modalsIsShow.value[name] = false + } + + const modalShowAndClose = async (name: ModalName, waitMs: number) => { + modalsIsShow.value[name] = true + await wait(waitMs) + modalsIsShow.value[name] = false + } + + return { modalsIsShow, modalShow, modalClose, modalShowAndClose } +} diff --git a/layouts/modal.vue b/layouts/modal.vue index 2798218..ca8073f 100644 --- a/layouts/modal.vue +++ b/layouts/modal.vue @@ -1,14 +1,14 @@