mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 18:22:53 +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
@@ -2132,6 +2132,18 @@ frontend at `http://localhost:5173`.
|
||||
`ConfirmDialog` by the `ConfirmHost` mounted once in `main.tsx`. `tone` is
|
||||
`danger` (default, pink) or `primary`. Components that already hold dialog
|
||||
state may still render `ConfirmDialog` directly.
|
||||
- **Every dialog is a `<Modal>`** (`components/Modal.tsx`; decided 2026-11-02):
|
||||
the portal, backdrop, `aria-modal`, Esc and outside click in ONE place —
|
||||
never a hand-rolled backdrop or a per-dialog Esc listener. `onDismiss` is
|
||||
what the dialog's Cancel / Close (or Hide, while a job runs) does, `null`
|
||||
while that is unavailable (busy): Esc and the backdrop then do nothing. An
|
||||
outside click closes only when the press AND the release are both on the
|
||||
backdrop — a plain `onClick` fires on the common ancestor, so a text
|
||||
selection dragged out of the dialog closed it. Esc reaches only the TOP
|
||||
modal (by opening order) and never while a menu is open. `layer="nested"`
|
||||
= `z-[60]` (a dialog opened from a dialog, QuitGuard). The one exception is
|
||||
`RelocateDialog`'s `backdropDismiss={false}` (Esc only: "Not now" lasts
|
||||
until the library is reopened).
|
||||
|
||||
## Theme — "dark liquid glass"
|
||||
|
||||
@@ -2156,7 +2168,7 @@ easy to break:
|
||||
opened far from the cursor. `.glass`'s blur and tint therefore live on its
|
||||
`::after` (z-index -1 under `isolation: isolate`), not on the panel.
|
||||
- **Every overlay renders through `createPortal(…, document.body)`** — all
|
||||
dialogs, `ContextMenu` and `Toast`. Each `.glass` panel is a stacking context
|
||||
dialogs (via `Modal`), `ContextMenu` and `Toast`. Each `.glass` panel is a stacking context
|
||||
(`isolation`), so an overlay rendered INSIDE one can never rise above a
|
||||
neighbouring panel, whatever its z-index: New Export (from the sidebar) sat
|
||||
behind the library, and the deck's Auto Hotcues dialog behind both. One
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, isServerPath, type FolderAddPreview, type FolderAddRequest, type JobStatus, type TrackOrigin } from '../api'
|
||||
import { useCaps } from '../lib/capabilities'
|
||||
import { placedAudioSummary } from '../lib/platformCopy'
|
||||
import { FolderPicker } from './FolderPicker'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Add browsed files to the collection — and, optionally, to a playlist or export.
|
||||
@@ -253,7 +253,7 @@ export function AddFilesDialog({ trackIds, target: requested, note, onClose, onD
|
||||
</label>
|
||||
)
|
||||
|
||||
return createPortal(
|
||||
return (
|
||||
<>
|
||||
{browsing && (
|
||||
<FolderPicker
|
||||
@@ -267,10 +267,7 @@ export function AddFilesDialog({ trackIds, target: requested, note, onClose, onD
|
||||
onClose={() => setBrowsing(false)}
|
||||
/>
|
||||
)}
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4 backdrop-blur-[3px]"
|
||||
>
|
||||
<Modal onDismiss={onClose} padding="p-4">
|
||||
<div className="w-full max-w-lg glass-overlay">
|
||||
<div className="border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">{title}</h2>
|
||||
@@ -461,9 +458,8 @@ export function AddFilesDialog({ trackIds, target: requested, note, onClose, onD
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
document.body,
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState, type ReactNode } from 'react'
|
||||
import { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type AnalyzeOptions, type AnalyzePreview, type TrackOrigin } from '../api'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
/** The selected tracks. */
|
||||
@@ -100,12 +100,6 @@ export function AnalyzeDialog({ ids, origin, gridWhy, keyWhy, gainWhy, preset, o
|
||||
const nothingTicked = !!what && !(what.bpm || what.grid || what.key || what.loudness || what.gain)
|
||||
const count = nothingTicked ? 0 : (p?.tracks_to_analyze ?? 0)
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && !busy && onClose()
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [busy, onClose])
|
||||
|
||||
const run = async () => {
|
||||
if (!opts || busy || count === 0) return
|
||||
setBusy(true)
|
||||
@@ -186,13 +180,9 @@ export function AnalyzeDialog({ ids, origin, gridWhy, keyWhy, gainWhy, preset, o
|
||||
if (p.grid_locked) gridLines.push(<div key="lk" className="text-faint">{plural(p.grid_locked, 'locked grid')} — skipped</div>)
|
||||
}
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={() => !busy && onClose()}
|
||||
>
|
||||
<div className="w-full max-w-sm overflow-hidden glass-overlay" onClick={(e) => e.stopPropagation()}>
|
||||
return (
|
||||
<Modal onDismiss={busy ? null : onClose}>
|
||||
<div className="w-full max-w-sm overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Analyze</div>
|
||||
<div className="text-xs text-muted">{plural(ids.length, 'track')} selected</div>
|
||||
@@ -265,7 +255,6 @@ export function AnalyzeDialog({ ids, origin, gridWhy, keyWhy, gainWhy, preset, o
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import {
|
||||
@@ -10,6 +9,7 @@ import {
|
||||
type Track,
|
||||
} from '../api'
|
||||
import { formatDuration } from '../lib/format'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Auto Hotcues: bind each hotcue slot to a structural event plus an offset in
|
||||
@@ -109,14 +109,6 @@ export function AutoCueDialog(props: Props) {
|
||||
if (rows === null && (prefs.data || prefs.isError)) setRows(loadTemplate(prefs.data, slotCount))
|
||||
}, [prefs.data, prefs.isError, rows, slotCount])
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape' && !busy) onClose()
|
||||
}
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [busy, onClose])
|
||||
|
||||
const setRow = (i: number, patch: Partial<Row>) =>
|
||||
setRows((rs) => rs && rs.map((r, j) => (j === i ? { ...r, ...patch } : r)))
|
||||
const nudge = (i: number, by: number) =>
|
||||
@@ -152,11 +144,10 @@ export function AutoCueDialog(props: Props) {
|
||||
}
|
||||
}
|
||||
|
||||
return createPortal(
|
||||
<div aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6" onClick={() => !busy && onClose()}>
|
||||
return (
|
||||
<Modal onDismiss={busy ? null : onClose}>
|
||||
<div
|
||||
className="flex max-h-[85vh] w-full max-w-xl flex-col overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Auto Hotcues</div>
|
||||
@@ -294,7 +285,6 @@ export function AutoCueDialog(props: Props) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState, type ReactNode } from 'react'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
export interface ConfirmRequest {
|
||||
title: string
|
||||
@@ -42,7 +42,6 @@ export function ConfirmDialog({ title, body, confirmLabel, tone = 'danger', altL
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape' && !busy) onClose()
|
||||
// A focused button handles its own Enter — otherwise tabbing to Cancel
|
||||
// and pressing Enter would run the destructive action.
|
||||
if (e.key === 'Enter' && !(e.target instanceof HTMLButtonElement)) {
|
||||
@@ -54,16 +53,9 @@ export function ConfirmDialog({ title, body, confirmLabel, tone = 'danger', altL
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
})
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={() => !busy && onClose()}
|
||||
>
|
||||
<div
|
||||
className="w-full max-w-sm overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={busy ? null : onClose}>
|
||||
<div className="w-full max-w-sm overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-4 text-[15px] font-semibold tracking-tight">
|
||||
{title}
|
||||
</div>
|
||||
@@ -101,7 +93,6 @@ export function ConfirmDialog({ title, body, confirmLabel, tone = 'danger', altL
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useMemo, useState, type ReactNode } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import {
|
||||
@@ -12,6 +11,7 @@ import {
|
||||
import { FolderPicker } from './FolderPicker'
|
||||
import { useServerFolder } from './AddFilesDialog'
|
||||
import { useCaps } from '../lib/capabilities'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Convert to Stems — one dialog (decided, see the stem-conversion discussion
|
||||
@@ -224,7 +224,7 @@ export function ConvertStemsDialog({ trackIds, onClose, onStarted, onDownloading
|
||||
)
|
||||
|
||||
const count = trackIds.length
|
||||
return createPortal(
|
||||
return (
|
||||
<>
|
||||
{browsing && opts && (
|
||||
<FolderPicker
|
||||
@@ -239,11 +239,7 @@ export function ConvertStemsDialog({ trackIds, onClose, onStarted, onDownloading
|
||||
onClose={() => setBrowsing(false)}
|
||||
/>
|
||||
)}
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4 backdrop-blur-[3px]"
|
||||
onKeyDown={(e) => e.key === 'Escape' && !starting && onClose()}
|
||||
>
|
||||
<Modal onDismiss={starting ? null : onClose} padding="p-4">
|
||||
<div className="flex max-h-[90vh] w-full max-w-lg flex-col overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">
|
||||
@@ -477,8 +473,7 @@ export function ConvertStemsDialog({ trackIds, onClose, onStarted, onDownloading
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
document.body,
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useRef, useState } from 'react'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type Track } from '../api'
|
||||
@@ -7,6 +6,7 @@ import { useCaps } from '../lib/capabilities'
|
||||
import { RatingStars } from './RatingStars'
|
||||
import { writeHint } from '../lib/platformCopy'
|
||||
import { invalidateTrackLists } from '../lib/trackQueries'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
track: Track
|
||||
@@ -96,14 +96,10 @@ export function EditTagsDialog({ track, onClose, onApplied, onError }: Props) {
|
||||
apply.mutate()
|
||||
}
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={onClose}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={onClose}>
|
||||
<div
|
||||
className="flex max-h-[85vh] w-full max-w-lg flex-col overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Edit Tags</div>
|
||||
@@ -240,7 +236,6 @@ export function EditTagsDialog({ track, onClose, onApplied, onError }: Props) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useState } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { api, type ExportSet, type LocalLibrary } from '../api'
|
||||
import { localLibraryProblem } from '../lib/platformCopy'
|
||||
import { FolderPicker } from './FolderPicker'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Create or edit an export: its name, its target platforms and where it lands.
|
||||
@@ -119,7 +119,7 @@ export function ExportDialog({ editing, onClose, onSaved, onError }: Props) {
|
||||
}
|
||||
}
|
||||
|
||||
return createPortal(
|
||||
return (
|
||||
<>
|
||||
{browsing && (
|
||||
<FolderPicker
|
||||
@@ -128,7 +128,7 @@ export function ExportDialog({ editing, onClose, onSaved, onError }: Props) {
|
||||
onClose={() => setBrowsing(false)}
|
||||
/>
|
||||
)}
|
||||
<div aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-4">
|
||||
<Modal onDismiss={onClose} padding="p-4">
|
||||
<div className="w-full max-w-lg glass-overlay">
|
||||
<div className="border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">
|
||||
@@ -336,8 +336,7 @@ export function ExportDialog({ editing, onClose, onSaved, onError }: Props) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
document.body,
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type ExportPreview, type ExportRunOptions, type ExportSet, type JobStatus, type NormalizeOptions } from '../api'
|
||||
import { FolderPicker } from './FolderPicker'
|
||||
import { LevelInput, useAppSetting } from './AppSettings'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Run an export: confirm what is about to happen, then watch it happen.
|
||||
@@ -175,7 +175,7 @@ export function ExportRunDialog({ set, onClose, onDone, onError }: Props) {
|
||||
: null
|
||||
const blocked = p?.blocked ?? null
|
||||
|
||||
return createPortal(
|
||||
return (
|
||||
<>
|
||||
{browsing && (
|
||||
<FolderPicker
|
||||
@@ -184,7 +184,7 @@ export function ExportRunDialog({ set, onClose, onDone, onError }: Props) {
|
||||
onClose={() => setBrowsing(false)}
|
||||
/>
|
||||
)}
|
||||
<div aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-4">
|
||||
<Modal onDismiss={onClose} padding="p-4">
|
||||
<div className="w-full max-w-lg glass-overlay">
|
||||
<div className="border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">Export “{set.name}”</h2>
|
||||
@@ -472,9 +472,8 @@ export function ExportRunDialog({ set, onClose, onDone, onError }: Props) {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
document.body,
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useState } from 'react'
|
||||
import { FileBrowser, useFsListing, type Listing } from './FileBrowser'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Pick a FOLDER, by browsing.
|
||||
@@ -33,8 +33,8 @@ export function FolderPicker({ value, onChange, onClose, listing = 'host' }: Pro
|
||||
onClose()
|
||||
}
|
||||
|
||||
return createPortal(
|
||||
<div aria-modal="true" className="fixed inset-0 z-[60] flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-4">
|
||||
return (
|
||||
<Modal onDismiss={onClose} layer="nested" padding="p-4">
|
||||
<div className="flex h-[70vh] w-full max-w-2xl flex-col overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">Choose a folder</h2>
|
||||
@@ -84,7 +84,6 @@ export function FolderPicker({ value, onChange, onClose, listing = 'host' }: Pro
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useState } from 'react'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type HistoryEntry } from '../api'
|
||||
import { useCaps } from '../lib/capabilities'
|
||||
import { restoreWarning } from '../lib/platformCopy'
|
||||
import type { ToastMsg } from './Toast'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
onClose: () => void
|
||||
@@ -79,14 +79,10 @@ export function HistoryPanel({ onClose, onNotify, onError }: Props) {
|
||||
|
||||
const entries = history.data ?? []
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={onClose}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={onClose}>
|
||||
<div
|
||||
className="flex max-h-[85vh] w-full max-w-xl flex-col overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Version History</div>
|
||||
@@ -208,7 +204,6 @@ export function HistoryPanel({ onClose, onNotify, onError }: Props) {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type ImportPreview, type JobStatus } from '../api'
|
||||
@@ -7,6 +6,7 @@ import { placedAudioSummary } from '../lib/platformCopy'
|
||||
import type { AddTarget } from './AddFilesDialog'
|
||||
import { FolderPicker } from './FolderPicker'
|
||||
import { useServerImportFolder, usePlaylistToggle } from './AddFilesDialog'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Import a browsed device into the loaded collection.
|
||||
@@ -173,7 +173,7 @@ export function ImportDialog({ playlistId, trackIds, target: requested, deviceLa
|
||||
const finished = job != null && job.state !== 'running'
|
||||
const pct = job && job.total > 0 ? Math.min(100, (job.done / job.total) * 100) : null
|
||||
|
||||
return createPortal(
|
||||
return (
|
||||
<>
|
||||
{browsing && (
|
||||
<FolderPicker
|
||||
@@ -187,7 +187,7 @@ export function ImportDialog({ playlistId, trackIds, target: requested, deviceLa
|
||||
onClose={() => setBrowsing(false)}
|
||||
/>
|
||||
)}
|
||||
<div aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-4">
|
||||
<Modal onDismiss={onClose} padding="p-4">
|
||||
<div className="w-full max-w-lg glass-overlay">
|
||||
<div className="border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">
|
||||
@@ -373,8 +373,7 @@ export function ImportDialog({ playlistId, trackIds, target: requested, deviceLa
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
document.body,
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type NormalizeOptions } from '../api'
|
||||
import { localLibraryProblem } from '../lib/platformCopy'
|
||||
import { FolderPicker } from './FolderPicker'
|
||||
import { LevelInput, useAppSetting } from './AppSettings'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Settings → Local libraries: where a "This computer" set is pushed.
|
||||
@@ -32,12 +32,6 @@ export function LocalLibrariesSettings({ onClose }: { onClose: () => void }) {
|
||||
const [picking, setPicking] = useState<string | null>(null) // a platform, or 'audio'
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && !picking && onClose()
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [onClose, picking])
|
||||
|
||||
const p = prefs.data ?? {}
|
||||
const overrides = (p.localLibraries as Record<string, string | null> | undefined) ?? {}
|
||||
const normalise = p.localNormalise === true
|
||||
@@ -74,17 +68,13 @@ export function LocalLibrariesSettings({ onClose }: { onClose: () => void }) {
|
||||
? d?.audio_root ?? ''
|
||||
: (d?.libraries.find((l) => l.platform === picking)?.path ?? '').replace(/[\\/][^\\/]*$/, '')
|
||||
|
||||
return createPortal(
|
||||
return (
|
||||
<>
|
||||
{picking && (
|
||||
<FolderPicker value={pickerValue} onChange={choose} onClose={() => setPicking(null)} />
|
||||
)}
|
||||
<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 max-h-full w-full max-w-lg flex-col overflow-hidden glass-overlay" onClick={(e) => e.stopPropagation()}>
|
||||
<Modal onDismiss={onClose}>
|
||||
<div className="flex max-h-full w-full max-w-lg 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">Local libraries</h2>
|
||||
<button onClick={onClose} className="rounded px-1.5 text-faint hover:text-text" aria-label="Close">
|
||||
@@ -198,8 +188,7 @@ export function LocalLibrariesSettings({ onClose }: { onClose: () => void }) {
|
||||
{error && <div className="text-xs text-pink">{error}</div>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
document.body,
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState, type AriaRole, type ReactNode } from 'react'
|
||||
|
||||
// Open modals by opening order (taken at first render, so a dialog opened
|
||||
// from another always ranks above it). Esc is answered by the top one only.
|
||||
const open = new Set<number>()
|
||||
let opened = 0
|
||||
|
||||
const menuOpen = () => document.querySelector('[role="menu"]') != null
|
||||
|
||||
interface Props {
|
||||
/** What Esc and a click on the backdrop do: the dialog's Cancel / Close.
|
||||
* `null` while that is not available (a run in progress), so neither
|
||||
* can close the dialog when its own Cancel could not. */
|
||||
onDismiss: (() => void) | null
|
||||
/** `false`: Esc only. For a dialog whose dismissal decides something a
|
||||
* stray click should not (RelocateDialog). */
|
||||
backdropDismiss?: boolean
|
||||
/** `nested` for a dialog opened from a dialog or above every other one. */
|
||||
layer?: 'dialog' | 'nested'
|
||||
/** The backdrop's padding (default `p-6`). */
|
||||
padding?: string
|
||||
role?: AriaRole
|
||||
'aria-label'?: string
|
||||
'aria-labelledby'?: string
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
/** The ONE modal container: portal, dimmed backdrop, Esc and outside click.
|
||||
*
|
||||
* An outside click closes only when the press AND the release are both on
|
||||
* the backdrop. A `click` alone fires on the nearest common ancestor, so a
|
||||
* text selection started inside the dialog and released outside it used to
|
||||
* land on the backdrop and close the dialog. */
|
||||
export function Modal({
|
||||
onDismiss,
|
||||
backdropDismiss = true,
|
||||
layer = 'dialog',
|
||||
padding = 'p-6',
|
||||
role,
|
||||
children,
|
||||
...aria
|
||||
}: Props) {
|
||||
const [id] = useState(() => ++opened)
|
||||
const dismissRef = useRef(onDismiss)
|
||||
dismissRef.current = onDismiss
|
||||
|
||||
useEffect(() => {
|
||||
open.add(id)
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key !== 'Escape' || e.defaultPrevented) return
|
||||
if (id !== Math.max(...open)) return
|
||||
// A menu over the dialog closes itself on Esc; the dialog stays.
|
||||
if (menuOpen()) return
|
||||
const dismiss = dismissRef.current
|
||||
if (!dismiss) return
|
||||
e.preventDefault()
|
||||
dismiss()
|
||||
}
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => {
|
||||
open.delete(id)
|
||||
window.removeEventListener('keydown', onKey)
|
||||
}
|
||||
}, [id])
|
||||
|
||||
const pressed = useRef(false)
|
||||
const released = useRef(false)
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
role={role}
|
||||
{...aria}
|
||||
className={`fixed inset-0 ${layer === 'nested' ? 'z-[60]' : 'z-50'} flex items-center justify-center bg-black/40 backdrop-blur-[3px] ${padding}`}
|
||||
// React bubbles events through portals, so a nested dialog's or menu's
|
||||
// pointer events reach here too; `target === currentTarget` keeps only
|
||||
// the ones on THIS backdrop.
|
||||
onPointerDown={(e) => {
|
||||
// A press that closes an open menu closes only the menu.
|
||||
pressed.current = e.target === e.currentTarget && e.button === 0 && !menuOpen()
|
||||
released.current = false
|
||||
}}
|
||||
onPointerUp={(e) => {
|
||||
released.current = e.target === e.currentTarget
|
||||
}}
|
||||
onClick={(e) => {
|
||||
const outside = pressed.current && released.current && e.target === e.currentTarget
|
||||
pressed.current = released.current = false
|
||||
if (outside && backdropDismiss) dismissRef.current?.()
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</div>,
|
||||
document.body,
|
||||
)
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { keepPreviousData, useQuery } from '@tanstack/react-query'
|
||||
import { api, type NormalizeOptions, type NormalizePreview, type NormalizeRow } from '../api'
|
||||
import { LevelInput, useAppSetting } from './AppSettings'
|
||||
import { Icon } from '../lib/icons'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
ids: string[]
|
||||
@@ -58,12 +58,6 @@ export function NormalizeDialog({ ids, onRun, onClose, onError }: Props) {
|
||||
const p: NormalizePreview | undefined = preview.data
|
||||
const count = p?.tracks_to_process ?? 0
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && !busy && onClose()
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [busy, onClose])
|
||||
|
||||
const summary = useMemo(() => {
|
||||
if (!p) return []
|
||||
const rows = p.rows
|
||||
@@ -105,13 +99,9 @@ export function NormalizeDialog({ ids, onRun, onClose, onError }: Props) {
|
||||
|
||||
const measureUnit = opts?.measure === 'rms' ? 'dB' : 'LUFS'
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={() => !busy && onClose()}
|
||||
>
|
||||
<div className="flex max-h-[80vh] w-full max-w-lg flex-col overflow-hidden glass-overlay" onClick={(e) => e.stopPropagation()}>
|
||||
return (
|
||||
<Modal onDismiss={busy ? null : onClose}>
|
||||
<div className="flex max-h-[80vh] w-full max-w-lg flex-col overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Normalize</div>
|
||||
<div className="text-xs text-muted">
|
||||
@@ -198,7 +188,6 @@ export function NormalizeDialog({ ids, onRun, onClose, onError }: Props) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type RemapPreview } from '../api'
|
||||
import type { ToastMsg } from './Toast'
|
||||
import { Icon } from '../lib/icons'
|
||||
import { invalidateTrackLists } from '../lib/trackQueries'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
onClose: () => void
|
||||
@@ -107,14 +107,10 @@ export function PathMappingDialog({ onClose, onNotify, onError }: Props) {
|
||||
const collides = (preview?.collisions ?? 0) > 0
|
||||
const canCommit = !!from.trim() && !!to.trim() && !collides
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={onClose}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={onClose}>
|
||||
<div
|
||||
className="flex max-h-[85vh] w-full max-w-xl flex-col overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Path Remapping</div>
|
||||
@@ -264,8 +260,7 @@ export function PathMappingDialog({ onClose, onNotify, onError }: Props) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type ExportRunOptions, type ExportSet, type JobStatus, type PushPreview, type PushTarget } from '../api'
|
||||
import { askConfirm } from '../lib/confirm'
|
||||
import { localLibraryProblem } from '../lib/platformCopy'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Push a "computer" set into this computer's Traktor / rekordbox: confirm what
|
||||
@@ -136,8 +136,8 @@ export function PushRunDialog({ set, onClose, onDone, onError }: Props) {
|
||||
job?.state === 'done' ? 100 : job && job.total > 0 ? Math.min(100, (job.done / job.total) * 100) : null
|
||||
const results = ((job?.result as { targets?: TargetResult[] } | null)?.targets ?? [])
|
||||
|
||||
return createPortal(
|
||||
<div aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-4">
|
||||
return (
|
||||
<Modal onDismiss={onClose} padding="p-4">
|
||||
<div className="w-full max-w-lg glass-overlay">
|
||||
<div className="border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">
|
||||
@@ -323,8 +323,7 @@ export function PushRunDialog({ set, onClose, onDone, onError }: Props) {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { api } from '../api'
|
||||
import { flushPrefs } from '../lib/prefs'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Ask before quitting with unsaved changes: Save · Discard · Cancel.
|
||||
@@ -99,21 +99,9 @@ export function QuitGuard() {
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!asking) return
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape' && !busy) void cancel()
|
||||
}
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
})
|
||||
|
||||
if (!asking) return null
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-[60] flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={busy ? null : () => void cancel()} layer="nested">
|
||||
<div className="w-full max-w-sm overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-4 text-[15px] font-semibold tracking-tight">
|
||||
Save changes before quitting?
|
||||
@@ -147,7 +135,6 @@ export function QuitGuard() {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useState } from 'react'
|
||||
import { api, type PathMapping, type RelocationVolume } from '../api'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
volumes: RelocationVolume[]
|
||||
@@ -51,21 +51,12 @@ export function RelocateDialog({ volumes, onAnswered, onOpenManual, onError }: P
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && !busy && answer([])
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
})
|
||||
|
||||
const set = (root: string, to: string | null) => setChoice((c) => ({ ...c, [root]: to }))
|
||||
|
||||
return createPortal(
|
||||
// No close on a backdrop click: dismissing lasts until the library is
|
||||
// reopened, which is too much for a stray click to decide.
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
>
|
||||
return (
|
||||
// Esc is "Not now", but a backdrop click is not: dismissing lasts until
|
||||
// the library is reopened, which is too much for a stray click to decide.
|
||||
<Modal onDismiss={busy ? null : () => void answer([])} backdropDismiss={false}>
|
||||
<div className="flex max-h-[85vh] w-full max-w-xl flex-col overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Tracks not found</div>
|
||||
@@ -116,8 +107,7 @@ export function RelocateDialog({ volumes, onAnswered, onOpenManual, onError }: P
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api } from '../api'
|
||||
import { size } from './ConvertStemsDialog'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Settings → Remote audio: this computer's copies of a remote library's audio.
|
||||
@@ -21,12 +21,6 @@ export function RemoteCacheSettings({ onClose }: { onClose: () => void }) {
|
||||
const [busy, setBusy] = useState(false)
|
||||
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 u = usage.data
|
||||
const capGb = u ? Math.round(u.cap / 1024 ** 3) : null
|
||||
|
||||
@@ -54,13 +48,9 @@ export function RemoteCacheSettings({ 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">Remote audio</h2>
|
||||
<button onClick={onClose} className="rounded px-1.5 text-faint hover:text-text" aria-label="Close">
|
||||
@@ -107,7 +97,6 @@ export function RemoteCacheSettings({ onClose }: { onClose: () => void }) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import {
|
||||
api,
|
||||
@@ -14,6 +13,7 @@ import {
|
||||
import { askConfirm } from '../lib/confirm'
|
||||
import { Icon } from '../lib/icons'
|
||||
import { remoteHolder } from '../lib/platformCopy'
|
||||
import { Modal } from './Modal'
|
||||
import { OptionCard } from './OptionCard'
|
||||
|
||||
/**
|
||||
@@ -329,12 +329,8 @@ function PendingEditsDialog({
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
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]"
|
||||
onKeyDown={(e) => e.key === 'Escape' && !busy && void choose('later')}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={busy ? null : () => void choose('later')}>
|
||||
<div className="w-full max-w-sm overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-4 text-[15px] font-semibold tracking-tight">
|
||||
Unsaved edits from {edits.machine || 'another computer'}
|
||||
@@ -369,7 +365,6 @@ function PendingEditsDialog({
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
||||
import type { SortingState } from '@tanstack/react-table'
|
||||
import { maxPosition, moveToPosition } from '../lib/playlistOrder'
|
||||
import { COLUMN_MENU } from '../lib/trackColumns'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
/** The playlist's full entry order — never the sorted or filtered view, so
|
||||
@@ -50,14 +50,6 @@ export function SetPositionDialog({ order, ids, sorting, onMove, onClose }: Prop
|
||||
onClose()
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape') onClose()
|
||||
}
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [onClose])
|
||||
|
||||
const option = (value: 'playlist' | 'sorted', label: string, detail: ReactNode) => (
|
||||
<label
|
||||
className={`flex cursor-pointer gap-3 rounded-lg px-3 py-2 ${
|
||||
@@ -80,15 +72,10 @@ export function SetPositionDialog({ order, ids, sorting, onMove, onClose }: Prop
|
||||
|
||||
const span = (p: number) => (count > 1 ? `#${p}–${p + count - 1}` : `#${p}`)
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={onClose}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={onClose}>
|
||||
<form
|
||||
className="w-full max-w-sm overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault()
|
||||
submit()
|
||||
@@ -152,7 +139,6 @@ export function SetPositionDialog({ order, ids, sorting, onMove, onClose }: Prop
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from 'react'
|
||||
import { useCaps } from '../lib/capabilities'
|
||||
import { Icon } from '../lib/icons'
|
||||
@@ -24,6 +23,7 @@ import {
|
||||
type Layer,
|
||||
type MouseGesture,
|
||||
} from '../lib/shortcuts'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
onClose: () => void
|
||||
@@ -162,15 +162,10 @@ export function ShortcutsDialog({ onClose }: Props) {
|
||||
onPick: pickLayer,
|
||||
}
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={onClose}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={onClose}>
|
||||
<div
|
||||
className="flex max-h-full w-full max-w-[960px] flex-col overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="flex flex-wrap items-center gap-3 border-b border-line py-3.5 pl-5 pr-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Keyboard Shortcuts</div>
|
||||
@@ -309,8 +304,7 @@ export function ShortcutsDialog({ onClose }: Props) {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect } from 'react'
|
||||
import type { StemBatchResult } from '../api'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* The Details behind a finished conversion's toast: every track that was
|
||||
@@ -8,24 +7,14 @@ import type { StemBatchResult } from '../api'
|
||||
* into a toast).
|
||||
*/
|
||||
export function StemReportDialog({ result, onClose }: { result: StemBatchResult; onClose: () => void }) {
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose()
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [onClose])
|
||||
|
||||
const rows = [
|
||||
...result.failed.map((s) => ({ ...s, failed: true })),
|
||||
...result.skipped.map((s) => ({ ...s, failed: false })),
|
||||
]
|
||||
const n = result.converted.length
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4 backdrop-blur-[3px]"
|
||||
onClick={onClose}
|
||||
>
|
||||
<div className="flex max-h-[80vh] w-full max-w-lg flex-col overflow-hidden glass-overlay" onClick={(e) => e.stopPropagation()}>
|
||||
return (
|
||||
<Modal onDismiss={onClose} padding="p-4">
|
||||
<div className="flex max-h-[80vh] w-full max-w-lg flex-col overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-3 text-sm font-semibold text-text">
|
||||
{n} converted to stems · {result.skipped.length} skipped · {result.failed.length} failed
|
||||
</div>
|
||||
@@ -49,7 +38,6 @@ export function StemReportDialog({ result, onClose }: { result: StemBatchResult;
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type StemTarget } from '../api'
|
||||
import { askConfirm } from '../lib/confirm'
|
||||
import { FolderPicker } from './FolderPicker'
|
||||
import { size } from './ConvertStemsDialog'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Settings → Stems (decided contents): the engine (status, download, install
|
||||
@@ -40,12 +40,6 @@ export function StemsSettings({ onClose }: Props) {
|
||||
}
|
||||
}, [install.data, qc])
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && !picking && onClose()
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [onClose, picking])
|
||||
|
||||
const act = async (fn: () => Promise<unknown>) => {
|
||||
setBusy(true)
|
||||
setError(null)
|
||||
@@ -72,7 +66,7 @@ export function StemsSettings({ onClose }: Props) {
|
||||
const targetLabel = (t: StemTarget) =>
|
||||
t === 'macos-arm64' ? 'Apple silicon (GPU)' : t === 'windows-x64-cuda' ? 'NVIDIA GPU' : 'processor only'
|
||||
|
||||
return createPortal(
|
||||
return (
|
||||
<>
|
||||
{picking && (
|
||||
<FolderPicker
|
||||
@@ -81,14 +75,9 @@ export function StemsSettings({ onClose }: Props) {
|
||||
onClose={() => setPicking(null)}
|
||||
/>
|
||||
)}
|
||||
<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}
|
||||
>
|
||||
<Modal onDismiss={onClose}>
|
||||
<div
|
||||
className="flex max-h-[85vh] w-full max-w-lg flex-col overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="flex items-center justify-between border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">Stems</h2>
|
||||
@@ -241,8 +230,7 @@ export function StemsSettings({ onClose }: Props) {
|
||||
{error && <div className="text-xs text-pink">{error}</div>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
document.body,
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState, type ReactNode } from 'react'
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import type { Track } from '../api'
|
||||
import { formatBpm, formatDuration, keyColor } from '../lib/format'
|
||||
import { useCaps } from '../lib/capabilities'
|
||||
import { Icon } from '../lib/icons'
|
||||
import { RatingStars } from './RatingStars'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
track: Track
|
||||
@@ -27,12 +27,6 @@ export function TrackInfoDialog({ track, artUrl, onClose, onEditTags }: Props) {
|
||||
const [artFailed, setArtFailed] = useState(false)
|
||||
const showArt = artUrl != null && !artFailed
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose()
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [onClose])
|
||||
|
||||
const grid =
|
||||
track.grid_marker_count === 0
|
||||
? null
|
||||
@@ -60,17 +54,10 @@ export function TrackInfoDialog({ track, artUrl, onClose, onEditTags }: Props) {
|
||||
] as [string, ReactNode][]
|
||||
).filter(([, v]) => v != null && v !== '')
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
role="dialog"
|
||||
aria-label={track.title ?? 'Track info'}
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4 backdrop-blur-[3px]"
|
||||
onClick={onClose}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={onClose} padding="p-4" role="dialog" aria-label={track.title ?? 'Track info'}>
|
||||
<div
|
||||
className="track-info-pop glass-overlay flex max-h-[90vh] w-full max-w-[860px] flex-col overflow-hidden sm:flex-row"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{/* The sleeve, bled into the card behind everything: a soft wash of the
|
||||
art's own colours. `filter` on this leaf is safe — nothing can open
|
||||
@@ -166,8 +153,7 @@ export function TrackInfoDialog({ track, artUrl, onClose, onEditTags }: Props) {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
/**
|
||||
* Startup update check against GitHub Releases.
|
||||
@@ -285,14 +285,10 @@ export function UpdateCheck() {
|
||||
const sections = newer.map((r) => ({ tag: r.tag_name, changes: whatsChanged(r.body) }))
|
||||
const grouped = sections.length > 1
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={close}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={busy ? null : close}>
|
||||
<div
|
||||
className="flex max-h-[80vh] w-full max-w-md flex-col overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">{title}</div>
|
||||
@@ -418,7 +414,6 @@ export function UpdateCheck() {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user