Skip to content

Commit 8dbd500

Browse files
committed
screenshot button and widget placeholders
1 parent 7d9b800 commit 8dbd500

File tree

7 files changed

+43
-18
lines changed

7 files changed

+43
-18
lines changed

packages/feedback-screenshot/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ export {
55
} from './screenshot';
66
export type { FeedbackScreenshotIntegrationOptions } from './screenshot';
77

8-
console.log('screenshot 9');
8+
console.log('screenshot 11');

packages/feedback-screenshot/src/screenshot.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { convertIntegrationFnToClass, defineIntegration } from '@sentry/core';
22
import type { Integration, IntegrationClass, IntegrationFn } from '@sentry/types';
3-
import { ScreenshotButton } from './screenshotWidget';
3+
import { ScreenshotButton } from './screenshotButton';
4+
import { ScreenshotWidget } from './screenshotWidget';
45
import { GLOBAL_OBJ } from '@sentry/utils';
56
import { 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
>;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
}
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
import { 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
}

packages/feedback/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ export {
55
feedbackIntegration,
66
} from './integration';
77

8-
console.log('Feedback 2');
8+
console.log('Feedback 4');

packages/feedback/src/widget/Dialog.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { FormComponentProps } from './Form';
33
import { Form } from './Form';
44
import { Logo } from './Logo';
55
import { createElement } from './util/createElement';
6+
import * as ScreenshotIntegration from '@sentry-internal/feedback-screenshot';
67

78
export 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
{

packages/feedback/src/widget/Form.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff 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',

0 commit comments

Comments
 (0)