mirror of
https://github.com/aljazceru/rabbit.git
synced 2025-12-18 06:24:25 +01:00
46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
import { createRoot, createSignal } from 'solid-js';
|
|
|
|
type ModalState =
|
|
| { type: 'Login' }
|
|
| { type: 'Profile'; pubkey: string }
|
|
| { type: 'ProfileEdit' }
|
|
| { type: 'UserTimeline'; pubkey: string }
|
|
| { type: 'AddColumn' }
|
|
| { type: 'About' }
|
|
| { type: 'Closed' };
|
|
|
|
const [modalState, setModalState] = createRoot(() => createSignal<ModalState>({ type: 'Closed' }));
|
|
|
|
const useModalState = () => {
|
|
const showLogin = () => {
|
|
setModalState({ type: 'Login' });
|
|
};
|
|
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,
|
|
showLogin,
|
|
showProfile,
|
|
showProfileEdit,
|
|
showAddColumn,
|
|
showAbout,
|
|
closeModal,
|
|
};
|
|
};
|
|
|
|
export default useModalState;
|