Skip to content

Commit c778e3f

Browse files
samuelmeulilex111
authored andcommitted
refactor(styled-components): migrate NewIssue (#836)
Migrated the `NewIssue` component to styled-components.
1 parent a2c3293 commit c778e3f

File tree

3 files changed

+50
-36
lines changed

3 files changed

+50
-36
lines changed

.all-contributorsrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,13 +835,23 @@
835835
"translation"
836836
]
837837
},
838+
{
838839
"login": "TFarla",
839840
"name": "Thomas Farla",
840841
"avatar_url": "https://avatars3.githubusercontent.com/u/4613944?v=4",
841842
"profile": "https://ilearned.today",
842843
"contributions": [
843844
"code"
844845
]
846+
},
847+
{
848+
"login": "samuelmeuli",
849+
"name": "Samuel Meuli",
850+
"avatar_url": "https://avatars0.githubusercontent.com/u/22477950?v=4",
851+
"profile": "https://samuelmeuli.com",
852+
"contributions": [
853+
"code"
854+
]
845855
}
846856
],
847857
"repoType": "github"

CONTRIBUTORS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ Thank you to all the people who have already contributed to GitPoint!
1919
| [<img src="https://avatars0.githubusercontent.com/u/3683673?v=4" width="100px;"/><br /><sub><b>TheCodeTalker</b></sub>](https://thecodetalker.github.io/)<br />[💻](https://github.com/gitpoint/git-point/commits?author=TheCodeTalker "Code") | [<img src="https://avatars0.githubusercontent.com/u/2670744?v=4" width="100px;"/><br /><sub><b>Leonardo</b></sub>](https://github.com/LeoCp)<br />[💻](https://github.com/gitpoint/git-point/commits?author=LeoCp "Code") | [<img src="https://avatars2.githubusercontent.com/u/13105865?v=4" width="100px;"/><br /><sub><b>Stephen</b></sub>](https://github.com/coderste)<br />[📖](https://github.com/gitpoint/git-point/commits?author=coderste "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/5565340?v=4" width="100px;"/><br /><sub><b>Zahra Traboulsi</b></sub>](http://www.zahra.tech)<br />[💻](https://github.com/gitpoint/git-point/commits?author=ZahraTee "Code") [⚠️](https://github.com/gitpoint/git-point/commits?author=ZahraTee "Tests") | [<img src="https://avatars3.githubusercontent.com/u/13391685?v=4" width="100px;"/><br /><sub><b>Joseba Carral</b></sub>](http://codevs.es)<br />[🌍](#translation-jcarral "Translation") | [<img src="https://avatars2.githubusercontent.com/u/5800039?v=4" width="100px;"/><br /><sub><b>CTownsdin</b></sub>](https://github.com/CTownsdin)<br />[💻](https://github.com/gitpoint/git-point/commits?author=CTownsdin "Code") |
2020
| [<img src="https://avatars0.githubusercontent.com/u/7470681?v=4" width="100px;"/><br /><sub><b>Apostolis Economou</b></sub>](https://github.com/apoeco)<br />[💻](https://github.com/gitpoint/git-point/commits?author=apoeco "Code") | [<img src="https://avatars3.githubusercontent.com/u/9337254?v=4" width="100px;"/><br /><sub><b>Arjun</b></sub>](https://github.com/Arjun-sna)<br />[💻](https://github.com/gitpoint/git-point/commits?author=Arjun-sna "Code") | [<img src="https://avatars1.githubusercontent.com/u/5786033?v=4" width="100px;"/><br /><sub><b>Riccardo</b></sub>](http://rkpasia.github.io)<br />[💻](https://github.com/gitpoint/git-point/commits?author=rkpasia "Code") [🎨](#design-rkpasia "Design") | [<img src="https://avatars3.githubusercontent.com/u/21980965?v=4" width="100px;"/><br /><sub><b>Luong Dang Hai</b></sub>](https://luongdanghai.com/)<br />[💻](https://github.com/gitpoint/git-point/commits?author=jarvisluong "Code") | [<img src="https://avatars3.githubusercontent.com/u/1428396?v=4" width="100px;"/><br /><sub><b>Jens Strobel</b></sub>](https://github.com/jstrobel)<br />[🐛](https://github.com/gitpoint/git-point/issues?q=author%3Ajstrobel "Bug reports") [🌍](#translation-jstrobel "Translation") | [<img src="https://avatars3.githubusercontent.com/u/3621147?v=4" width="100px;"/><br /><sub><b>James Gosbell</b></sub>](https://github.com/jamesg1)<br />[💻](https://github.com/gitpoint/git-point/commits?author=jamesg1 "Code") |
2121
| [<img src="https://avatars1.githubusercontent.com/u/11476348?v=4" width="100px;"/><br /><sub><b>Dhanial Rizky Wira Putra</b></sub>](https://github.com/dhamanutd)<br />[💻](https://github.com/gitpoint/git-point/commits?author=dhamanutd "Code") [🎨](#design-dhamanutd "Design") | [<img src="https://avatars1.githubusercontent.com/u/16650066?v=4" width="100px;"/><br /><sub><b>James Logue</b></sub>](https://github.com/jjlljj)<br />[💻](https://github.com/gitpoint/git-point/commits?author=jjlljj "Code") [⚠️](https://github.com/gitpoint/git-point/commits?author=jjlljj "Tests") | [<img src="https://avatars0.githubusercontent.com/u/22607072?v=4" width="100px;"/><br /><sub><b>parker lindley</b></sub>](https://github.com/etcetera8)<br />[💻](https://github.com/gitpoint/git-point/commits?author=etcetera8 "Code") [⚠️](https://github.com/gitpoint/git-point/commits?author=etcetera8 "Tests") | [<img src="https://avatars2.githubusercontent.com/u/22456673?v=4" width="100px;"/><br /><sub><b>Amanda Tjan</b></sub>](https://github.com/soytjan)<br />[💻](https://github.com/gitpoint/git-point/commits?author=soytjan "Code") [⚠️](https://github.com/gitpoint/git-point/commits?author=soytjan "Tests") | [<img src="https://avatars2.githubusercontent.com/u/10307875?v=4" width="100px;"/><br /><sub><b>Richie</b></sub>](https://github.com/whitedogg13)<br />[💻](https://github.com/gitpoint/git-point/commits?author=whitedogg13 "Code") | [<img src="https://avatars2.githubusercontent.com/u/10983824?v=4" width="100px;"/><br /><sub><b>Mario Arnautou</b></sub>](http://mario.arnautou.fr/)<br />[💻](https://github.com/gitpoint/git-point/commits?author=MarioArnt "Code") |
22-
| [<img src="https://avatars1.githubusercontent.com/u/31237758?v=4" width="100px;"/><br /><sub><b>Lenore</b></sub>](https://github.com/SpaceLenore)<br />[🌍](#translation-SpaceLenore "Translation") | [<img src="https://avatars0.githubusercontent.com/u/17492631?v=4" width="100px;"/><br /><sub><b>Geo Galagaran</b></sub>](http://geeofree.github.io)<br />[🌍](#translation-geeofree "Translation") | [<img src="https://avatars0.githubusercontent.com/u/2192460?v=4" width="100px;"/><br /><sub><b>Никола Радовановић (Nikola Radovanović)</b></sub>](http://www.toptal.com/resume/nikola-radovanovic)<br />[🌍](#translation-cobisimo "Translation") | [<img src="https://avatars3.githubusercontent.com/u/4613944?v=4" width="100px;"/><br /><sub><b>Thomas Farla</b></sub>](https://ilearned.today)<br />[💻](https://github.com/gitpoint/git-point/commits?author=TFarla "Code") |[<img src="https://avatars2.githubusercontent.com/u/26858034?s=400&u=fd8893b7f81dd9c9baeaf2807a1f7f98db0b2fe2&v=4" width="100px;"/><br /><sub><b>Huda Al Dallal</b></sub>](https://github.com/ooHAoo)<br />[🌍](#translation-ooHAoo "Translation") |
22+
| [<img src="https://avatars1.githubusercontent.com/u/31237758?v=4" width="100px;"/><br /><sub><b>Lenore</b></sub>](https://github.com/SpaceLenore)<br />[🌍](#translation-SpaceLenore "Translation") | [<img src="https://avatars0.githubusercontent.com/u/17492631?v=4" width="100px;"/><br /><sub><b>Geo Galagaran</b></sub>](http://geeofree.github.io)<br />[🌍](#translation-geeofree "Translation") | [<img src="https://avatars0.githubusercontent.com/u/2192460?v=4" width="100px;"/><br /><sub><b>Никола Радовановић (Nikola Radovanović)</b></sub>](http://www.toptal.com/resume/nikola-radovanovic)<br />[🌍](#translation-cobisimo "Translation") | [<img src="https://avatars2.githubusercontent.com/u/26858034?s=400&u=fd8893b7f81dd9c9baeaf2807a1f7f98db0b2fe2&v=4" width="100px;"/><br /><sub><b>Huda Al Dallal</b></sub>](https://github.com/ooHAoo)<br />[🌍](#translation-ooHAoo "Translation") | [<img src="https://avatars3.githubusercontent.com/u/4613944?v=4" width="100px;"/><br /><sub><b>Thomas Farla</b></sub>](https://ilearned.today)<br />[💻](https://github.com/gitpoint/git-point/commits?author=TFarla "Code") | [<img src="https://avatars0.githubusercontent.com/u/22477950?v=4" width="100px;"/><br /><sub><b>Samuel Meuli</b></sub>](https://samuelmeuli.com)<br />[💻](https://github.com/gitpoint/git-point/commits?author=samuelmeuli "Code") |
2323
<!-- ALL-CONTRIBUTORS-LIST:END -->

src/issue/screens/new-issue.screen.js

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,42 @@
22
import React, { Component } from 'react';
33
import { connect } from 'react-redux';
44
import { bindActionCreators } from 'redux';
5-
import { ScrollView, StyleSheet, TextInput, View, Alert } from 'react-native';
5+
import { Alert, ScrollView } from 'react-native';
66
import { ListItem } from 'react-native-elements';
7+
import styled from 'styled-components';
78

89
import { ViewContainer, SectionList, LoadingModal } from 'components';
910
import { t } from 'utils';
1011
import { colors, fonts, normalize } from 'config';
1112
import { submitNewIssue } from '../issue.action';
1213

13-
const styles = StyleSheet.create({
14-
textInput: {
15-
fontSize: normalize(12),
16-
marginHorizontal: 15,
17-
flex: 1,
18-
color: colors.black,
19-
...fonts.fontPrimary,
20-
},
21-
submitTitle: {
22-
color: colors.green,
23-
...fonts.fontPrimary,
24-
},
25-
listItemContainer: {
26-
flex: 1,
27-
},
28-
titleSmall: {
14+
const StyledListItem = styled(ListItem).attrs({
15+
titleStyle: {
2916
color: colors.primaryDark,
3017
...fonts.fontPrimarySemiBold,
3118
fontSize: normalize(10),
3219
},
33-
});
20+
})``;
21+
22+
const StyledTextInput = styled.TextInput`
23+
flex-grow: 1;
24+
height: ${props => Math.max(60, props.valueHeight)}
25+
margin: 0 15px;
26+
${fonts.fontPrimary};
27+
font-size: ${normalize(12)};
28+
color: ${colors.black};
29+
`;
30+
31+
const SubmitListItem = styled(ListItem).attrs({
32+
titleStyle: {
33+
color: colors.green,
34+
...fonts.fontPrimary,
35+
},
36+
})``;
37+
38+
const SubmitView = styled.View`
39+
flex-grow: 1;
40+
`;
3441

3542
const mapStateToProps = state => ({
3643
locale: state.auth.locale,
@@ -94,16 +101,20 @@ class NewIssue extends Component {
94101

95102
render() {
96103
const { locale, repository, isPendingSubmitting } = this.props;
97-
const { issueTitle, issueComment } = this.state;
104+
const {
105+
issueTitle,
106+
issueTitleHeight,
107+
issueComment,
108+
issueCommentHeight,
109+
} = this.state;
98110

99111
return (
100112
<ViewContainer>
101113
{isPendingSubmitting && <LoadingModal />}
102114
<ScrollView>
103115
{repository.full_name && (
104-
<ListItem
116+
<StyledListItem
105117
title={repository.full_name}
106-
titleStyle={styles.titleSmall}
107118
leftIcon={{
108119
name: 'repo',
109120
size: 17,
@@ -114,7 +125,7 @@ class NewIssue extends Component {
114125
/>
115126
)}
116127
<SectionList title={t('Issue Title', locale)}>
117-
<TextInput
128+
<StyledTextInput
118129
underlineColorAndroid={'transparent'}
119130
placeholder={t('Write a title for your issue here', locale)}
120131
blurOnSubmit
@@ -126,16 +137,13 @@ class NewIssue extends Component {
126137
}
127138
onChangeText={text => this.setState({ issueTitle: text })}
128139
placeholderTextColor={colors.grey}
129-
style={[
130-
styles.textInput,
131-
{ height: Math.max(60, this.state.issueTitleHeight) },
132-
]}
133140
value={issueTitle}
141+
valueHeight={issueTitleHeight}
134142
/>
135143
</SectionList>
136144

137145
<SectionList title={t('Issue Comment', locale)}>
138-
<TextInput
146+
<StyledTextInput
139147
underlineColorAndroid={'transparent'}
140148
placeholder={t('Write a comment for your issue here', locale)}
141149
multiline
@@ -146,24 +154,20 @@ class NewIssue extends Component {
146154
})
147155
}
148156
placeholderTextColor={colors.grey}
149-
style={[
150-
styles.textInput,
151-
{ height: Math.max(60, this.state.issueCommentHeight) },
152-
]}
153157
value={issueComment}
158+
valueHeight={issueCommentHeight}
154159
/>
155160
</SectionList>
156161

157162
<SectionList>
158-
<View style={styles.listItemContainer}>
159-
<ListItem
163+
<SubmitView>
164+
<SubmitListItem
160165
title={t('Submit', locale)}
161166
hideChevron
162167
underlayColor={colors.greyLight}
163-
titleStyle={styles.submitTitle}
164168
onPress={() => this.submitNewIssue()}
165169
/>
166-
</View>
170+
</SubmitView>
167171
</SectionList>
168172
</ScrollView>
169173
</ViewContainer>

0 commit comments

Comments
 (0)