mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Added context option to multi analyze
This commit is contained in:
1 parent
b71436fad6
commit
532dc5d6ac
11 files changed
+486
-12
No files matched your search
@@ -0,0 +1,83 @@
|
||||
import { useEffect } from 'react'
|
||||
|
||||
interface Props {
|
||||
/** Tracks the user selected. */
|
||||
total: number
|
||||
/** Unlocked tracks that already have a beatgrid. */
|
||||
existing: number
|
||||
/** Tracks whose grid is locked — skipped whatever is chosen here. */
|
||||
locked: number
|
||||
onChoose: (replaceExisting: boolean) => void
|
||||
onClose: () => void
|
||||
}
|
||||
|
||||
/** Asked only when a batch analysis would meet existing grids: re-analysing a
|
||||
* grid someone may have hand-fixed is a decision, not a default. */
|
||||
export function AnalyzeGridDialog({ total, existing, locked, onChoose, onClose }: Props) {
|
||||
// "Skip them" would leave nothing to do when every unlocked track has a grid.
|
||||
const canSkip = existing < total - locked
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose()
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [onClose])
|
||||
|
||||
return (
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-40 flex items-center justify-center bg-black/60 p-6"
|
||||
onClick={onClose}
|
||||
>
|
||||
<div
|
||||
className="w-full max-w-sm overflow-hidden rounded-xl border border-line bg-ink-900 shadow-2xl"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Analyze Grid & BPM</div>
|
||||
<div className="text-xs text-muted">
|
||||
{total} track{total === 1 ? '' : 's'} selected
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-1 px-5 py-4 text-sm text-muted">
|
||||
<p>
|
||||
<span className="tabular-nums text-text">{existing}</span>{' '}
|
||||
{existing === 1 ? 'already has a beatgrid' : 'already have a beatgrid'}. Replacing
|
||||
discards any hand edits to {existing === 1 ? 'it' : 'them'}.
|
||||
</p>
|
||||
{locked > 0 && (
|
||||
<p className="text-faint">
|
||||
{locked} {locked === 1 ? 'is' : 'are'} locked and will be skipped either way.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center justify-end gap-2 border-t border-line px-5 py-3">
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="rounded-md px-3 py-1.5 text-sm text-muted hover:bg-ink-800 hover:text-text"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onChoose(true)}
|
||||
className={
|
||||
canSkip
|
||||
? 'rounded-md px-3 py-1.5 text-sm text-muted hover:bg-ink-800 hover:text-text'
|
||||
: 'rounded-md bg-accent px-4 py-1.5 text-sm font-medium text-ink-950 hover:brightness-110'
|
||||
}
|
||||
>
|
||||
Replace {existing === 1 ? 'it' : 'them'}
|
||||
</button>
|
||||
{canSkip && (
|
||||
<button
|
||||
onClick={() => onChoose(false)}
|
||||
className="rounded-md bg-accent px-4 py-1.5 text-sm font-medium text-ink-950 hover:brightness-110"
|
||||
>
|
||||
Skip {existing === 1 ? 'it' : 'them'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user