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 5
5
} from './screenshot' ;
6
6
export type { FeedbackScreenshotIntegrationOptions } from './screenshot' ;
7
7
8
- console . log ( 'screenshot 9 ' ) ;
8
+ console . log ( 'screenshot 11 ' ) ;
Original file line number Diff line number Diff line change 1
1
import { convertIntegrationFnToClass , defineIntegration } from '@sentry/core' ;
2
2
import type { Integration , IntegrationClass , IntegrationFn } from '@sentry/types' ;
3
- import { ScreenshotButton } from './screenshotWidget' ;
3
+ import { ScreenshotButton } from './screenshotButton' ;
4
+ import { ScreenshotWidget } from './screenshotWidget' ;
4
5
import { GLOBAL_OBJ } from '@sentry/utils' ;
5
6
import { h , render } from 'preact' ;
6
7
@@ -27,6 +28,9 @@ export const _feedbackScreenshotIntegration = ((options: Partial<FeedbackScreens
27
28
return { el : options . el || WINDOW . document . createElement ( 'div' ) , props : options . props || null } ;
28
29
} ,
29
30
renderScreenshotWidget : ( options : FeedbackScreenshotOptions ) => {
31
+ return render ( < ScreenshotWidget /> , options . el ) ;
32
+ } ,
33
+ renderScreenshotButton : ( options : FeedbackScreenshotOptions ) => {
30
34
return render ( < ScreenshotButton /> , options . el ) ;
31
35
} ,
32
36
} ;
@@ -48,5 +52,6 @@ export const FeedbackScreenshot = convertIntegrationFnToClass(
48
52
Integration & {
49
53
getOptions : ( ) => FeedbackScreenshotIntegrationOptions ;
50
54
renderScreenshotWidget : ( ) => void ;
55
+ renderScreenshotButton : ( ) => void ;
51
56
}
52
57
> ;
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 1
1
import { h } from 'preact' ;
2
-
3
2
// 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;" /> ;
13
5
}
Original file line number Diff line number Diff line change 5
5
feedbackIntegration ,
6
6
} from './integration' ;
7
7
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';
3
3
import { Form } from './Form' ;
4
4
import { Logo } from './Logo' ;
5
5
import { createElement } from './util/createElement' ;
6
+ import * as ScreenshotIntegration from '@sentry-internal/feedback-screenshot' ;
6
7
7
8
export interface DialogProps
8
9
extends FormComponentProps ,
@@ -95,6 +96,14 @@ export function Dialog({
95
96
return ( el && el . open === true ) || false ;
96
97
}
97
98
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
+
98
107
const {
99
108
el : formEl ,
100
109
showError,
@@ -119,6 +128,7 @@ export function Dialog({
119
128
open : true ,
120
129
onClick : handleDialogClick ,
121
130
} ,
131
+ screenshot ,
122
132
createElement (
123
133
'div' ,
124
134
{
Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ export function Form({
140
140
name : 'message' ,
141
141
required : true ,
142
142
className : 'form__input form__input--textarea' ,
143
- placeholder : 'message placeholder' ,
143
+ placeholder : messagePlaceholder ,
144
144
} ) ;
145
145
146
146
const cancelEl = createElement (
@@ -156,11 +156,11 @@ export function Form({
156
156
cancelButtonLabel ,
157
157
) ;
158
158
159
- const screenshot = createElement ( 'div' , { className : 'btn-group' } ) ;
159
+ const button = createElement ( 'div' , { className : 'btn-group' } ) ;
160
160
161
161
// @ts -expect-error temp
162
- ScreenshotIntegration . feedbackScreenshotIntegration ( ) . renderScreenshotWidget ( {
163
- el : screenshot ,
162
+ ScreenshotIntegration . feedbackScreenshotIntegration ( ) . renderScreenshotButton ( {
163
+ el : button ,
164
164
props : null ,
165
165
} ) ;
166
166
@@ -228,7 +228,7 @@ export function Form({
228
228
] ,
229
229
) ,
230
230
231
- screenshot ,
231
+ button ,
232
232
233
233
createElement (
234
234
'div' ,
You can’t perform that action at this time.
0 commit comments