Skip to content

Commit 43e0757

Browse files
author
Peter Piekarczyk
committed
update styles
1 parent a121a64 commit 43e0757

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/index.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
// @flow
22
import React from 'react'
3+
import type { StyleObj } from 'react-native/Libraries/StyleSheet/StyleSheetTypes'
34
import { View, Text, Image, StyleSheet } from 'react-native'
45

56
const styles = StyleSheet.create({
67
container: {
78
flexDirection: 'row-reverse',
9+
flexWrap: 'nowrap',
10+
justifyContent: 'center',
811
alignItems: 'center',
9-
backgroundColor: '#eee'
12+
alignSelf: 'center'
1013
},
1114
circle: {
1215
width: 20,
1316
height: 20,
14-
borderRadius: 10
17+
borderRadius: 10,
18+
marginBottom: 20
1519
},
1620
avatar: {
1721
width: 40,
@@ -25,17 +29,17 @@ const styles = StyleSheet.create({
2529
backgroundColor: '#b6c0ca',
2630
justifyContent: 'center',
2731
alignItems: 'center',
28-
marginLeft: 7
32+
marginLeft: 9
2933
},
3034
extraLabel: {
3135
color: '#333',
32-
fontSize: 14
36+
fontSize: 12
3337
}
3438
})
3539

3640
function renderFace (face, index) {
3741
return (
38-
<View key={index} style={styles.circle}>
42+
<View key={face.id || index} style={styles.circle}>
3943
<Image
4044
style={styles.avatar}
4145
source={{ uri: face.imageUrl }}
@@ -45,30 +49,32 @@ function renderFace (face, index) {
4549
)
4650
}
4751

48-
function renderAdditionalFaces (additionalFaces) {
52+
function renderoverflow (overflow) {
4953
return (
5054
<View style={styles.circle}>
5155
<View style={[styles.avatar, styles.extra]}>
5256
<Text style={styles.extraLabel}>
53-
+{additionalFaces}
57+
+{overflow}
5458
</Text>
5559
</View>
5660
</View>
5761
)
5862
}
5963

6064
type Face = {
61-
imageUrl: string
65+
imageUrl: string,
66+
id?: string
6267
}
6368

6469
type FacePileType = {
6570
faces: Array<Face>,
66-
additionalFaces: number
71+
overflow: number,
72+
containerStyle?: StyleObj
6773
}
6874

69-
const FacePile = ({ faces, additionalFaces }: FacePileType) =>
70-
<View style={styles.container}>
71-
{renderAdditionalFaces(additionalFaces)}
75+
const FacePile = ({ faces, overflow, containerStyle }: FacePileType) =>
76+
<View style={[styles.container, containerStyle]}>
77+
{renderoverflow(overflow)}
7278
{faces.map(renderFace)}
7379
</View>
7480

@@ -87,7 +93,7 @@ FacePile.defaultProps = {
8793
imageUrl: 'https://lorempixel.com/200/202/people'
8894
}
8995
],
90-
additionalFaces: 8
96+
overflow: 8
9197
}
9298

9399
export default FacePile

0 commit comments

Comments
 (0)