Skip to content

Commit 265e629

Browse files
(2.2) feat: Add Feedback Form UI Branding logo (#4357)
* Adds sentry branding logo as a base64 encoded png --------- Co-authored-by: LucasZF <[email protected]>
1 parent e0ec92d commit 265e629

File tree

6 files changed

+55
-4
lines changed

6 files changed

+55
-4
lines changed

packages/core/src/js/feedback/FeedbackForm.styles.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const defaultStyles: FeedbackFormStyles = {
1515
fontSize: 24,
1616
fontWeight: 'bold',
1717
marginBottom: 20,
18-
textAlign: 'center',
18+
textAlign: 'left',
19+
flex: 1,
1920
color: FORGROUND_COLOR,
2021
},
2122
label: {
@@ -57,6 +58,14 @@ const defaultStyles: FeedbackFormStyles = {
5758
color: FORGROUND_COLOR,
5859
fontSize: 16,
5960
},
61+
titleContainer: {
62+
flexDirection: 'row',
63+
width: '100%',
64+
},
65+
sentryLogo: {
66+
width: 40,
67+
height: 40,
68+
},
6069
};
6170

6271
export default defaultStyles;

packages/core/src/js/feedback/FeedbackForm.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as React from 'react';
44
import type { KeyboardTypeOptions } from 'react-native';
55
import {
66
Alert,
7+
Image,
78
Keyboard,
89
KeyboardAvoidingView,
910
SafeAreaView,
@@ -15,6 +16,7 @@ import {
1516
View
1617
} from 'react-native';
1718

19+
import { sentryLogo } from './branding';
1820
import { defaultConfiguration } from './defaults';
1921
import defaultStyles from './FeedbackForm.styles';
2022
import type { FeedbackFormProps, FeedbackFormState, FeedbackFormStyles,FeedbackGeneralConfiguration, FeedbackTextConfiguration } from './FeedbackForm.types';
@@ -104,7 +106,16 @@ export class FeedbackForm extends React.Component<FeedbackFormProps, FeedbackFor
104106
<ScrollView>
105107
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
106108
<View style={styles.container}>
107-
<Text style={styles.title}>{text.formTitle}</Text>
109+
<View style={styles.titleContainer}>
110+
<Text style={styles.title}>{text.formTitle}</Text>
111+
{config.showBranding && (
112+
<Image
113+
source={{ uri: sentryLogo }}
114+
style={styles.sentryLogo}
115+
testID='sentry-logo'
116+
/>
117+
)}
118+
</View>
108119

109120
{config.showName && (
110121
<>

packages/core/src/js/feedback/FeedbackForm.types.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import type { TextStyle, ViewStyle } from 'react-native';
1+
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native';
22

3+
/**
4+
* The props for the feedback form
5+
*/
36
export interface FeedbackFormProps extends FeedbackGeneralConfiguration, FeedbackTextConfiguration, FeedbackCallbacks {
47
styles?: FeedbackFormStyles;
58
}
@@ -8,6 +11,13 @@ export interface FeedbackFormProps extends FeedbackGeneralConfiguration, Feedbac
811
* General feedback configuration
912
*/
1013
export interface FeedbackGeneralConfiguration {
14+
/**
15+
* Show the Sentry branding
16+
*
17+
* @default true
18+
*/
19+
showBranding?: boolean;
20+
1121
/**
1222
* Should the email field be required?
1323
*/
@@ -128,6 +138,9 @@ export interface FeedbackCallbacks {
128138
onFormClose?: () => void;
129139
}
130140

141+
/**
142+
* The styles for the feedback form
143+
*/
131144
export interface FeedbackFormStyles {
132145
container?: ViewStyle;
133146
title?: TextStyle;
@@ -138,8 +151,13 @@ export interface FeedbackFormStyles {
138151
submitText?: TextStyle;
139152
cancelButton?: ViewStyle;
140153
cancelText?: TextStyle;
154+
titleContainer?: ViewStyle;
155+
sentryLogo?: ImageStyle;
141156
}
142157

158+
/**
159+
* The state of the feedback form
160+
*/
143161
export interface FeedbackFormState {
144162
isVisible: boolean;
145163
name: string;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* Base64 encoded PNG image of the Sentry logo (source https://sentry.io/branding/)
3+
*/
4+
export const sentryLogo =
5+
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAAC4BAMAAAB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itl99sVjSgITl/yk6Lk48JjfGadnanHml8xjMvFTA+eL42CRwDKEZwbm4rBMyAmdH6UEz8HDTPj4d4ie1EJxJCQg56DXaxKOl0iGz0jcdebZluzhbFSA1yEZ2JzbHZKQe3I/EK4CErTHbwn84ZP+8Poxqrd/+I2cXJAw0v9VAkBiI3DhLryZEe6SXNeJk5HcHFu+Aom5wiIn2a7niZiE1WKMUhIOhNFJSQZzh0VG8tPcQufLSQI46sO9vcM0NDQ0NDQ0NDQ0NHxF/AFGJOBYBWrb5gAAAABJRU5ErkJggg==';

packages/core/src/js/feedback/defaults.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const defaultConfiguration: Partial<FeedbackFormProps> = {
2929
},
3030

3131
// FeedbackGeneralConfiguration
32+
showBranding: true,
3233
isEmailRequired: false,
3334
shouldValidateEmail: true,
3435
isNameRequired: false,

packages/core/test/feedback/FeedbackForm.test.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ describe('FeedbackForm', () => {
4646
});
4747

4848
it('renders correctly', () => {
49-
const { getByPlaceholderText, getByText } = render(<FeedbackForm {...defaultProps} />);
49+
const { getByPlaceholderText, getByText, getByTestId } = render(<FeedbackForm {...defaultProps} />);
5050

5151
expect(getByText(defaultProps.formTitle)).toBeTruthy();
52+
expect(getByTestId('sentry-logo')).toBeTruthy(); // default showBranding is true
5253
expect(getByText(defaultProps.nameLabel)).toBeTruthy();
5354
expect(getByPlaceholderText(defaultProps.namePlaceholder)).toBeTruthy();
5455
expect(getByText(defaultProps.emailLabel)).toBeTruthy();
@@ -59,6 +60,12 @@ describe('FeedbackForm', () => {
5960
expect(getByText(defaultProps.cancelButtonLabel)).toBeTruthy();
6061
});
6162

63+
it('does not render the sentry logo when showBranding is false', () => {
64+
const { queryByTestId } = render(<FeedbackForm {...defaultProps} showBranding={false} />);
65+
66+
expect(queryByTestId('sentry-logo')).toBeNull();
67+
});
68+
6269
it('name and email are prefilled when sentry user is set', () => {
6370
const { getByPlaceholderText } = render(<FeedbackForm {...defaultProps} />);
6471

0 commit comments

Comments
 (0)