-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(feedback): Let CropCorner inherit the existing h prop (#12814)
I noticed this after #12784, but the `<CropCorner>` wasn't inside the `ScreenshotEditorFactory()` function. So of course it wasn't getting access to the `h` ref that is passed in. That variable is what the `<div>` gets transpiled into -> it becomes `h.createElement('div')`. So what i'm doing is moving `CropCorner` into a `CropCornerFactory` so we can pass `h` in and hopefully not have the extra `import .. from 'preact';` in the 2nd bundle. Related to #12535
- Loading branch information
Showing
2 changed files
with
41 additions
and
30 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
packages/feedback/src/screenshot/components/CropCorner.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { VNode, h as hType } from 'preact'; | ||
|
||
interface FactoryParams { | ||
h: typeof hType; | ||
} | ||
|
||
export default function CropCornerFactory({ | ||
h, // eslint-disable-line @typescript-eslint/no-unused-vars | ||
}: FactoryParams) { | ||
return function CropCorner({ | ||
top, | ||
left, | ||
corner, | ||
onGrabButton, | ||
}: { | ||
top: number; | ||
left: number; | ||
corner: string; | ||
onGrabButton: (e: Event, corner: string) => void; | ||
}): VNode { | ||
return ( | ||
<button | ||
class={`editor__crop-corner editor__crop-corner--${corner} `} | ||
style={{ | ||
top: top, | ||
left: left, | ||
}} | ||
onMouseDown={e => { | ||
e.preventDefault(); | ||
onGrabButton(e, corner); | ||
}} | ||
onClick={e => { | ||
e.preventDefault(); | ||
}} | ||
></button> | ||
); | ||
}; | ||
} |
This file contains 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