mirror of
https://github.com/aljazceru/rabbit.git
synced 2025-12-17 05:54:19 +01:00
41 lines
935 B
TypeScript
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;
|