27 lines
951 B
TypeScript
27 lines
951 B
TypeScript
/* Shared open state for the sign-in popup (AuthModal.vue), shaped like
|
|
useSearch and useSettings. The account row in the sidebar, the gate on the
|
|
editor pages and the editor itself all reach the popup through this, so only
|
|
one is ever on screen. */
|
|
|
|
export type SignInMode = 'signin' | 'signup'
|
|
|
|
export function useSignInPopup() {
|
|
const open = useState<boolean>('signin:open', () => false)
|
|
const mode = useState<SignInMode>('signin:mode', () => 'signin')
|
|
/* Why the popup was opened — shown above the form when a session has just
|
|
expired mid-edit, so the person knows what happened to their save. */
|
|
const notice = useState<string>('signin:notice', () => '')
|
|
|
|
function show(opts: { mode?: SignInMode; notice?: string } = {}) {
|
|
mode.value = opts.mode ?? 'signin'
|
|
notice.value = opts.notice ?? ''
|
|
open.value = true
|
|
}
|
|
|
|
function hide() {
|
|
open.value = false
|
|
}
|
|
|
|
return { open, mode, notice, show, hide }
|
|
}
|