-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ref(feedback): Refactor screenshot editor into multiple files #15362
Conversation
size-limit report 📦
|
|
||
return function ScreenshotEditor({ onError }: Props): VNode { | ||
const styles = hooks.useMemo(() => ({ __html: createScreenshotInputStyles(options.styleNonce).innerText }), []); | ||
|
||
const canvasContainerRef = hooks.useRef<HTMLDivElement>(null); | ||
const cropContainerRef = hooks.useRef<HTMLDivElement>(null); | ||
const croppingRef = hooks.useRef<HTMLCanvasElement>(null); | ||
const annotatingRef = hooks.useRef<HTMLCanvasElement>(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if this useRef
call was just inside Annotations.tsx?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's used in screenshot editor when resizing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh i missed that. i'll take another look. it's a non-blocking kind of thing too
❌ 416 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
setCroppingRect={setCroppingRect} | ||
resize={resize} | ||
/> | ||
<Annotations action={action} imageBuffer={imageBuffer} annotatingRef={annotatingRef} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it work if this was like:
<Annotations action={action} imageBuffer={imageBuffer} annotatingRef={annotatingRef} /> | |
{action === 'annotate' ? <Annotations imageBuffer={imageBuffer} annotatingRef={annotatingRef} /> : null} |
same for options._experiments.annotations || action === 'crop' ? <Crop> : null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no it does not :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
splitting into multiple files is a big help. We could probably do something about the number of props, but i'd need too look more closely first.
This works and is an improvement, so i'm all for 🚢
if (action !== 'crop') { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When/why would this component get a non crop
action?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's in a useEffect with action as a dependency. This is done so that when you switch from cropping to the annotation tool, the above part of the code will run and clear the rectangle drawn around the image.
<button | ||
class={`editor__tool ${action === 'crop' ? 'editor__tool--active' : ''}`} | ||
onClick={e => { | ||
e.preventDefault(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the default behavior that this stops?
(you might need a type="button"
if it's submitting a form)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is submitting the form 😬
We are splitting up screenshot editor into 3 additional parts: cropping, annotations, toolbar