Repository navigation
feat(image-cropper-web): make initial crop size configurable - #2396
Open
hunter-koppen wants to merge 3 commits into
Open
hunter-koppen wants to merge 3 commits into
hunter-koppen wants to merge 3 commits into
Conversation
Add an "Initial crop size (%)" property so the crop box no longer always seeds at a hardcoded 80% of the image on load and on Reset. Default is 100% (the full image).
Collaborator
|
thank you for the submission. |
… crop box - Default "Initial crop size (%)" to 80 so existing apps keep their current box. - Size the box as a share of the largest box that fits the aspect ratio, so the setting also works for height-limited ratios (e.g. 1:1 on a landscape image). - Report values outside 1-100 in Studio Pro via the editorConfig check. - Add unit tests for buildInitialCrop, CropArea onLoad, ratio re-seed and check. - Update the OpenSpec spec and changelog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request type
Description
The crop box's initial selection (on load, and again on Reset) was hardcoded to
80% of the image, centered, with no way to configure it — see
buildInitialCrop()inutils/initialCrop.ts. For any aspect ratio thatalready matches the desired crop, this forces the user to manually resize the
box on every use, since it never starts flush with the edges.
This PR adds an "Initial crop size (%)" property (
initialCropSize, integer,1-100) to control that, threaded through
CropArea→ImageCropperContainer→
ImageCropperStoreinto the existingbuildInitialCrop()calls (initialload, Reset, and re-seeding on aspect-ratio resolution). Out-of-range/NaN
values fall back to 100 defensively.
Note on the default: I set the default to 100% (the full image) rather
than preserving the old 80%, since a full-image starting box seems like the
more useful default for most crop use cases and removes the "always resize
by hand first" step. That said, this is a behavior change for existing apps
using this widget, so I'm flagging the choice explicitly — happy to default
to 80% instead (or anything else) if you'd prefer to keep it backward
compatible. Either way it's now configurable per widget instance.
What should be covered while testing?
(100) → on load, the crop box should cover the entire image edge-to-edge
(respecting the configured aspect ratio).
restore the original image.
format/size) is unaffected — covered by the existing + two new unit tests
in
ImageCropper.spec.tsx.pnpm lint,pnpm test, andtsc --noEmitall pass for this package.