2025-11-17 10:44:49 +01:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import * as React from 'react';
|
feat: add comprehensive conversion options and enhanced UI
This major update adds powerful format-specific controls, quality presets,
file metadata display, and enhanced progress feedback to significantly
improve the user experience.
New Components:
- ConversionOptionsPanel: Format-specific controls with collapsible advanced options
- Video options: codec selection (H.264, H.265, VP8, VP9), bitrate, resolution, FPS
- Audio options: codec selection, bitrate, sample rate, channels
- Image options: quality slider, width/height controls
- Quality Presets: One-click presets (High Quality, Balanced, Small File, Web Optimized)
- FileInfo: Displays file metadata including size, duration, dimensions
- Slider: Reusable slider component for quality/bitrate controls
- Select: Reusable dropdown component for codec/format selection
Enhanced Features:
- ConversionPreview improvements:
- Real-time elapsed time display
- Estimated time remaining calculation
- File size comparison (input vs output with % reduction/increase)
- Better visual status indicators with icons
- Enhanced loading states with detailed progress
- FileConverter integration:
- Passes conversion options to converter services
- Manages conversion options state
- Resets options on file reset
UI/UX Improvements:
- Format-specific option panels that adapt to selected output format
- Visual preset buttons with icons and descriptions
- Collapsible advanced options to reduce clutter
- Better progress feedback with time estimates
- File size comparison badges showing compression results
- Smooth animations and transitions (existing animations already in place)
- Responsive design for all new components
Technical Details:
- Options are properly typed and integrated with ConversionOptions interface
- All components support disabled states during conversion
- Preview component calculates speed and estimates remaining time
- Metadata extraction for video/audio/image files using browser APIs
- Proper cleanup of object URLs and timers
User Benefits:
- Power users can fine-tune codec, bitrate, resolution settings
- Beginners can use quality presets with confidence
- Better understanding of conversion progress and file size impact
- Informed decisions with file metadata display
- Professional-grade control over output quality
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 11:46:10 +01:00
|
|
|
import { Download, CheckCircle, XCircle, Loader2, Clock, TrendingUp, FileCheck2, ArrowRight } from 'lucide-react';
|
2025-11-17 10:44:49 +01:00
|
|
|
import { cn } from '@/lib/utils/cn';
|
|
|
|
|
import { Button } from '@/components/ui/Button';
|
|
|
|
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/Card';
|
|
|
|
|
import { Progress } from '@/components/ui/Progress';
|
|
|
|
|
import { downloadBlob, formatFileSize, generateOutputFilename } from '@/lib/utils/fileUtils';
|
|
|
|
|
import type { ConversionJob } from '@/types/conversion';
|
|
|
|
|
|
|
|
|
|
export interface ConversionPreviewProps {
|
|
|
|
|
job: ConversionJob;
|
|
|
|
|
onDownload?: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function ConversionPreview({ job, onDownload }: ConversionPreviewProps) {
|
|
|
|
|
const [previewUrl, setPreviewUrl] = React.useState<string | null>(null);
|
feat: add comprehensive conversion options and enhanced UI
This major update adds powerful format-specific controls, quality presets,
file metadata display, and enhanced progress feedback to significantly
improve the user experience.
New Components:
- ConversionOptionsPanel: Format-specific controls with collapsible advanced options
- Video options: codec selection (H.264, H.265, VP8, VP9), bitrate, resolution, FPS
- Audio options: codec selection, bitrate, sample rate, channels
- Image options: quality slider, width/height controls
- Quality Presets: One-click presets (High Quality, Balanced, Small File, Web Optimized)
- FileInfo: Displays file metadata including size, duration, dimensions
- Slider: Reusable slider component for quality/bitrate controls
- Select: Reusable dropdown component for codec/format selection
Enhanced Features:
- ConversionPreview improvements:
- Real-time elapsed time display
- Estimated time remaining calculation
- File size comparison (input vs output with % reduction/increase)
- Better visual status indicators with icons
- Enhanced loading states with detailed progress
- FileConverter integration:
- Passes conversion options to converter services
- Manages conversion options state
- Resets options on file reset
UI/UX Improvements:
- Format-specific option panels that adapt to selected output format
- Visual preset buttons with icons and descriptions
- Collapsible advanced options to reduce clutter
- Better progress feedback with time estimates
- File size comparison badges showing compression results
- Smooth animations and transitions (existing animations already in place)
- Responsive design for all new components
Technical Details:
- Options are properly typed and integrated with ConversionOptions interface
- All components support disabled states during conversion
- Preview component calculates speed and estimates remaining time
- Metadata extraction for video/audio/image files using browser APIs
- Proper cleanup of object URLs and timers
User Benefits:
- Power users can fine-tune codec, bitrate, resolution settings
- Beginners can use quality presets with confidence
- Better understanding of conversion progress and file size impact
- Informed decisions with file metadata display
- Professional-grade control over output quality
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 11:46:10 +01:00
|
|
|
const [elapsedTime, setElapsedTime] = React.useState(0);
|
|
|
|
|
const [estimatedTimeRemaining, setEstimatedTimeRemaining] = React.useState<number | null>(null);
|
|
|
|
|
|
|
|
|
|
// Timer for elapsed time and estimation
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
|
if (job.status === 'processing' || job.status === 'loading') {
|
|
|
|
|
const interval = setInterval(() => {
|
|
|
|
|
if (job.startTime) {
|
|
|
|
|
const elapsed = Date.now() - job.startTime;
|
|
|
|
|
setElapsedTime(elapsed);
|
|
|
|
|
|
|
|
|
|
// Estimate time remaining based on progress
|
|
|
|
|
if (job.progress > 5 && job.progress < 100) {
|
|
|
|
|
const progressRate = job.progress / elapsed;
|
|
|
|
|
const remainingProgress = 100 - job.progress;
|
|
|
|
|
const estimated = remainingProgress / progressRate;
|
|
|
|
|
setEstimatedTimeRemaining(estimated);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, 100);
|
|
|
|
|
|
|
|
|
|
return () => clearInterval(interval);
|
|
|
|
|
} else {
|
|
|
|
|
setEstimatedTimeRemaining(null);
|
|
|
|
|
}
|
|
|
|
|
}, [job.status, job.startTime, job.progress]);
|
2025-11-17 10:44:49 +01:00
|
|
|
|
|
|
|
|
// Create preview URL for result
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
|
if (job.result && job.status === 'completed') {
|
|
|
|
|
const url = URL.createObjectURL(job.result);
|
|
|
|
|
setPreviewUrl(url);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
URL.revokeObjectURL(url);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}, [job.result, job.status]);
|
|
|
|
|
|
|
|
|
|
const handleDownload = () => {
|
|
|
|
|
if (job.result) {
|
|
|
|
|
const filename = generateOutputFilename(job.inputFile.name, job.outputFormat.extension);
|
|
|
|
|
downloadBlob(job.result, filename);
|
|
|
|
|
onDownload?.();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const renderPreview = () => {
|
|
|
|
|
if (!previewUrl || !job.result) return null;
|
|
|
|
|
|
|
|
|
|
const category = job.outputFormat.category;
|
|
|
|
|
|
2025-11-17 12:16:37 +01:00
|
|
|
// Log blob details for debugging
|
|
|
|
|
console.log('[Preview] Blob details:', {
|
|
|
|
|
size: job.result.size,
|
|
|
|
|
type: job.result.type,
|
|
|
|
|
previewUrl,
|
|
|
|
|
outputFormat: job.outputFormat.extension,
|
|
|
|
|
});
|
|
|
|
|
|
2025-11-17 10:44:49 +01:00
|
|
|
switch (category) {
|
|
|
|
|
case 'image':
|
|
|
|
|
return (
|
|
|
|
|
<div className="mt-4 rounded-lg overflow-hidden bg-muted/30 flex items-center justify-center p-4">
|
|
|
|
|
<img
|
|
|
|
|
src={previewUrl}
|
|
|
|
|
alt="Converted image preview"
|
|
|
|
|
className="max-w-full max-h-64 object-contain"
|
2025-11-17 12:16:37 +01:00
|
|
|
onError={(e) => {
|
|
|
|
|
console.error('[Preview] Image failed to load:', {
|
|
|
|
|
src: previewUrl,
|
|
|
|
|
blobSize: job.result?.size,
|
|
|
|
|
blobType: job.result?.type,
|
|
|
|
|
error: e,
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
onLoad={() => {
|
|
|
|
|
console.log('[Preview] Image loaded successfully');
|
|
|
|
|
}}
|
2025-11-17 10:44:49 +01:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
case 'video':
|
|
|
|
|
return (
|
|
|
|
|
<div className="mt-4 rounded-lg overflow-hidden bg-muted/30">
|
|
|
|
|
<video src={previewUrl} controls className="w-full max-h-64">
|
|
|
|
|
Your browser does not support video playback.
|
|
|
|
|
</video>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
case 'audio':
|
|
|
|
|
return (
|
|
|
|
|
<div className="mt-4 rounded-lg overflow-hidden bg-muted/30 p-4">
|
|
|
|
|
<audio src={previewUrl} controls className="w-full">
|
|
|
|
|
Your browser does not support audio playback.
|
|
|
|
|
</audio>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
feat: add comprehensive conversion options and enhanced UI
This major update adds powerful format-specific controls, quality presets,
file metadata display, and enhanced progress feedback to significantly
improve the user experience.
New Components:
- ConversionOptionsPanel: Format-specific controls with collapsible advanced options
- Video options: codec selection (H.264, H.265, VP8, VP9), bitrate, resolution, FPS
- Audio options: codec selection, bitrate, sample rate, channels
- Image options: quality slider, width/height controls
- Quality Presets: One-click presets (High Quality, Balanced, Small File, Web Optimized)
- FileInfo: Displays file metadata including size, duration, dimensions
- Slider: Reusable slider component for quality/bitrate controls
- Select: Reusable dropdown component for codec/format selection
Enhanced Features:
- ConversionPreview improvements:
- Real-time elapsed time display
- Estimated time remaining calculation
- File size comparison (input vs output with % reduction/increase)
- Better visual status indicators with icons
- Enhanced loading states with detailed progress
- FileConverter integration:
- Passes conversion options to converter services
- Manages conversion options state
- Resets options on file reset
UI/UX Improvements:
- Format-specific option panels that adapt to selected output format
- Visual preset buttons with icons and descriptions
- Collapsible advanced options to reduce clutter
- Better progress feedback with time estimates
- File size comparison badges showing compression results
- Smooth animations and transitions (existing animations already in place)
- Responsive design for all new components
Technical Details:
- Options are properly typed and integrated with ConversionOptions interface
- All components support disabled states during conversion
- Preview component calculates speed and estimates remaining time
- Metadata extraction for video/audio/image files using browser APIs
- Proper cleanup of object URLs and timers
User Benefits:
- Power users can fine-tune codec, bitrate, resolution settings
- Beginners can use quality presets with confidence
- Better understanding of conversion progress and file size impact
- Informed decisions with file metadata display
- Professional-grade control over output quality
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 11:46:10 +01:00
|
|
|
const formatTime = (ms: number) => {
|
|
|
|
|
const seconds = Math.floor(ms / 1000);
|
|
|
|
|
if (seconds < 60) return `${seconds}s`;
|
|
|
|
|
const minutes = Math.floor(seconds / 60);
|
|
|
|
|
const remainingSeconds = seconds % 60;
|
|
|
|
|
return `${minutes}m ${remainingSeconds}s`;
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-17 10:44:49 +01:00
|
|
|
const renderStatus = () => {
|
|
|
|
|
switch (job.status) {
|
|
|
|
|
case 'loading':
|
|
|
|
|
return (
|
feat: add comprehensive conversion options and enhanced UI
This major update adds powerful format-specific controls, quality presets,
file metadata display, and enhanced progress feedback to significantly
improve the user experience.
New Components:
- ConversionOptionsPanel: Format-specific controls with collapsible advanced options
- Video options: codec selection (H.264, H.265, VP8, VP9), bitrate, resolution, FPS
- Audio options: codec selection, bitrate, sample rate, channels
- Image options: quality slider, width/height controls
- Quality Presets: One-click presets (High Quality, Balanced, Small File, Web Optimized)
- FileInfo: Displays file metadata including size, duration, dimensions
- Slider: Reusable slider component for quality/bitrate controls
- Select: Reusable dropdown component for codec/format selection
Enhanced Features:
- ConversionPreview improvements:
- Real-time elapsed time display
- Estimated time remaining calculation
- File size comparison (input vs output with % reduction/increase)
- Better visual status indicators with icons
- Enhanced loading states with detailed progress
- FileConverter integration:
- Passes conversion options to converter services
- Manages conversion options state
- Resets options on file reset
UI/UX Improvements:
- Format-specific option panels that adapt to selected output format
- Visual preset buttons with icons and descriptions
- Collapsible advanced options to reduce clutter
- Better progress feedback with time estimates
- File size comparison badges showing compression results
- Smooth animations and transitions (existing animations already in place)
- Responsive design for all new components
Technical Details:
- Options are properly typed and integrated with ConversionOptions interface
- All components support disabled states during conversion
- Preview component calculates speed and estimates remaining time
- Metadata extraction for video/audio/image files using browser APIs
- Proper cleanup of object URLs and timers
User Benefits:
- Power users can fine-tune codec, bitrate, resolution settings
- Beginners can use quality presets with confidence
- Better understanding of conversion progress and file size impact
- Informed decisions with file metadata display
- Professional-grade control over output quality
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 11:46:10 +01:00
|
|
|
<div className="space-y-3">
|
|
|
|
|
<div className="flex items-center gap-2 text-info">
|
|
|
|
|
<Loader2 className="h-4 w-4 animate-spin" />
|
|
|
|
|
<span className="text-sm font-medium">Loading WASM converter...</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
|
|
|
|
<Clock className="h-3.5 w-3.5" />
|
|
|
|
|
<span>Elapsed: {formatTime(elapsedTime)}</span>
|
|
|
|
|
</div>
|
2025-11-17 10:44:49 +01:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
case 'processing':
|
|
|
|
|
return (
|
feat: add comprehensive conversion options and enhanced UI
This major update adds powerful format-specific controls, quality presets,
file metadata display, and enhanced progress feedback to significantly
improve the user experience.
New Components:
- ConversionOptionsPanel: Format-specific controls with collapsible advanced options
- Video options: codec selection (H.264, H.265, VP8, VP9), bitrate, resolution, FPS
- Audio options: codec selection, bitrate, sample rate, channels
- Image options: quality slider, width/height controls
- Quality Presets: One-click presets (High Quality, Balanced, Small File, Web Optimized)
- FileInfo: Displays file metadata including size, duration, dimensions
- Slider: Reusable slider component for quality/bitrate controls
- Select: Reusable dropdown component for codec/format selection
Enhanced Features:
- ConversionPreview improvements:
- Real-time elapsed time display
- Estimated time remaining calculation
- File size comparison (input vs output with % reduction/increase)
- Better visual status indicators with icons
- Enhanced loading states with detailed progress
- FileConverter integration:
- Passes conversion options to converter services
- Manages conversion options state
- Resets options on file reset
UI/UX Improvements:
- Format-specific option panels that adapt to selected output format
- Visual preset buttons with icons and descriptions
- Collapsible advanced options to reduce clutter
- Better progress feedback with time estimates
- File size comparison badges showing compression results
- Smooth animations and transitions (existing animations already in place)
- Responsive design for all new components
Technical Details:
- Options are properly typed and integrated with ConversionOptions interface
- All components support disabled states during conversion
- Preview component calculates speed and estimates remaining time
- Metadata extraction for video/audio/image files using browser APIs
- Proper cleanup of object URLs and timers
User Benefits:
- Power users can fine-tune codec, bitrate, resolution settings
- Beginners can use quality presets with confidence
- Better understanding of conversion progress and file size impact
- Informed decisions with file metadata display
- Professional-grade control over output quality
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 11:46:10 +01:00
|
|
|
<div className="space-y-3">
|
|
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
<div className="flex items-center gap-2 text-info">
|
|
|
|
|
<Loader2 className="h-4 w-4 animate-spin" />
|
|
|
|
|
<span className="text-sm font-medium">Converting...</span>
|
|
|
|
|
</div>
|
|
|
|
|
<span className="text-xs text-muted-foreground">{job.progress}%</span>
|
|
|
|
|
</div>
|
|
|
|
|
<Progress value={job.progress} showLabel={false} />
|
|
|
|
|
<div className="flex items-center gap-4 text-xs text-muted-foreground">
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<Clock className="h-3.5 w-3.5" />
|
|
|
|
|
<span>Elapsed: {formatTime(elapsedTime)}</span>
|
|
|
|
|
</div>
|
|
|
|
|
{estimatedTimeRemaining && (
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<TrendingUp className="h-3.5 w-3.5" />
|
|
|
|
|
<span>~{formatTime(estimatedTimeRemaining)} remaining</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2025-11-17 10:44:49 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
case 'completed':
|
feat: add comprehensive conversion options and enhanced UI
This major update adds powerful format-specific controls, quality presets,
file metadata display, and enhanced progress feedback to significantly
improve the user experience.
New Components:
- ConversionOptionsPanel: Format-specific controls with collapsible advanced options
- Video options: codec selection (H.264, H.265, VP8, VP9), bitrate, resolution, FPS
- Audio options: codec selection, bitrate, sample rate, channels
- Image options: quality slider, width/height controls
- Quality Presets: One-click presets (High Quality, Balanced, Small File, Web Optimized)
- FileInfo: Displays file metadata including size, duration, dimensions
- Slider: Reusable slider component for quality/bitrate controls
- Select: Reusable dropdown component for codec/format selection
Enhanced Features:
- ConversionPreview improvements:
- Real-time elapsed time display
- Estimated time remaining calculation
- File size comparison (input vs output with % reduction/increase)
- Better visual status indicators with icons
- Enhanced loading states with detailed progress
- FileConverter integration:
- Passes conversion options to converter services
- Manages conversion options state
- Resets options on file reset
UI/UX Improvements:
- Format-specific option panels that adapt to selected output format
- Visual preset buttons with icons and descriptions
- Collapsible advanced options to reduce clutter
- Better progress feedback with time estimates
- File size comparison badges showing compression results
- Smooth animations and transitions (existing animations already in place)
- Responsive design for all new components
Technical Details:
- Options are properly typed and integrated with ConversionOptions interface
- All components support disabled states during conversion
- Preview component calculates speed and estimates remaining time
- Metadata extraction for video/audio/image files using browser APIs
- Proper cleanup of object URLs and timers
User Benefits:
- Power users can fine-tune codec, bitrate, resolution settings
- Beginners can use quality presets with confidence
- Better understanding of conversion progress and file size impact
- Informed decisions with file metadata display
- Professional-grade control over output quality
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 11:46:10 +01:00
|
|
|
const inputSize = job.inputFile.size;
|
|
|
|
|
const outputSize = job.result?.size || 0;
|
|
|
|
|
const sizeReduction = inputSize > 0 ? ((inputSize - outputSize) / inputSize) * 100 : 0;
|
|
|
|
|
|
2025-11-17 10:44:49 +01:00
|
|
|
return (
|
feat: add comprehensive conversion options and enhanced UI
This major update adds powerful format-specific controls, quality presets,
file metadata display, and enhanced progress feedback to significantly
improve the user experience.
New Components:
- ConversionOptionsPanel: Format-specific controls with collapsible advanced options
- Video options: codec selection (H.264, H.265, VP8, VP9), bitrate, resolution, FPS
- Audio options: codec selection, bitrate, sample rate, channels
- Image options: quality slider, width/height controls
- Quality Presets: One-click presets (High Quality, Balanced, Small File, Web Optimized)
- FileInfo: Displays file metadata including size, duration, dimensions
- Slider: Reusable slider component for quality/bitrate controls
- Select: Reusable dropdown component for codec/format selection
Enhanced Features:
- ConversionPreview improvements:
- Real-time elapsed time display
- Estimated time remaining calculation
- File size comparison (input vs output with % reduction/increase)
- Better visual status indicators with icons
- Enhanced loading states with detailed progress
- FileConverter integration:
- Passes conversion options to converter services
- Manages conversion options state
- Resets options on file reset
UI/UX Improvements:
- Format-specific option panels that adapt to selected output format
- Visual preset buttons with icons and descriptions
- Collapsible advanced options to reduce clutter
- Better progress feedback with time estimates
- File size comparison badges showing compression results
- Smooth animations and transitions (existing animations already in place)
- Responsive design for all new components
Technical Details:
- Options are properly typed and integrated with ConversionOptions interface
- All components support disabled states during conversion
- Preview component calculates speed and estimates remaining time
- Metadata extraction for video/audio/image files using browser APIs
- Proper cleanup of object URLs and timers
User Benefits:
- Power users can fine-tune codec, bitrate, resolution settings
- Beginners can use quality presets with confidence
- Better understanding of conversion progress and file size impact
- Informed decisions with file metadata display
- Professional-grade control over output quality
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 11:46:10 +01:00
|
|
|
<div className="space-y-3">
|
|
|
|
|
<div className="flex items-center gap-2 text-success">
|
|
|
|
|
<CheckCircle className="h-5 w-5" />
|
|
|
|
|
<span className="text-sm font-medium">Conversion complete!</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* File size comparison */}
|
|
|
|
|
<div className="bg-muted/50 rounded-lg p-3 space-y-2">
|
|
|
|
|
<div className="flex items-center justify-between text-sm">
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<FileCheck2 className="h-4 w-4 text-muted-foreground" />
|
|
|
|
|
<span className="text-muted-foreground">Input:</span>
|
|
|
|
|
</div>
|
|
|
|
|
<span className="font-medium">{formatFileSize(inputSize)}</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center justify-center py-1">
|
|
|
|
|
<ArrowRight className="h-4 w-4 text-muted-foreground" />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center justify-between text-sm">
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<FileCheck2 className="h-4 w-4 text-muted-foreground" />
|
|
|
|
|
<span className="text-muted-foreground">Output:</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<span className="font-medium">{formatFileSize(outputSize)}</span>
|
|
|
|
|
{Math.abs(sizeReduction) > 1 && (
|
|
|
|
|
<span className={cn(
|
|
|
|
|
"text-xs px-2 py-0.5 rounded-full",
|
|
|
|
|
sizeReduction > 0
|
|
|
|
|
? "bg-success/10 text-success"
|
|
|
|
|
: "bg-info/10 text-info"
|
|
|
|
|
)}>
|
|
|
|
|
{sizeReduction > 0 ? '-' : '+'}{Math.abs(sizeReduction).toFixed(0)}%
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-11-17 10:44:49 +01:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
case 'error':
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex items-center gap-2 text-destructive">
|
feat: add comprehensive conversion options and enhanced UI
This major update adds powerful format-specific controls, quality presets,
file metadata display, and enhanced progress feedback to significantly
improve the user experience.
New Components:
- ConversionOptionsPanel: Format-specific controls with collapsible advanced options
- Video options: codec selection (H.264, H.265, VP8, VP9), bitrate, resolution, FPS
- Audio options: codec selection, bitrate, sample rate, channels
- Image options: quality slider, width/height controls
- Quality Presets: One-click presets (High Quality, Balanced, Small File, Web Optimized)
- FileInfo: Displays file metadata including size, duration, dimensions
- Slider: Reusable slider component for quality/bitrate controls
- Select: Reusable dropdown component for codec/format selection
Enhanced Features:
- ConversionPreview improvements:
- Real-time elapsed time display
- Estimated time remaining calculation
- File size comparison (input vs output with % reduction/increase)
- Better visual status indicators with icons
- Enhanced loading states with detailed progress
- FileConverter integration:
- Passes conversion options to converter services
- Manages conversion options state
- Resets options on file reset
UI/UX Improvements:
- Format-specific option panels that adapt to selected output format
- Visual preset buttons with icons and descriptions
- Collapsible advanced options to reduce clutter
- Better progress feedback with time estimates
- File size comparison badges showing compression results
- Smooth animations and transitions (existing animations already in place)
- Responsive design for all new components
Technical Details:
- Options are properly typed and integrated with ConversionOptions interface
- All components support disabled states during conversion
- Preview component calculates speed and estimates remaining time
- Metadata extraction for video/audio/image files using browser APIs
- Proper cleanup of object URLs and timers
User Benefits:
- Power users can fine-tune codec, bitrate, resolution settings
- Beginners can use quality presets with confidence
- Better understanding of conversion progress and file size impact
- Informed decisions with file metadata display
- Professional-grade control over output quality
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 11:46:10 +01:00
|
|
|
<XCircle className="h-5 w-5" />
|
2025-11-17 10:44:49 +01:00
|
|
|
<span className="text-sm font-medium">Conversion failed</span>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (job.status === 'pending') {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Card className="animate-fadeIn">
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<CardTitle className="text-lg">Conversion Status</CardTitle>
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent>
|
|
|
|
|
<div className="space-y-4">
|
|
|
|
|
{/* Status */}
|
|
|
|
|
{renderStatus()}
|
|
|
|
|
|
|
|
|
|
{/* Error message */}
|
|
|
|
|
{job.error && (
|
|
|
|
|
<div className="bg-destructive/10 border border-destructive/20 rounded-md p-3">
|
|
|
|
|
<p className="text-sm text-destructive">{job.error}</p>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Preview */}
|
|
|
|
|
{job.status === 'completed' && renderPreview()}
|
|
|
|
|
|
|
|
|
|
{/* Download button */}
|
|
|
|
|
{job.status === 'completed' && job.result && (
|
|
|
|
|
<Button onClick={handleDownload} className="w-full gap-2">
|
|
|
|
|
<Download className="h-4 w-4" />
|
|
|
|
|
Download{' '}
|
|
|
|
|
{generateOutputFilename(job.inputFile.name, job.outputFormat.extension)}
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Duration */}
|
|
|
|
|
{job.status === 'completed' && job.startTime && job.endTime && (
|
|
|
|
|
<p className="text-xs text-muted-foreground text-center">
|
|
|
|
|
Completed in {((job.endTime - job.startTime) / 1000).toFixed(2)}s
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
);
|
|
|
|
|
}
|