Skip to content

Fix missing CropSuggestionModal component, add SVG color override, and preserve SVG format on upload#8

Merged
notkainoa merged 4 commits intocodex/add-drag-and-drop-support-for-uploadsfrom
copilot/sub-pr-4
Nov 24, 2025
Merged

Fix missing CropSuggestionModal component, add SVG color override, and preserve SVG format on upload#8
notkainoa merged 4 commits intocodex/add-drag-and-drop-support-for-uploadsfrom
copilot/sub-pr-4

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 24, 2025

The CropSuggestionModal component was missing from App.tsx, causing a React error that prevented the entire application from rendering. This component is required by the image upload flow to offer users the option to crop transparent padding.

Additionally, added SVG color override functionality to allow users to customize the color of uploaded SVG images, and fixed an issue where SVG files were being converted to PNG during the cropping process.

Changes

Added missing modal component (~70 lines)

  • Renders when uploaded images contain >threshold transparent padding
  • Shows side-by-side comparison of original vs. auto-cropped preview
  • Provides accept/reject actions for the crop suggestion
const CropSuggestionModal: React.FC<CropSuggestionModalProps> = ({ pending, onAcceptCrop, onSkip }) => {
    if (!pending) return null;
    
    const whitespacePercent = Math.round(pending.whitespaceRatio * 100);
    
    return (
        <div className="fixed inset-0 z-[100] bg-black/70 backdrop-blur-sm flex items-center justify-center p-4">
            {/* Side-by-side image comparison UI */}
        </div>
    );
};

The component was referenced at line 1301 but never defined, likely lost during a previous merge. Existing handlers (handleAcceptCrop, handleSkipCrop) and state management (pendingCrop) were already in place.

Added SVG color override feature

  • Added imageColor field to IconConfig type (defaults to #ffffff)
  • Color picker appears in Image Settings sidebar when an SVG is uploaded
  • SVG detection via checking if imageSrc starts with 'data:image/svg'
  • Color override applied in:
    • Preview component using CSS mask technique
    • SVG export using style attributes
    • Canvas export using composite operations

Preserve SVG format during upload

  • SVG files now bypass the cropping analysis to prevent conversion to PNG
  • When an SVG is uploaded, it goes directly to the image source without rasterization
  • This ensures SVG files remain as vector graphics and the Image Color picker stays functional
  • PNG/JPG images continue to show the crop suggestion dialog when they have significant transparent padding

Screenshots

Drag-and-drop overlay working:

Application loading correctly:

SVG color picker in Image Settings:

SVG with custom color applied:

SVG uploaded without crop dialog (preserves vector format):


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link
Copy Markdown

vercel bot commented Nov 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
emblemic Ready Ready Preview Comment Nov 24, 2025 3:36am

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Nov 24, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI changed the title [WIP] Add global drag-and-drop image upload Fix missing CropSuggestionModal component breaking drag-and-drop upload Nov 24, 2025
Copilot AI requested a review from notkainoa November 24, 2025 02:40
Copy link
Copy Markdown
Owner

@notkainoa notkainoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let the user override the color if the image is an svg

@notkainoa
Copy link
Copy Markdown
Owner

@copilot i meant in the settings in the right sidebar

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 24, 2025

@copilot i meant in the settings in the right sidebar

Added in commit d6d2063. When you upload an SVG image, an "Image Color" picker now appears in the Image Settings section of the right sidebar. You can use it to change the color of the SVG.

SVG color picker showing

The color picker only appears for SVG images and allows you to override the SVG's color:

Color changed to red

Copilot AI changed the title Fix missing CropSuggestionModal component breaking drag-and-drop upload Fix missing CropSuggestionModal component and add SVG color override Nov 24, 2025
@notkainoa
Copy link
Copy Markdown
Owner

@copilot When we crop an image, if its an svg, are we able to keep it as an svg. cause when I crop an svg now I think it changes it to a png cause I can't change the color anymore

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 24, 2025

@copilot When we crop an image, if its an svg, are we able to keep it as an svg. cause when I crop an svg now I think it changes it to a png cause I can't change the color anymore

Fixed in commit 60eea2d. SVG files now bypass the cropping process entirely, so they remain as SVGs and you can still change their color.

When you upload an SVG now:

  • No crop dialog appears (SVGs skip the transparency analysis)
  • The Image Color picker works immediately
  • The SVG stays as an SVG throughout

SVG uploaded without crop dialog

PNG and JPG images still get the crop suggestion when they have transparent padding.

Copilot AI changed the title Fix missing CropSuggestionModal component and add SVG color override Fix missing CropSuggestionModal component, add SVG color override, and preserve SVG format on upload Nov 24, 2025
@notkainoa notkainoa marked this pull request as ready for review November 24, 2025 04:39
@notkainoa notkainoa merged commit 918b536 into codex/add-drag-and-drop-support-for-uploads Nov 24, 2025
2 of 3 checks passed
@notkainoa notkainoa deleted the copilot/sub-pr-4 branch November 24, 2025 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants