Skip to content

Commit 223c5e3

Browse files
committed
Button Component
1 parent 60f7239 commit 223c5e3

File tree

5 files changed

+52
-15
lines changed

5 files changed

+52
-15
lines changed

src/components/Button/Button.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react-native'
2+
import styles from './ButtonStyles'
3+
4+
// TODO :: Extend styles via receiving prop
5+
6+
class Button extends React.Component {
7+
_onPress() {
8+
this.props.onPress()
9+
}
10+
render() {
11+
return (
12+
<React.TouchableHighlight
13+
style={styles.container}
14+
onPress={this._onPress.bind(this)}>
15+
<React.Text style={styles.text}>{this.props.text}</React.Text>
16+
</React.TouchableHighlight>
17+
)
18+
}
19+
}
20+
Button.propTypes = {
21+
text: React.PropTypes.string.isRequired,
22+
onPress: React.PropTypes.func.isRequired,
23+
}
24+
25+
export default Button
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict'
2+
3+
import { StyleSheet } from 'react-native'
4+
5+
6+
export default StyleSheet.create({
7+
container: {
8+
marginTop: 20,
9+
backgroundColor: "#CCC",
10+
paddingTop: 10,
11+
paddingBottom: 10,
12+
borderRadius: 40,
13+
padding: 40,
14+
alignSelf: 'center',
15+
},
16+
text: {
17+
18+
},
19+
})

src/components/Button/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Button",
3+
"private": true,
4+
"main": "./Button.js"
5+
}

src/views/Home/Home.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import styles from './HomeStyles'
99
import SpotifyStore from '../../stores/SpotifyStore'
1010
import SpotifyActions from '../../actions/SpotifyActions'
1111
import ArtistList from '../../components/ArtistList'
12+
import Button from '../../components/Button'
1213

1314

1415
export default class Home extends ViewBase {
@@ -81,12 +82,8 @@ export default class Home extends ViewBase {
8182
<ArtistList
8283
artists={this.state.relatedArtists}
8384
onTapCreatePlaylist={this._createPlaylist.bind(this)}
84-
/>
85-
<React.TouchableHighlight
86-
style={styles.createPlaylistButton}
87-
onPress={this._discoverArtists.bind(this)}>
88-
<React.Text style={styles.loginButtonText}>Create Playlist</React.Text>
89-
</React.TouchableHighlight>
85+
/>
86+
<Button text="Create Playlist" onPress={this._createPlaylist}></Button>
9087
</React.View>
9188
)
9289
}

src/views/Home/HomeStyles.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,4 @@ export default StyleSheet.create({
1818
alignSelf: 'center',
1919
fontSize: 20,
2020
},
21-
createPlaylistButton: {
22-
marginTop: 20,
23-
backgroundColor: "#CCC",
24-
paddingTop: 10,
25-
paddingBottom: 10,
26-
borderRadius: 40,
27-
padding: 40,
28-
alignSelf: 'center',
29-
},
3021
})

0 commit comments

Comments
 (0)