Enhanced info boxes with better contrast and visibility: - Increased background opacity from /10 to /90 for blue info boxes - Changed to thicker border (border-2) for better definition - Changed text color to white for better contrast on blue background - Applied consistent styling across: * Selection Active info box (EditControls) * History Available info box (HistoryControls) Info boxes are now clearly readable in both light and dark modes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
140 lines
3.8 KiB
TypeScript
140 lines
3.8 KiB
TypeScript
'use client';
|
|
|
|
import * as React from 'react';
|
|
import { Scissors, Copy, Clipboard, Trash2, CropIcon, Info } from 'lucide-react';
|
|
import { Button } from '@/components/ui/Button';
|
|
import { cn } from '@/lib/utils/cn';
|
|
import type { Selection } from '@/types/selection';
|
|
import { formatDuration } from '@/lib/audio/decoder';
|
|
|
|
export interface EditControlsProps {
|
|
selection: Selection | null;
|
|
hasClipboard: boolean;
|
|
onCut: () => void;
|
|
onCopy: () => void;
|
|
onPaste: () => void;
|
|
onDelete: () => void;
|
|
onTrim: () => void;
|
|
onClearSelection: () => void;
|
|
className?: string;
|
|
}
|
|
|
|
export function EditControls({
|
|
selection,
|
|
hasClipboard,
|
|
onCut,
|
|
onCopy,
|
|
onPaste,
|
|
onDelete,
|
|
onTrim,
|
|
onClearSelection,
|
|
className,
|
|
}: EditControlsProps) {
|
|
const hasSelection = selection !== null;
|
|
const selectionDuration = selection ? selection.end - selection.start : 0;
|
|
|
|
return (
|
|
<div className={cn('space-y-4', className)}>
|
|
{/* Selection Info */}
|
|
{hasSelection && (
|
|
<div className="rounded-lg border-2 border-info bg-info/90 p-3">
|
|
<div className="flex items-start gap-2">
|
|
<Info className="h-4 w-4 text-white dark:text-white mt-0.5 flex-shrink-0" />
|
|
<div className="flex-1 min-w-0 text-sm text-white dark:text-white">
|
|
<p className="font-medium">Selection Active</p>
|
|
<p className="opacity-95 mt-1">
|
|
Duration: {formatDuration(selectionDuration)} |
|
|
Start: {formatDuration(selection.start)} |
|
|
End: {formatDuration(selection.end)}
|
|
</p>
|
|
<p className="text-xs opacity-90 mt-1">
|
|
Tip: Hold Shift and drag on the waveform to select a region
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{/* Edit Buttons */}
|
|
<div className="grid grid-cols-2 gap-2">
|
|
<Button
|
|
variant="outline"
|
|
onClick={onCut}
|
|
disabled={!hasSelection}
|
|
title="Cut (Ctrl+X)"
|
|
className="justify-start"
|
|
>
|
|
<Scissors className="h-4 w-4 mr-2" />
|
|
Cut
|
|
</Button>
|
|
|
|
<Button
|
|
variant="outline"
|
|
onClick={onCopy}
|
|
disabled={!hasSelection}
|
|
title="Copy (Ctrl+C)"
|
|
className="justify-start"
|
|
>
|
|
<Copy className="h-4 w-4 mr-2" />
|
|
Copy
|
|
</Button>
|
|
|
|
<Button
|
|
variant="outline"
|
|
onClick={onPaste}
|
|
disabled={!hasClipboard}
|
|
title="Paste (Ctrl+V)"
|
|
className="justify-start"
|
|
>
|
|
<Clipboard className="h-4 w-4 mr-2" />
|
|
Paste
|
|
</Button>
|
|
|
|
<Button
|
|
variant="outline"
|
|
onClick={onDelete}
|
|
disabled={!hasSelection}
|
|
title="Delete (Del)"
|
|
className="justify-start"
|
|
>
|
|
<Trash2 className="h-4 w-4 mr-2" />
|
|
Delete
|
|
</Button>
|
|
|
|
<Button
|
|
variant="outline"
|
|
onClick={onTrim}
|
|
disabled={!hasSelection}
|
|
title="Trim to Selection"
|
|
className="justify-start"
|
|
>
|
|
<CropIcon className="h-4 w-4 mr-2" />
|
|
Trim
|
|
</Button>
|
|
|
|
<Button
|
|
variant="outline"
|
|
onClick={onClearSelection}
|
|
disabled={!hasSelection}
|
|
title="Clear Selection (Esc)"
|
|
className="justify-start"
|
|
>
|
|
Clear
|
|
</Button>
|
|
</div>
|
|
|
|
{/* Keyboard Shortcuts Info */}
|
|
<div className="text-xs text-muted-foreground space-y-1 p-3 rounded-lg bg-muted/30">
|
|
<p className="font-medium mb-2">Edit Shortcuts:</p>
|
|
<p>• Shift+Drag: Select region</p>
|
|
<p>• Ctrl+A: Select all</p>
|
|
<p>• Ctrl+X: Cut</p>
|
|
<p>• Ctrl+C: Copy</p>
|
|
<p>• Ctrl+V: Paste</p>
|
|
<p>• Delete: Delete selection</p>
|
|
<p>• Escape: Clear selection</p>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|