File tree Expand file tree Collapse file tree 7 files changed +43
-18
lines changed Expand file tree Collapse file tree 7 files changed +43
-18
lines changed Original file line number Diff line number Diff line change 55} from './screenshot' ;
66export type { FeedbackScreenshotIntegrationOptions } from './screenshot' ;
77
8- console . log ( 'screenshot 9 ' ) ;
8+ console . log ( 'screenshot 11 ' ) ;
Original file line number Diff line number Diff line change 11import { convertIntegrationFnToClass , defineIntegration } from '@sentry/core' ;
22import type { Integration , IntegrationClass , IntegrationFn } from '@sentry/types' ;
3- import { ScreenshotButton } from './screenshotWidget' ;
3+ import { ScreenshotButton } from './screenshotButton' ;
4+ import { ScreenshotWidget } from './screenshotWidget' ;
45import { GLOBAL_OBJ } from '@sentry/utils' ;
56import { h , render } from 'preact' ;
67
@@ -27,6 +28,9 @@ export const _feedbackScreenshotIntegration = ((options: Partial<FeedbackScreens
2728 return { el : options . el || WINDOW . document . createElement ( 'div' ) , props : options . props || null } ;
2829 } ,
2930 renderScreenshotWidget : ( options : FeedbackScreenshotOptions ) => {
31+ return render ( < ScreenshotWidget /> , options . el ) ;
32+ } ,
33+ renderScreenshotButton : ( options : FeedbackScreenshotOptions ) => {
3034 return render ( < ScreenshotButton /> , options . el ) ;
3135 } ,
3236 } ;
@@ -48,5 +52,6 @@ export const FeedbackScreenshot = convertIntegrationFnToClass(
4852 Integration & {
4953 getOptions : ( ) => FeedbackScreenshotIntegrationOptions ;
5054 renderScreenshotWidget : ( ) => void ;
55+ renderScreenshotButton : ( ) => void ;
5156 }
5257> ;
Original file line number Diff line number Diff line change 1+ import { Component , h } from 'preact' ;
2+
3+ export class ScreenshotButton extends Component {
4+ state = { clicked : false } ;
5+ handleClick = ( ) => {
6+ this . setState ( { clicked : ! this . state . clicked } ) ;
7+ } ;
8+ render ( ) {
9+ return (
10+ < label htmlFor = "screenshot" className = "form__label" >
11+ < span className = "form__label__text" > Screenshot</ span >
12+ < button class = "btn btn--default" type = "screenshot" onClick = { this . handleClick } >
13+ { this . state . clicked ? 'Remove' : 'Add' }
14+ </ button >
15+ </ label >
16+ ) ;
17+ }
18+ }
Original file line number Diff line number Diff line change 11import { h } from 'preact' ;
2-
32// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
4- export function ScreenshotButton ( ) {
5- return (
6- < label htmlFor = "screenshot" className = "form__label" >
7- < span className = "form__label__text" > Screenshot</ span >
8- < button class = "btn btn--default" type = "cancel" >
9- Add
10- </ button >
11- </ label >
12- ) ;
3+ export function ScreenshotWidget ( ) {
4+ return < div style = "height:100px; width: 100px; background:red;" /> ;
135}
Original file line number Diff line number Diff line change 55 feedbackIntegration ,
66} from './integration' ;
77
8- console . log ( 'Feedback 2 ' ) ;
8+ console . log ( 'Feedback 4 ' ) ;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import type { FormComponentProps } from './Form';
33import { Form } from './Form' ;
44import { Logo } from './Logo' ;
55import { createElement } from './util/createElement' ;
6+ import * as ScreenshotIntegration from '@sentry-internal/feedback-screenshot' ;
67
78export interface DialogProps
89 extends FormComponentProps ,
@@ -95,6 +96,14 @@ export function Dialog({
9596 return ( el && el . open === true ) || false ;
9697 }
9798
99+ const screenshot = createElement ( 'div' , { className : 'dialog-content' } ) ;
100+
101+ // @ts -expect-error temp
102+ ScreenshotIntegration . feedbackScreenshotIntegration ( ) . renderScreenshotWidget ( {
103+ el : screenshot ,
104+ props : null ,
105+ } ) ;
106+
98107 const {
99108 el : formEl ,
100109 showError,
@@ -119,6 +128,7 @@ export function Dialog({
119128 open : true ,
120129 onClick : handleDialogClick ,
121130 } ,
131+ screenshot ,
122132 createElement (
123133 'div' ,
124134 {
Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ export function Form({
140140 name : 'message' ,
141141 required : true ,
142142 className : 'form__input form__input--textarea' ,
143- placeholder : 'message placeholder' ,
143+ placeholder : messagePlaceholder ,
144144 } ) ;
145145
146146 const cancelEl = createElement (
@@ -156,11 +156,11 @@ export function Form({
156156 cancelButtonLabel ,
157157 ) ;
158158
159- const screenshot = createElement ( 'div' , { className : 'btn-group' } ) ;
159+ const button = createElement ( 'div' , { className : 'btn-group' } ) ;
160160
161161 // @ts -expect-error temp
162- ScreenshotIntegration . feedbackScreenshotIntegration ( ) . renderScreenshotWidget ( {
163- el : screenshot ,
162+ ScreenshotIntegration . feedbackScreenshotIntegration ( ) . renderScreenshotButton ( {
163+ el : button ,
164164 props : null ,
165165 } ) ;
166166
@@ -228,7 +228,7 @@ export function Form({
228228 ] ,
229229 ) ,
230230
231- screenshot ,
231+ button ,
232232
233233 createElement (
234234 'div' ,
You can’t perform that action at this time.
0 commit comments