-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dbdb333
commit 96c582b
Showing
6 changed files
with
215 additions
and
148 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,82 @@ | ||
import React, { Fragment } from 'react'; | ||
import { | ||
View, | ||
Text, | ||
StyleSheet, | ||
StyleProp, | ||
ViewStyle, | ||
TextStyle, | ||
Platform, | ||
TouchableOpacity, | ||
GestureResponderEvent | ||
} from 'react-native'; | ||
import Divider from '../Divider'; | ||
import map from 'lodash/map'; | ||
import { colors } from '../utils'; | ||
|
||
export type CardActionsProps = { | ||
actions?: Array<{ | ||
text?: string; | ||
icon?: JSX.Element; | ||
onPress?: (e: GestureResponderEvent, index: number) => void; | ||
actionsTextStyle?: StyleProp<TextStyle> | ||
}>; | ||
actionsContainerStyle?: StyleProp<ViewStyle> | ||
children?: React.ReactNode; | ||
}; | ||
|
||
const CardActions = ({ | ||
actions = [], | ||
actionsContainerStyle, | ||
children | ||
}: CardActionsProps) => { | ||
return ( | ||
<Fragment> | ||
<Divider style={StyleSheet.flatten({ marginTop: 15 })} /> | ||
{React.isValidElement(children) ? React.cloneElement(children) : null} | ||
<View style={[styles.actionsContainer, actionsContainerStyle]}> | ||
{map(actions, (item, index) => { | ||
return ( | ||
<TouchableOpacity | ||
style={[styles.actionsTitleContainer, { marginLeft: index === 0 ? 0 : 10 }]} | ||
key={index} | ||
onPress={(event) => item.onPress && item.onPress(event, index)} | ||
> | ||
{item.icon && item.icon} | ||
{item.text && <Text style={[styles.actionsTitle, item.actionsTextStyle]}>{item.text}</Text>} | ||
</TouchableOpacity> | ||
); | ||
})} | ||
</View> | ||
</Fragment> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
actionsContainer: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
justifyContent: 'flex-end', | ||
paddingTop: 15, | ||
}, | ||
actionsTitleContainer: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
fontSize: 16, | ||
}, | ||
actionsTitle: { | ||
color: colors.colorsPalette.violet30, | ||
...Platform.select({ | ||
android: { | ||
fontFamily: 'sans-serif', | ||
fontWeight: 'bold', | ||
}, | ||
default: { | ||
fontWeight: 'bold', | ||
}, | ||
}), | ||
textAlign: 'center', | ||
}, | ||
}); | ||
|
||
export default CardActions |
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,58 @@ | ||
import React from 'react'; | ||
import { | ||
View, | ||
Text, | ||
StyleSheet, | ||
Platform, | ||
TextStyle, | ||
StyleProp | ||
} from 'react-native'; | ||
import { colors } from '../utils'; | ||
import Divider from '../Divider'; | ||
|
||
export type CardTitleProps = { | ||
title?: string; | ||
titleStyle?: StyleProp<TextStyle> | ||
children?: React.ReactNode; | ||
}; | ||
|
||
const CardTitle = ({ | ||
title, | ||
titleStyle, | ||
children | ||
}: CardTitleProps) => { | ||
return ( | ||
<View> | ||
{title && ( | ||
<Text testID="cardTitle" style={StyleSheet.flatten([styles.title, titleStyle]) as TextStyle}> | ||
{title} | ||
</Text> | ||
)} | ||
{React.isValidElement(children)?React.cloneElement(children):null} | ||
<Divider style={StyleSheet.flatten([styles.divider])} /> | ||
</View> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
title: { | ||
fontSize: 14, | ||
color: colors.colorsPalette.grey10, | ||
...Platform.select({ | ||
android: { | ||
fontFamily: 'sans-serif', | ||
fontWeight: 'bold', | ||
}, | ||
default: { | ||
fontWeight: 'bold', | ||
}, | ||
}), | ||
textAlign: 'center', | ||
marginBottom: 15, | ||
}, | ||
divider: { | ||
marginBottom: 15, | ||
} | ||
}); | ||
|
||
export default CardTitle |
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
Oops, something went wrong.