forked from alibaba/rax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Card.js
99 lines (94 loc) · 2.31 KB
/
Card.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import normalize from './normalizeText';
import {createElement} from 'rax';
import {View, Image} from 'rax-components';
import Platform from 'universal-platform';
import StyleSheet from 'universal-stylesheet';
import Divider from './Divider';
import colors from './colors';
import Text from './Text';
const Card = ({
children,
flexDirection,
containerStyle,
wrapperStyle,
title,
titleStyle,
dividerStyle,
image,
imageStyle,
fontFamily}) =>
<View style={[
styles.container,
image && {padding: 0},
containerStyle && containerStyle]}>
<View style={[styles.wrapper, wrapperStyle && wrapperStyle, flexDirection && {flexDirection}]}>
{
title && !image &&
<View>
<Text style={[
styles.cardTitle,
titleStyle && titleStyle,
fontFamily && {fontFamily}
]}>{title}</Text>
<Divider style={[styles.divider, dividerStyle && dividerStyle]} />
</View>
}
{
image &&
<View style={{flex: 1}}>
<Image
resizeMode="cover"
style={[{flex: 1, width: null, height: 150}, imageStyle && imageStyle]}
source={image} />
<View
style={[{padding: 10}, wrapperStyle && wrapperStyle]}>
{title && <Text style={[styles.imageTitle, titleStyle && titleStyle]}>{title}</Text>}
{children}
</View>
</View>
}
{ !image && children}
</View>
</View>
;
const styles = StyleSheet.create({
container: {
backgroundColor: 'white',
borderColor: colors.grey5,
borderWidth: 1,
padding: 15 * 2,
margin: 15 * 2,
marginBottom: 0,
...Platform.select({
ios: {
shadowColor: 'rgba(0,0,0, .2)',
shadowOffset: {height: 0, width: 0},
shadowOpacity: 1,
shadowRadius: 1
},
android: {
elevation: 1
}
})
},
imageTitle: {
fontSize: normalize(14 * 2),
marginBottom: 8 * 2,
color: colors.grey1,
fontWeight: '500'
},
wrapper: {
backgroundColor: 'transparent'
},
divider: {
marginBottom: 15 * 2
},
cardTitle: {
fontSize: normalize(14 * 2),
fontWeight: 'bold',
textAlign: 'center',
marginBottom: 15 * 2,
color: colors.grey1
}
});
export default Card;