mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Unified pop-up modals and out-click close behaviour
This commit is contained in:
1 parent
65fbc775ce
commit
4fdb2b7ce1
28 files changed
+234
-319
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api } from '../api'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Settings → Konduktor: preferences about the app itself rather than about a
|
||||
@@ -42,12 +42,6 @@ export function AppSettings({ onClose }: { onClose: () => void }) {
|
||||
const levelCeiling = useAppSetting('levelCeiling')
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose()
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [onClose])
|
||||
|
||||
const set = async (patch: Partial<typeof APP_SETTING_DEFAULTS>) => {
|
||||
setError(null)
|
||||
try {
|
||||
@@ -57,13 +51,9 @@ export function AppSettings({ onClose }: { onClose: () => void }) {
|
||||
}
|
||||
}
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-6 backdrop-blur-[3px]"
|
||||
onClick={onClose}
|
||||
>
|
||||
<div className="flex w-full max-w-md flex-col overflow-hidden glass-overlay" onClick={(e) => e.stopPropagation()}>
|
||||
return (
|
||||
<Modal onDismiss={onClose}>
|
||||
<div className="flex w-full max-w-md flex-col overflow-hidden glass-overlay">
|
||||
<div className="flex items-center justify-between border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">Konduktor settings</h2>
|
||||
<button onClick={onClose} className="rounded px-1.5 text-faint hover:text-text" aria-label="Close">
|
||||
@@ -166,8 +156,7 @@ export function AppSettings({ onClose }: { onClose: () => void }) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user