2025-11-17 10:44:49 +01:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import * as React from 'react';
|
2025-11-17 13:34:11 +01:00
|
|
|
import { ArrowRight, ArrowDown, Keyboard } from 'lucide-react';
|
2025-11-17 10:44:49 +01:00
|
|
|
import { Button } from '@/components/ui/Button';
|
|
|
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/Card';
|
|
|
|
|
import { FileUpload } from './FileUpload';
|
|
|
|
|
import { FormatSelector } from './FormatSelector';
|
|
|
|
|
import { ConversionPreview } from './ConversionPreview';
|
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 { ConversionOptionsPanel } from './ConversionOptions';
|
|
|
|
|
import { FileInfo } from './FileInfo';
|
feat: add format presets for common conversion scenarios
Format presets included:
**Video Presets:**
- YouTube Video (1080p, H.264, optimized)
- Instagram Video (Square format, 1:1)
- Twitter Video (720p, small file)
- Web Optimized (Streaming, low bitrate)
**Audio Presets:**
- Podcast (MP3, voice optimized, 128k)
- High Quality Music (MP3, 320k)
- Audiobook (Mono, 64k, small size)
**Image Presets:**
- Web Thumbnail (JPG, 800px width)
- HD Image (PNG, lossless, high quality)
- Social Media (JPG, 1200px, optimized)
- Web Optimized (WebP, small size)
Implementation:
- Created formatPresets.ts with 11 predefined presets
- FormatPresets component with responsive grid layout
- One-click preset application
- Automatically configures format and options
- Toast notification on preset selection
- Visual feedback with ring highlight
- Organized by category (video/audio/image)
- Emoji icons for visual appeal
User experience:
- Quick access to common conversion scenarios
- No need to manually configure complex settings
- Preset descriptions explain use case
- Disabled during active conversion
- Clear visual indication of selected preset
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 13:30:35 +01:00
|
|
|
import { FormatPresets } from './FormatPresets';
|
2025-11-17 10:44:49 +01:00
|
|
|
import { useToast } from '@/components/ui/Toast';
|
|
|
|
|
import {
|
|
|
|
|
SUPPORTED_FORMATS,
|
|
|
|
|
getFormatByExtension,
|
|
|
|
|
getFormatByMimeType,
|
|
|
|
|
getCompatibleFormats,
|
|
|
|
|
} from '@/lib/utils/formatMappings';
|
|
|
|
|
import { convertWithFFmpeg } from '@/lib/converters/ffmpegService';
|
|
|
|
|
import { convertWithImageMagick } from '@/lib/converters/imagemagickService';
|
|
|
|
|
import { addToHistory } from '@/lib/storage/history';
|
2025-11-17 13:13:52 +01:00
|
|
|
import { downloadBlobsAsZip, generateOutputFilename } from '@/lib/utils/fileUtils';
|
feat: add format presets for common conversion scenarios
Format presets included:
**Video Presets:**
- YouTube Video (1080p, H.264, optimized)
- Instagram Video (Square format, 1:1)
- Twitter Video (720p, small file)
- Web Optimized (Streaming, low bitrate)
**Audio Presets:**
- Podcast (MP3, voice optimized, 128k)
- High Quality Music (MP3, 320k)
- Audiobook (Mono, 64k, small size)
**Image Presets:**
- Web Thumbnail (JPG, 800px width)
- HD Image (PNG, lossless, high quality)
- Social Media (JPG, 1200px, optimized)
- Web Optimized (WebP, small size)
Implementation:
- Created formatPresets.ts with 11 predefined presets
- FormatPresets component with responsive grid layout
- One-click preset application
- Automatically configures format and options
- Toast notification on preset selection
- Visual feedback with ring highlight
- Organized by category (video/audio/image)
- Emoji icons for visual appeal
User experience:
- Quick access to common conversion scenarios
- No need to manually configure complex settings
- Preset descriptions explain use case
- Disabled during active conversion
- Clear visual indication of selected preset
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 13:30:35 +01:00
|
|
|
import { getPresetById, type FormatPreset } from '@/lib/utils/formatPresets';
|
2025-11-17 13:34:11 +01:00
|
|
|
import { useKeyboardShortcuts, type KeyboardShortcut } from '@/lib/hooks/useKeyboardShortcuts';
|
|
|
|
|
import { KeyboardShortcutsModal } from '@/components/ui/KeyboardShortcutsModal';
|
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 type { ConversionJob, ConversionFormat, ConversionOptions } from '@/types/conversion';
|
2025-11-17 10:44:49 +01:00
|
|
|
|
|
|
|
|
export function FileConverter() {
|
|
|
|
|
const { addToast } = useToast();
|
|
|
|
|
|
2025-11-17 13:13:52 +01:00
|
|
|
const [selectedFiles, setSelectedFiles] = React.useState<File[]>([]);
|
2025-11-17 10:44:49 +01:00
|
|
|
const [inputFormat, setInputFormat] = React.useState<ConversionFormat | undefined>();
|
|
|
|
|
const [outputFormat, setOutputFormat] = React.useState<ConversionFormat | undefined>();
|
|
|
|
|
const [compatibleFormats, setCompatibleFormats] = React.useState<ConversionFormat[]>([]);
|
2025-11-17 13:13:52 +01:00
|
|
|
const [conversionJobs, setConversionJobs] = React.useState<ConversionJob[]>([]);
|
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 [conversionOptions, setConversionOptions] = React.useState<ConversionOptions>({});
|
2025-11-17 13:34:11 +01:00
|
|
|
const [showShortcutsModal, setShowShortcutsModal] = React.useState(false);
|
|
|
|
|
|
|
|
|
|
const fileInputRef = React.useRef<HTMLInputElement>(null);
|
2025-11-17 10:44:49 +01:00
|
|
|
|
2025-11-17 13:13:52 +01:00
|
|
|
// Detect input format when files are selected
|
2025-11-17 10:44:49 +01:00
|
|
|
React.useEffect(() => {
|
2025-11-17 13:13:52 +01:00
|
|
|
if (selectedFiles.length === 0) {
|
2025-11-17 10:44:49 +01:00
|
|
|
setInputFormat(undefined);
|
|
|
|
|
setOutputFormat(undefined);
|
|
|
|
|
setCompatibleFormats([]);
|
2025-11-17 13:13:52 +01:00
|
|
|
setConversionJobs([]);
|
2025-11-17 10:44:49 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-17 13:13:52 +01:00
|
|
|
// Use first file to detect format (assume all files same format for batch)
|
|
|
|
|
const firstFile = selectedFiles[0];
|
|
|
|
|
|
2025-11-17 10:44:49 +01:00
|
|
|
// Try to detect format from extension
|
2025-11-17 13:13:52 +01:00
|
|
|
const ext = firstFile.name.split('.').pop()?.toLowerCase();
|
2025-11-17 10:44:49 +01:00
|
|
|
let format = ext ? getFormatByExtension(ext) : undefined;
|
|
|
|
|
|
|
|
|
|
// Fallback to MIME type
|
|
|
|
|
if (!format) {
|
2025-11-17 13:13:52 +01:00
|
|
|
format = getFormatByMimeType(firstFile.type);
|
2025-11-17 10:44:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (format) {
|
|
|
|
|
setInputFormat(format);
|
|
|
|
|
const compatible = getCompatibleFormats(format);
|
|
|
|
|
setCompatibleFormats(compatible);
|
|
|
|
|
|
|
|
|
|
// Auto-select first compatible format
|
|
|
|
|
if (compatible.length > 0 && !outputFormat) {
|
|
|
|
|
setOutputFormat(compatible[0]);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-17 13:13:52 +01:00
|
|
|
addToast(`Detected format: ${format.name} (${selectedFiles.length} file${selectedFiles.length > 1 ? 's' : ''})`, 'success');
|
2025-11-17 10:44:49 +01:00
|
|
|
} else {
|
|
|
|
|
addToast('Could not detect file format', 'error');
|
|
|
|
|
setInputFormat(undefined);
|
|
|
|
|
setCompatibleFormats([]);
|
|
|
|
|
}
|
2025-11-17 13:13:52 +01:00
|
|
|
}, [selectedFiles]);
|
2025-11-17 10:44:49 +01:00
|
|
|
|
|
|
|
|
const handleConvert = async () => {
|
2025-11-17 13:13:52 +01:00
|
|
|
if (selectedFiles.length === 0 || !inputFormat || !outputFormat) {
|
|
|
|
|
addToast('Please select files and output format', 'error');
|
2025-11-17 10:44:49 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-17 13:13:52 +01:00
|
|
|
// Create conversion jobs for all files
|
|
|
|
|
const jobs: ConversionJob[] = selectedFiles.map((file) => ({
|
2025-11-17 10:44:49 +01:00
|
|
|
id: Math.random().toString(36).substring(7),
|
2025-11-17 13:13:52 +01:00
|
|
|
inputFile: file,
|
2025-11-17 10:44:49 +01:00
|
|
|
inputFormat,
|
|
|
|
|
outputFormat,
|
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
|
|
|
options: conversionOptions,
|
2025-11-17 13:13:52 +01:00
|
|
|
status: 'pending',
|
2025-11-17 10:44:49 +01:00
|
|
|
progress: 0,
|
|
|
|
|
startTime: Date.now(),
|
2025-11-17 13:13:52 +01:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
setConversionJobs(jobs);
|
|
|
|
|
|
2025-11-17 14:07:53 +01:00
|
|
|
// Track success/failure counts
|
|
|
|
|
let successCount = 0;
|
|
|
|
|
let failureCount = 0;
|
|
|
|
|
|
2025-11-17 13:13:52 +01:00
|
|
|
// Convert files sequentially
|
|
|
|
|
for (let i = 0; i < jobs.length; i++) {
|
|
|
|
|
const job = jobs[i];
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// Update job to loading
|
|
|
|
|
setConversionJobs((prev) =>
|
|
|
|
|
prev.map((j, idx) => idx === i ? { ...j, status: 'loading' as const } : j)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Update job to processing
|
|
|
|
|
setConversionJobs((prev) =>
|
|
|
|
|
prev.map((j, idx) => idx === i ? { ...j, status: 'processing' as const, progress: 10 } : j)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Call appropriate converter
|
|
|
|
|
let result;
|
|
|
|
|
|
|
|
|
|
switch (outputFormat.converter) {
|
|
|
|
|
case 'ffmpeg':
|
|
|
|
|
result = await convertWithFFmpeg(job.inputFile, outputFormat.extension, conversionOptions, (progress) => {
|
|
|
|
|
setConversionJobs((prev) =>
|
|
|
|
|
prev.map((j, idx) => idx === i ? { ...j, progress } : j)
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'imagemagick':
|
|
|
|
|
result = await convertWithImageMagick(
|
|
|
|
|
job.inputFile,
|
|
|
|
|
outputFormat.extension,
|
|
|
|
|
conversionOptions,
|
|
|
|
|
(progress) => {
|
|
|
|
|
setConversionJobs((prev) =>
|
|
|
|
|
prev.map((j, idx) => idx === i ? { ...j, progress } : j)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
throw new Error(`Unknown converter: ${outputFormat.converter}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update job with result
|
|
|
|
|
if (result.success && result.blob) {
|
2025-11-17 14:07:53 +01:00
|
|
|
successCount++;
|
|
|
|
|
|
2025-11-17 13:13:52 +01:00
|
|
|
setConversionJobs((prev) =>
|
|
|
|
|
prev.map((j, idx) => idx === i ? {
|
|
|
|
|
...j,
|
|
|
|
|
status: 'completed' as const,
|
|
|
|
|
progress: 100,
|
|
|
|
|
result: result.blob,
|
|
|
|
|
endTime: Date.now(),
|
|
|
|
|
} : j)
|
|
|
|
|
);
|
2025-11-17 10:44:49 +01:00
|
|
|
|
2025-11-17 13:13:52 +01:00
|
|
|
// Add to history
|
|
|
|
|
addToHistory({
|
|
|
|
|
inputFileName: job.inputFile.name,
|
|
|
|
|
inputFormat: inputFormat.name,
|
|
|
|
|
outputFormat: outputFormat.name,
|
|
|
|
|
outputFileName: `output.${outputFormat.extension}`,
|
|
|
|
|
fileSize: result.blob.size,
|
|
|
|
|
result: result.blob,
|
2025-11-17 10:44:49 +01:00
|
|
|
});
|
2025-11-17 13:13:52 +01:00
|
|
|
} else {
|
2025-11-17 14:07:53 +01:00
|
|
|
failureCount++;
|
|
|
|
|
|
2025-11-17 13:13:52 +01:00
|
|
|
setConversionJobs((prev) =>
|
|
|
|
|
prev.map((j, idx) => idx === i ? {
|
|
|
|
|
...j,
|
|
|
|
|
status: 'error' as const,
|
|
|
|
|
error: result.error || 'Unknown error',
|
|
|
|
|
endTime: Date.now(),
|
|
|
|
|
} : j)
|
2025-11-17 10:44:49 +01:00
|
|
|
);
|
2025-11-17 13:13:52 +01:00
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2025-11-17 14:07:53 +01:00
|
|
|
failureCount++;
|
2025-11-17 13:13:52 +01:00
|
|
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
|
|
|
|
|
|
|
|
setConversionJobs((prev) =>
|
|
|
|
|
prev.map((j, idx) => idx === i ? {
|
|
|
|
|
...j,
|
|
|
|
|
status: 'error' as const,
|
|
|
|
|
error: errorMessage,
|
|
|
|
|
endTime: Date.now(),
|
|
|
|
|
} : j)
|
|
|
|
|
);
|
2025-11-17 10:44:49 +01:00
|
|
|
}
|
2025-11-17 13:13:52 +01:00
|
|
|
}
|
2025-11-17 10:44:49 +01:00
|
|
|
|
2025-11-17 13:13:52 +01:00
|
|
|
// Show completion message
|
|
|
|
|
if (successCount === jobs.length) {
|
|
|
|
|
addToast(`All ${jobs.length} files converted successfully!`, 'success');
|
|
|
|
|
} else if (successCount > 0) {
|
|
|
|
|
addToast(`${successCount}/${jobs.length} files converted successfully`, 'info');
|
|
|
|
|
} else {
|
|
|
|
|
addToast('All conversions failed', 'error');
|
2025-11-17 10:44:49 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleReset = () => {
|
2025-11-17 13:13:52 +01:00
|
|
|
setSelectedFiles([]);
|
2025-11-17 10:44:49 +01:00
|
|
|
setInputFormat(undefined);
|
|
|
|
|
setOutputFormat(undefined);
|
|
|
|
|
setCompatibleFormats([]);
|
2025-11-17 13:13:52 +01:00
|
|
|
setConversionJobs([]);
|
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
|
|
|
setConversionOptions({});
|
2025-11-17 10:44:49 +01:00
|
|
|
};
|
|
|
|
|
|
2025-11-17 13:13:52 +01:00
|
|
|
const handleFileSelect = (files: File[]) => {
|
|
|
|
|
setSelectedFiles((prev) => [...prev, ...files]);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleFileRemove = (index: number) => {
|
|
|
|
|
setSelectedFiles((prev) => prev.filter((_, i) => i !== index));
|
|
|
|
|
};
|
|
|
|
|
|
feat: add format presets for common conversion scenarios
Format presets included:
**Video Presets:**
- YouTube Video (1080p, H.264, optimized)
- Instagram Video (Square format, 1:1)
- Twitter Video (720p, small file)
- Web Optimized (Streaming, low bitrate)
**Audio Presets:**
- Podcast (MP3, voice optimized, 128k)
- High Quality Music (MP3, 320k)
- Audiobook (Mono, 64k, small size)
**Image Presets:**
- Web Thumbnail (JPG, 800px width)
- HD Image (PNG, lossless, high quality)
- Social Media (JPG, 1200px, optimized)
- Web Optimized (WebP, small size)
Implementation:
- Created formatPresets.ts with 11 predefined presets
- FormatPresets component with responsive grid layout
- One-click preset application
- Automatically configures format and options
- Toast notification on preset selection
- Visual feedback with ring highlight
- Organized by category (video/audio/image)
- Emoji icons for visual appeal
User experience:
- Quick access to common conversion scenarios
- No need to manually configure complex settings
- Preset descriptions explain use case
- Disabled during active conversion
- Clear visual indication of selected preset
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 13:30:35 +01:00
|
|
|
const handlePresetSelect = (preset: FormatPreset) => {
|
|
|
|
|
// Find the output format that matches the preset
|
|
|
|
|
const format = compatibleFormats.find(f => f.extension === preset.outputFormat);
|
|
|
|
|
|
|
|
|
|
if (format) {
|
|
|
|
|
setOutputFormat(format);
|
|
|
|
|
setConversionOptions(preset.options);
|
|
|
|
|
addToast(`Applied ${preset.name} preset`, 'success');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-17 13:13:52 +01:00
|
|
|
const handleDownloadAll = async () => {
|
|
|
|
|
if (!outputFormat) return;
|
|
|
|
|
|
|
|
|
|
const completedJobs = conversionJobs.filter(job => job.status === 'completed' && job.result);
|
|
|
|
|
|
|
|
|
|
if (completedJobs.length === 0) {
|
|
|
|
|
addToast('No files to download', 'error');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (completedJobs.length === 1) {
|
|
|
|
|
// Just download the single file
|
|
|
|
|
const job = completedJobs[0];
|
|
|
|
|
const filename = generateOutputFilename(job.inputFile.name, outputFormat.extension);
|
|
|
|
|
const url = URL.createObjectURL(job.result!);
|
|
|
|
|
const a = document.createElement('a');
|
|
|
|
|
a.href = url;
|
|
|
|
|
a.download = filename;
|
|
|
|
|
document.body.appendChild(a);
|
|
|
|
|
a.click();
|
|
|
|
|
document.body.removeChild(a);
|
|
|
|
|
URL.revokeObjectURL(url);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Download multiple files as ZIP
|
|
|
|
|
const files = completedJobs.map(job => ({
|
|
|
|
|
blob: job.result!,
|
|
|
|
|
filename: generateOutputFilename(job.inputFile.name, outputFormat.extension),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
await downloadBlobsAsZip(files, `converted-files.zip`);
|
|
|
|
|
addToast(`Downloaded ${files.length} files as ZIP`, 'success');
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-17 13:22:44 +01:00
|
|
|
const handleRetry = async (jobId: string) => {
|
|
|
|
|
const jobIndex = conversionJobs.findIndex(j => j.id === jobId);
|
|
|
|
|
if (jobIndex === -1 || !outputFormat) return;
|
|
|
|
|
|
|
|
|
|
const job = conversionJobs[jobIndex];
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// Reset job to loading
|
|
|
|
|
setConversionJobs((prev) =>
|
|
|
|
|
prev.map((j, idx) => idx === jobIndex ? {
|
|
|
|
|
...j,
|
|
|
|
|
status: 'loading' as const,
|
|
|
|
|
progress: 0,
|
|
|
|
|
error: undefined,
|
|
|
|
|
startTime: Date.now(),
|
|
|
|
|
} : j)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Update to processing
|
|
|
|
|
setConversionJobs((prev) =>
|
|
|
|
|
prev.map((j, idx) => idx === jobIndex ? { ...j, status: 'processing' as const, progress: 10 } : j)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Call appropriate converter
|
|
|
|
|
let result;
|
|
|
|
|
|
|
|
|
|
switch (outputFormat.converter) {
|
|
|
|
|
case 'ffmpeg':
|
|
|
|
|
result = await convertWithFFmpeg(job.inputFile, outputFormat.extension, conversionOptions, (progress) => {
|
|
|
|
|
setConversionJobs((prev) =>
|
|
|
|
|
prev.map((j, idx) => idx === jobIndex ? { ...j, progress } : j)
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'imagemagick':
|
|
|
|
|
result = await convertWithImageMagick(
|
|
|
|
|
job.inputFile,
|
|
|
|
|
outputFormat.extension,
|
|
|
|
|
conversionOptions,
|
|
|
|
|
(progress) => {
|
|
|
|
|
setConversionJobs((prev) =>
|
|
|
|
|
prev.map((j, idx) => idx === jobIndex ? { ...j, progress } : j)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
throw new Error(`Unknown converter: ${outputFormat.converter}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update job with result
|
|
|
|
|
if (result.success && result.blob) {
|
|
|
|
|
setConversionJobs((prev) =>
|
|
|
|
|
prev.map((j, idx) => idx === jobIndex ? {
|
|
|
|
|
...j,
|
|
|
|
|
status: 'completed' as const,
|
|
|
|
|
progress: 100,
|
|
|
|
|
result: result.blob,
|
|
|
|
|
endTime: Date.now(),
|
|
|
|
|
} : j)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
addToast('Conversion completed successfully!', 'success');
|
|
|
|
|
|
|
|
|
|
// Add to history
|
|
|
|
|
addToHistory({
|
|
|
|
|
inputFileName: job.inputFile.name,
|
|
|
|
|
inputFormat: job.inputFormat.name,
|
|
|
|
|
outputFormat: outputFormat.name,
|
|
|
|
|
outputFileName: `output.${outputFormat.extension}`,
|
|
|
|
|
fileSize: result.blob.size,
|
|
|
|
|
result: result.blob,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
setConversionJobs((prev) =>
|
|
|
|
|
prev.map((j, idx) => idx === jobIndex ? {
|
|
|
|
|
...j,
|
|
|
|
|
status: 'error' as const,
|
|
|
|
|
error: result.error || 'Unknown error',
|
|
|
|
|
endTime: Date.now(),
|
|
|
|
|
} : j)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
addToast(result.error || 'Retry failed', 'error');
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
|
|
|
|
|
|
|
|
setConversionJobs((prev) =>
|
|
|
|
|
prev.map((j, idx) => idx === jobIndex ? {
|
|
|
|
|
...j,
|
|
|
|
|
status: 'error' as const,
|
|
|
|
|
error: errorMessage,
|
|
|
|
|
endTime: Date.now(),
|
|
|
|
|
} : j)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
addToast(`Retry failed: ${errorMessage}`, 'error');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-17 13:13:52 +01:00
|
|
|
const isConverting = conversionJobs.some(job => job.status === 'loading' || job.status === 'processing');
|
|
|
|
|
const isConvertDisabled = selectedFiles.length === 0 || !outputFormat || isConverting;
|
|
|
|
|
const completedCount = conversionJobs.filter(job => job.status === 'completed').length;
|
2025-11-17 10:44:49 +01:00
|
|
|
|
2025-11-17 13:34:11 +01:00
|
|
|
// Define keyboard shortcuts
|
|
|
|
|
const shortcuts: KeyboardShortcut[] = [
|
|
|
|
|
{
|
|
|
|
|
key: 'o',
|
|
|
|
|
ctrl: true,
|
|
|
|
|
description: 'Open file dialog',
|
|
|
|
|
action: () => {
|
|
|
|
|
if (!isConverting) {
|
|
|
|
|
fileInputRef.current?.click();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'Enter',
|
|
|
|
|
ctrl: true,
|
|
|
|
|
description: 'Start conversion',
|
|
|
|
|
action: () => {
|
|
|
|
|
if (!isConvertDisabled) {
|
|
|
|
|
handleConvert();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 's',
|
|
|
|
|
ctrl: true,
|
|
|
|
|
description: 'Download results',
|
|
|
|
|
action: () => {
|
|
|
|
|
if (completedCount > 0) {
|
|
|
|
|
handleDownloadAll();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'r',
|
|
|
|
|
ctrl: true,
|
|
|
|
|
description: 'Reset converter',
|
|
|
|
|
action: () => {
|
|
|
|
|
if (!isConverting) {
|
|
|
|
|
handleReset();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: '/',
|
|
|
|
|
ctrl: true,
|
|
|
|
|
description: 'Show keyboard shortcuts',
|
|
|
|
|
action: () => setShowShortcutsModal(true),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'Escape',
|
|
|
|
|
description: 'Close shortcuts modal',
|
|
|
|
|
action: () => setShowShortcutsModal(false),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: '?',
|
|
|
|
|
description: 'Show keyboard shortcuts',
|
|
|
|
|
action: () => setShowShortcutsModal(true),
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// Enable keyboard shortcuts
|
|
|
|
|
useKeyboardShortcuts(shortcuts, !showShortcutsModal);
|
|
|
|
|
|
2025-11-17 10:44:49 +01:00
|
|
|
return (
|
|
|
|
|
<div className="w-full max-w-4xl mx-auto space-y-6">
|
|
|
|
|
{/* Header */}
|
|
|
|
|
<Card>
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<CardTitle>File Converter</CardTitle>
|
|
|
|
|
<CardDescription>
|
refactor: remove all document conversion support, keep only media conversions
This commit completely removes document conversion functionality to focus
exclusively on media file conversions (video, audio, images).
Changes:
- Remove all document converter services (pandocService.ts, pdfService.ts, docxService.ts)
- Uninstall document-related packages: marked, turndown, dompurify, jspdf, pdfjs-dist, docx, mammoth, @types/turndown
- Remove document formats (PDF, DOCX, Markdown, HTML, TXT) from formatMappings.ts
- Remove pandoc converter from FileConverter.tsx
- Remove pandoc loader and references from wasmLoader.ts
- Update TypeScript types to remove 'pandoc' from ConverterEngine and 'document' from FileCategory
- Remove pandoc from WASMModuleState interface
- Update README.md to remove all document conversion documentation
- Update UI descriptions to reflect media-only conversions
Supported conversions now:
- Video: MP4, WebM, AVI, MOV, MKV, GIF
- Audio: MP3, WAV, OGG, AAC, FLAC
- Images: PNG, JPG, WebP, GIF, BMP, TIFF, SVG
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 11:35:20 +01:00
|
|
|
Convert videos, audio, and images directly in your browser using WebAssembly
|
2025-11-17 10:44:49 +01:00
|
|
|
</CardDescription>
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent className="space-y-6">
|
|
|
|
|
{/* File upload */}
|
|
|
|
|
<FileUpload
|
2025-11-17 13:13:52 +01:00
|
|
|
onFileSelect={handleFileSelect}
|
|
|
|
|
onFileRemove={handleFileRemove}
|
|
|
|
|
selectedFiles={selectedFiles}
|
|
|
|
|
disabled={isConverting}
|
2025-11-17 13:34:11 +01:00
|
|
|
inputRef={fileInputRef}
|
2025-11-17 10:44:49 +01:00
|
|
|
/>
|
|
|
|
|
|
2025-11-17 13:13:52 +01:00
|
|
|
{/* File Info - show first file */}
|
|
|
|
|
{selectedFiles.length > 0 && inputFormat && (
|
|
|
|
|
<FileInfo file={selectedFiles[0]} format={inputFormat} />
|
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
|
|
|
)}
|
|
|
|
|
|
feat: add format presets for common conversion scenarios
Format presets included:
**Video Presets:**
- YouTube Video (1080p, H.264, optimized)
- Instagram Video (Square format, 1:1)
- Twitter Video (720p, small file)
- Web Optimized (Streaming, low bitrate)
**Audio Presets:**
- Podcast (MP3, voice optimized, 128k)
- High Quality Music (MP3, 320k)
- Audiobook (Mono, 64k, small size)
**Image Presets:**
- Web Thumbnail (JPG, 800px width)
- HD Image (PNG, lossless, high quality)
- Social Media (JPG, 1200px, optimized)
- Web Optimized (WebP, small size)
Implementation:
- Created formatPresets.ts with 11 predefined presets
- FormatPresets component with responsive grid layout
- One-click preset application
- Automatically configures format and options
- Toast notification on preset selection
- Visual feedback with ring highlight
- Organized by category (video/audio/image)
- Emoji icons for visual appeal
User experience:
- Quick access to common conversion scenarios
- No need to manually configure complex settings
- Preset descriptions explain use case
- Disabled during active conversion
- Clear visual indication of selected preset
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 13:30:35 +01:00
|
|
|
{/* Format Presets */}
|
|
|
|
|
{inputFormat && (
|
|
|
|
|
<FormatPresets
|
|
|
|
|
inputFormat={inputFormat}
|
|
|
|
|
onPresetSelect={handlePresetSelect}
|
|
|
|
|
disabled={isConverting}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
2025-11-17 10:44:49 +01:00
|
|
|
{/* Format selection */}
|
|
|
|
|
{inputFormat && compatibleFormats.length > 0 && (
|
|
|
|
|
<div className="grid grid-cols-1 md:grid-cols-[1fr_auto_1fr] gap-4 items-start">
|
|
|
|
|
{/* Input format */}
|
|
|
|
|
<div>
|
|
|
|
|
<label className="text-sm font-medium text-foreground mb-2 block">Input Format</label>
|
|
|
|
|
<Card className="p-4">
|
|
|
|
|
<p className="font-medium">{inputFormat.name}</p>
|
|
|
|
|
<p className="text-xs text-muted-foreground mt-1">{inputFormat.description}</p>
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-11-17 13:20:39 +01:00
|
|
|
{/* Arrow - horizontal on desktop, vertical on mobile */}
|
|
|
|
|
<div className="flex md:hidden items-center justify-center py-2">
|
|
|
|
|
<ArrowDown className="h-5 w-5 text-muted-foreground" />
|
|
|
|
|
</div>
|
2025-11-17 10:44:49 +01:00
|
|
|
<div className="hidden md:flex items-center justify-center pt-8">
|
|
|
|
|
<ArrowRight className="h-5 w-5 text-muted-foreground" />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Output format */}
|
|
|
|
|
<FormatSelector
|
|
|
|
|
formats={compatibleFormats}
|
|
|
|
|
selectedFormat={outputFormat}
|
|
|
|
|
onFormatSelect={setOutputFormat}
|
|
|
|
|
label="Output Format"
|
2025-11-17 13:13:52 +01:00
|
|
|
disabled={isConverting}
|
2025-11-17 10:44:49 +01:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
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
|
|
|
{/* Conversion Options */}
|
|
|
|
|
{inputFormat && outputFormat && (
|
|
|
|
|
<ConversionOptionsPanel
|
|
|
|
|
inputFormat={inputFormat}
|
|
|
|
|
outputFormat={outputFormat}
|
|
|
|
|
options={conversionOptions}
|
|
|
|
|
onOptionsChange={setConversionOptions}
|
2025-11-17 13:13:52 +01:00
|
|
|
disabled={isConverting}
|
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
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
2025-11-17 10:44:49 +01:00
|
|
|
{/* Convert button */}
|
|
|
|
|
{inputFormat && outputFormat && (
|
|
|
|
|
<div className="flex gap-3">
|
|
|
|
|
<Button
|
|
|
|
|
onClick={handleConvert}
|
|
|
|
|
disabled={isConvertDisabled}
|
|
|
|
|
className="flex-1"
|
|
|
|
|
size="lg"
|
|
|
|
|
>
|
2025-11-17 13:13:52 +01:00
|
|
|
{isConverting
|
2025-11-17 10:44:49 +01:00
|
|
|
? 'Converting...'
|
2025-11-17 13:13:52 +01:00
|
|
|
: `Convert ${selectedFiles.length} File${selectedFiles.length > 1 ? 's' : ''}`}
|
2025-11-17 10:44:49 +01:00
|
|
|
</Button>
|
|
|
|
|
<Button onClick={handleReset} variant="outline" size="lg">
|
|
|
|
|
Reset
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
|
2025-11-17 13:13:52 +01:00
|
|
|
{/* Download All Button */}
|
|
|
|
|
{completedCount > 0 && (
|
|
|
|
|
<Card>
|
|
|
|
|
<CardContent className="pt-6">
|
|
|
|
|
<Button
|
|
|
|
|
onClick={handleDownloadAll}
|
|
|
|
|
className="w-full"
|
|
|
|
|
size="lg"
|
|
|
|
|
variant="default"
|
|
|
|
|
>
|
|
|
|
|
Download All ({completedCount} file{completedCount > 1 ? 's' : ''})
|
|
|
|
|
{completedCount > 1 && ' as ZIP'}
|
|
|
|
|
</Button>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Conversion previews */}
|
|
|
|
|
{conversionJobs.length > 0 && (
|
|
|
|
|
<div className="space-y-4">
|
|
|
|
|
{conversionJobs.map((job) => (
|
2025-11-17 13:22:44 +01:00
|
|
|
<ConversionPreview
|
|
|
|
|
key={job.id}
|
|
|
|
|
job={job}
|
|
|
|
|
onRetry={() => handleRetry(job.id)}
|
|
|
|
|
/>
|
2025-11-17 13:13:52 +01:00
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2025-11-17 13:34:11 +01:00
|
|
|
|
|
|
|
|
{/* Keyboard Shortcuts Button */}
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => setShowShortcutsModal(true)}
|
|
|
|
|
className="fixed bottom-6 right-6 rounded-full w-12 h-12 p-0 shadow-lg"
|
|
|
|
|
title="Keyboard Shortcuts (Ctrl+/)"
|
|
|
|
|
>
|
|
|
|
|
<Keyboard className="h-5 w-5" />
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
{/* Keyboard Shortcuts Modal */}
|
|
|
|
|
<KeyboardShortcutsModal
|
|
|
|
|
shortcuts={shortcuts}
|
|
|
|
|
isOpen={showShortcutsModal}
|
|
|
|
|
onClose={() => setShowShortcutsModal(false)}
|
|
|
|
|
/>
|
2025-11-17 10:44:49 +01:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|