GeezerVison is showing github.com — ref(feedback): Let CropCorner inherit the existing h prop (#12814) · getsentry/sentry-javascript@aefbfaa
File treeExpand file treeCollapse file tree Open diff view settings packages/feedback/src/screenshot/components
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +38Lines changed: 38 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import type { VNode, h as hType } from 'preact'; | | 2 | + | | 3 | +interface FactoryParams { | | 4 | + h: typeof hType; | | 5 | +} | | 6 | + | | 7 | +export default function CropCornerFactory({ | | 8 | + h, // eslint-disable-line @typescript-eslint/no-unused-vars | | 9 | +}: FactoryParams) { | | 10 | + return function CropCorner({ | | 11 | + top, | | 12 | + left, | | 13 | + corner, | | 14 | + onGrabButton, | | 15 | + }: { | | 16 | + top: number; | | 17 | + left: number; | | 18 | + corner: string; | | 19 | + onGrabButton: (e: Event, corner: string) => void; | | 20 | + }): VNode { | | 21 | + return ( | | 22 | + <button | | 23 | + class={`editor__crop-corner editor__crop-corner--${corner} `} | | 24 | + style={{ | | 25 | + top: top, | | 26 | + left: left, | | 27 | + }} | | 28 | + onMouseDown={e => { | | 29 | + e.preventDefault(); | | 30 | + onGrabButton(e, corner); | | 31 | + }} | | 32 | + onClick={e => { | | 33 | + e.preventDefault(); | | 34 | + }} | | 35 | + ></button> | | 36 | + ); | | 37 | + }; | | 38 | +} |
Collapse file Copy file name to clipboardExpand all lines: packages/feedback/src/screenshot/components/ScreenshotEditor.tsx +3-30Lines changed: 3 additions & 30 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5,6 +5,7 @@ import type { ComponentType, VNode, h as hType } from 'preact'; | 5 | 5 | import { h } from 'preact'; // eslint-disable-line @typescript-eslint/no-unused-vars | 6 | 6 | import type * as Hooks from 'preact/hooks'; | 7 | 7 | import { DOCUMENT, WINDOW } from '../../constants'; | | 8 | +import CropCornerFactory from './CropCorner'; | 8 | 9 | import { createScreenshotInputStyles } from './ScreenshotInput.css'; | 9 | 10 | import { useTakeScreenshotFactory } from './useTakeScreenshot'; | 10 | 11 |
| @@ -64,7 +65,7 @@ const getContainedSize = (img: HTMLCanvasElement): Box => { | 64 | 65 | }; | 65 | 66 |
| 66 | 67 | export function ScreenshotEditorFactory({ | 67 | | - h, // eslint-disable-line @typescript-eslint/no-unused-vars | | 68 | + h, | 68 | 69 | hooks, | 69 | 70 | imageBuffer, | 70 | 71 | dialog, | @@ -74,6 +75,7 @@ export function ScreenshotEditorFactory({ | 74 | 75 |
| 75 | 76 | return function ScreenshotEditor({ onError }: Props): VNode { | 76 | 77 | const styles = hooks.useMemo(() => ({ __html: createScreenshotInputStyles().innerText }), []); | | 78 | + const CropCorner = CropCornerFactory({ h }); | 77 | 79 |
| 78 | 80 | const canvasContainerRef = hooks.useRef<HTMLDivElement>(null); | 79 | 81 | const cropContainerRef = hooks.useRef<HTMLDivElement>(null); | @@ -328,32 +330,3 @@ export function ScreenshotEditorFactory({ | 328 | 330 | ); | 329 | 331 | }; | 330 | 332 | } | 331 | | - | 332 | | -function CropCorner({ | 333 | | - top, | 334 | | - left, | 335 | | - corner, | 336 | | - onGrabButton, | 337 | | -}: { | 338 | | - top: number; | 339 | | - left: number; | 340 | | - corner: string; | 341 | | - onGrabButton: (e: Event, corner: string) => void; | 342 | | -}): VNode { | 343 | | - return ( | 344 | | - <button | 345 | | - class={`editor__crop-corner editor__crop-corner--${corner} `} | 346 | | - style={{ | 347 | | - top: top, | 348 | | - left: left, | 349 | | - }} | 350 | | - onMouseDown={e => { | 351 | | - e.preventDefault(); | 352 | | - onGrabButton(e, corner); | 353 | | - }} | 354 | | - onClick={e => { | 355 | | - e.preventDefault(); | 356 | | - }} | 357 | | - ></button> | 358 | | - ); | 359 | | -} |
|