mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-26 05:16:41 +07:00
removed PhotoSwipeStore
This commit is contained in:
parent
224c27b6f4
commit
82308d2a91
15 changed files with 90 additions and 84 deletions
|
@ -1,13 +1,24 @@
|
|||
import { useModalStore } from '~/store/modal/useModalStore';
|
||||
import { useCallback } from 'react';
|
||||
import { Dialog } from '~/constants/modal';
|
||||
import { FC, useCallback, VFC } from 'react';
|
||||
import { Dialog, DIALOG_CONTENT } from '~/constants/modal';
|
||||
import { IDialogProps } from '~/types/modal';
|
||||
|
||||
export type DialogContentProps = {
|
||||
[K in keyof typeof DIALOG_CONTENT]: typeof DIALOG_CONTENT[K] extends (props: infer U) => any
|
||||
? U extends IDialogProps
|
||||
? keyof Omit<U, 'onRequestClose' | 'children'> extends never
|
||||
? {}
|
||||
: Omit<U, 'onRequestClose' | 'children'>
|
||||
: {}
|
||||
: {};
|
||||
};
|
||||
|
||||
export const useModal = () => {
|
||||
const { setCurrent, hide } = useModalStore();
|
||||
|
||||
const showModal = useCallback(
|
||||
(dialog: Dialog) => {
|
||||
setCurrent(dialog);
|
||||
<T extends Dialog>(dialog: T, props: DialogContentProps[T]) => {
|
||||
setCurrent(dialog, props);
|
||||
},
|
||||
[setCurrent]
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue