-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add a FormItem component for readability
- Loading branch information
1 parent
7786e12
commit 0915f2a
Showing
4 changed files
with
94 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React from 'react'; | ||
import RN from 'react-native'; | ||
|
||
import { MessageId } from '../../../../localization'; | ||
import colors from '../../../components/colors'; | ||
import fonts from '../../../components/fonts'; | ||
|
||
import Message from '../../../components/Message'; | ||
import IconButton from '../../../components/IconButton'; | ||
|
||
type FormButton = { | ||
testID: string; | ||
onClick: () => void; | ||
}; | ||
|
||
type Props = { | ||
labelMessageId: MessageId; | ||
button?: FormButton; | ||
style?: RN.StyleProp<RN.ViewStyle>; | ||
children: React.ReactNode; | ||
}; | ||
|
||
export const FormItem = ({ | ||
labelMessageId, | ||
button, | ||
children, | ||
style, | ||
}: Props) => { | ||
return ( | ||
<RN.View style={style ?? styles.dataContainer}> | ||
<RN.View style={styles.headerContainer}> | ||
<Message style={styles.fieldName} id={labelMessageId} /> | ||
{button && ( | ||
<IconButton | ||
badge={require('../../../images/pen.svg')} | ||
onPress={button.onClick} | ||
testID={button.testID} | ||
noShadow | ||
/> | ||
)} | ||
</RN.View> | ||
{children} | ||
</RN.View> | ||
); | ||
}; | ||
|
||
const styles = RN.StyleSheet.create({ | ||
dataContainer: { | ||
paddingVertical: 16, | ||
borderBottomColor: colors.formBorderGray, | ||
borderBottomWidth: 1, | ||
}, | ||
headerContainer: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
flex: 1, | ||
justifyContent: 'space-between', | ||
paddingTop: 16, | ||
}, | ||
fieldName: { | ||
...fonts.regularBold, | ||
color: colors.darkestBlue, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters