diff --git a/src/app/components/upload-card/UploadCardRenderer.tsx b/src/app/components/upload-card/UploadCardRenderer.tsx index 8e8f57f8c..4628e2b26 100644 --- a/src/app/components/upload-card/UploadCardRenderer.tsx +++ b/src/app/components/upload-card/UploadCardRenderer.tsx @@ -117,7 +117,6 @@ function CompressionCheckbox({ fileItem, metadata, setMetadata }: CompressionChe return; } - // Optimistically mark as enabled; kick off compression in background setMetadata(fileItem, { ...metadata, compressImage: true, compressionResult: undefined }); setCompressing(true); @@ -136,63 +135,108 @@ function CompressionCheckbox({ fileItem, metadata, setMetadata }: CompressionChe ? Math.round(((result.originalSize - result.compressedSize) / result.originalSize) * 100) : null; + const originalSize = formatFileSize(originalFile.size); + return ( + {/* Checkbox row */} {compressing && ( - - estimating… + + compressing… )} - {checked && !compressing && result !== undefined && ( - + 0 - ? 'var(--tc-success-normal, #2e7d32)' - : 'var(--text-secondary)' - : 'var(--tc-danger-normal)', - paddingLeft: '20px', + padding: `2px ${config.space.S200}`, + borderRadius: config.radii.R300, + background: color.Surface.Container, + border: `1px solid ${color.Surface.ContainerLine}`, }} > - {result - ? savingPct !== null && savingPct > 0 - ? `→ ~${formatFileSize(result.compressedSize)} (${savingPct}% smaller)` - : `→ ${formatFileSize(result.compressedSize)} (no significant saving)` - : 'Compression not available for this file'} - - )} - {checked && !compressing && result === undefined && ( - - Original: {formatFileSize(originalFile.size)} - - )} + + Original + + + {originalSize} + + + + {checked && !compressing && result !== undefined && ( + <> + + → + + 5 + ? (color.Success?.Container ?? color.Primary.Container) + : color.Surface.Container, + border: `1px solid ${ + savingPct !== null && savingPct > 5 + ? (color.Success?.ContainerLine ?? color.Primary.ContainerLine) + : color.Surface.ContainerLine + }`, + }} + > + + Compressed + + {result ? ( + + {formatFileSize(result.compressedSize)} + {savingPct !== null && savingPct > 0 && ( + ({savingPct}% smaller) + )} + + ) : ( + + unavailable + + )} + + + )} + ); }