Overview
TheUploadArea component is the central interface for file uploads in MkDowner. It provides an intuitive drag-and-drop zone, handles file selection, displays upload progress, and shows conversion success states.
Key Features
- Drag-and-drop file upload
- Click-to-browse file selection
- Multiple file support
- Upload progress tracking
- Success state with download confirmation
- Responsive visual feedback
Props
Callback function triggered when files are selected (via drag-and-drop or file browser).
Callback function triggered when the user submits files for conversion.
Indicates whether files are currently being uploaded/converted.
Upload progress percentage (0-100). Used to display the progress bar during conversion.
Array of currently selected files. Used to display file count and enable/disable submit button.
Controls whether to display the success state after successful conversion.
Name of the downloaded file shown in the success message.
Callback function triggered when the user clicks “Convert New Files” button in success state.
Usage Example
Integration with Hooks
TheUploadArea component works seamlessly with the useFileUpload hook, which manages file state and conversion logic:
Component Behavior
Default State
Displays a drag-and-drop zone with:- Upload icon
- Instructions: “Drop your PDF here or click to browse”
- Supported formats message
- Disabled submit button (enabled after file selection)
File Selected State
After files are selected:- Updates subtext to show file count: “X file(s) selected”
- Enables submit button with dynamic text:
- Single file: “Convert file”
- Multiple files: “Convert X files”
Uploading State
During conversion:- Button text changes to “Converting…”
- Progress bar appears showing conversion progress
- Submit button is disabled
Success State
After successful conversion:- Shows success icon (✅)
- Displays message: “Conversion Successful!”
- Shows downloaded file name
- Provides “Convert New Files” button to reset the form
Styling & Customization
The component uses CSS classes fromUploadArea.css:
.upload-card- Main container.is-dragover- Applied during drag-over state.success-state- Applied when showing success message.progress-bar- Progress indicator styling.primary-btn- Submit button styling
Drag-and-Drop Visual Feedback
The component automatically adds theis-dragover class when files are dragged over the drop zone, providing visual feedback to users.
Implementation Details
Source Code Location
~/workspace/source/src/components/UploadArea/UploadArea.tsx:15-140
TypeScript Interface
Key Implementation Notes
- Uses
useReffor hidden file input element - Handles drag events:
onDragOver,onDragLeave,onDrop - Converts
File[]array toFileListfor submission usingDataTransferAPI - Dynamic button text based on state and file count
- Form submission prevents default browser behavior