Files
rabbit/src/hooks/useModalState.ts
2023-05-08 19:58:59 +09:00

41 lines
935 B
TypeScript

import { createSignal } from 'solid-js';
type ModalState =
| { type: 'Profile'; pubkey: string }
| { type: 'ProfileEdit' }
| { type: 'UserTimeline'; pubkey: string }
| { type: 'AddColumn' }
| { type: 'About' }
| { type: 'Closed' };
const [modalState, setModalState] = createSignal<ModalState>({ type: 'Closed' });
const useModalState = () => {
const showProfile = (pubkey: string) => {
setModalState({ type: 'Profile', pubkey });
};
const showProfileEdit = () => {
setModalState({ type: 'ProfileEdit' });
};
const showAddColumn = () => {
setModalState({ type: 'AddColumn' });
};
const showAbout = () => {
setModalState({ type: 'About' });
};
const closeModal = () => {
setModalState({ type: 'Closed' });
};
return {
modalState,
setModalState,
showProfile,
showProfileEdit,
showAddColumn,
showAbout,
closeModal,
};
};
export default useModalState;