Skip to content

Commit 4b5df7a

Browse files
committed
Adds input text labels
1 parent a169362 commit 4b5df7a

File tree

5 files changed

+60
-5
lines changed

5 files changed

+60
-5
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ const defaultStyles = StyleSheet.create({
1212
marginBottom: 20,
1313
textAlign: 'center',
1414
},
15+
label: {
16+
marginBottom: 4,
17+
fontSize: 16,
18+
},
1519
input: {
1620
height: 50,
1721
borderColor: '#ccc',

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@ import { Alert, Text, TextInput, TouchableOpacity, View } from 'react-native';
77
import {
88
CANCEL_BUTTON_LABEL,
99
EMAIL_ERROR,
10+
EMAIL_LABEL,
1011
EMAIL_PLACEHOLDER,
1112
ERROR_TITLE,
1213
FORM_ERROR,
1314
FORM_TITLE,
15+
IS_REQUIRED_LABEL,
16+
MESSAGE_LABEL,
1417
MESSAGE_PLACEHOLDER,
18+
NAME_LABEL,
1519
NAME_PLACEHOLDER,
1620
SUBMIT_BUTTON_LABEL} from './constants';
1721
import defaultStyles from './FeedbackForm.styles';
1822
import type { FeedbackFormProps, FeedbackFormState } from './FeedbackForm.types';
23+
import LabelText from './LabelText';
1924

2025
/**
2126
* @beta
@@ -72,21 +77,37 @@ export class FeedbackForm extends React.Component<FeedbackFormProps, FeedbackFor
7277
<View style={styles?.container || defaultStyles.container}>
7378
<Text style={styles?.title || defaultStyles.title}>{text?.formTitle || FORM_TITLE}</Text>
7479

80+
<LabelText
81+
label={text?.nameLabel || NAME_LABEL}
82+
isRequired={true}
83+
isRequiredLabel={text?.isRequiredLabel || IS_REQUIRED_LABEL}
84+
styles={styles?.label || defaultStyles.label}
85+
/>
7586
<TextInput
7687
style={styles?.input || defaultStyles.input}
7788
placeholder={text?.namePlaceholder || NAME_PLACEHOLDER}
7889
value={name}
7990
onChangeText={(value) => this.setState({ name: value })}
8091
/>
81-
92+
<LabelText
93+
label={text?.emailLabel || EMAIL_LABEL}
94+
isRequired={true}
95+
isRequiredLabel={text?.isRequiredLabel || IS_REQUIRED_LABEL}
96+
styles={styles?.label || defaultStyles.label}
97+
/>
8298
<TextInput
8399
style={styles?.input || defaultStyles.input}
84100
placeholder={text?.emailPlaceholder || EMAIL_PLACEHOLDER}
85101
keyboardType={'email-address' as KeyboardTypeOptions}
86102
value={email}
87103
onChangeText={(value) => this.setState({ email: value })}
88104
/>
89-
105+
<LabelText
106+
label={text?.descriptionLabel || MESSAGE_LABEL}
107+
isRequired={true}
108+
isRequiredLabel={text?.isRequiredLabel || IS_REQUIRED_LABEL}
109+
styles={styles?.label || defaultStyles.label}
110+
/>
90111
<TextInput
91112
style={[styles?.input || defaultStyles.input, styles?.textArea || defaultStyles.textArea]}
92113
placeholder={text?.descriptionPlaceholder || MESSAGE_PLACEHOLDER}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ export interface FeedbackFormProps {
88

99
export interface FeedbackFormText {
1010
formTitle?: string;
11+
nameLabel?: string;
1112
namePlaceholder?: string;
13+
emailLabel?: string;
1214
emailPlaceholder?: string;
15+
descriptionLabel?: string;
1316
descriptionPlaceholder?: string;
17+
isRequiredLabel?: string;
1418
submitButton?: string;
1519
cancelButton?: string;
1620
errorTitle?: string;
@@ -21,6 +25,7 @@ export interface FeedbackFormText {
2125
export interface FeedbackFormStyles {
2226
container?: ViewStyle;
2327
title?: TextStyle;
28+
label?: TextStyle;
2429
input?: TextStyle;
2530
textArea?: ViewStyle;
2631
submitButton?: ViewStyle;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import type { TextStyle } from 'react-native';
3+
import { Text } from 'react-native';
4+
5+
interface LabelTextProps {
6+
label: string;
7+
isRequired: boolean;
8+
isRequiredLabel: string;
9+
styles: TextStyle;
10+
}
11+
12+
const LabelText: React.FC<LabelTextProps> = ({ label, isRequired, isRequiredLabel, styles }) => {
13+
return (
14+
<Text style={styles}>
15+
{label}
16+
{isRequired && ` ${isRequiredLabel}`}
17+
</Text>
18+
);
19+
};
20+
21+
export default LabelText;

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
export const FORM_TITLE = 'Report a Bug';
2-
export const NAME_PLACEHOLDER = 'Name';
3-
export const EMAIL_PLACEHOLDER = 'Email';
4-
export const MESSAGE_PLACEHOLDER = 'Description';
2+
export const NAME_PLACEHOLDER = 'Your Name';
3+
export const NAME_LABEL = 'Name';
4+
export const EMAIL_PLACEHOLDER = '[email protected]';
5+
export const EMAIL_LABEL = 'Email';
6+
export const MESSAGE_PLACEHOLDER = "What's the bug? What did you expect?";
7+
export const MESSAGE_LABEL = 'Description';
8+
export const IS_REQUIRED_LABEL = '(required)';
59
export const SUBMIT_BUTTON_LABEL = 'Send Bug Report';
610
export const CANCEL_BUTTON_LABEL = 'Cancel';
711
export const ERROR_TITLE = 'Error';

0 commit comments

Comments
 (0)