-
Notifications
You must be signed in to change notification settings - Fork 1
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
4e1dd25
commit e2dd2a0
Showing
6 changed files
with
104 additions
and
42 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
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,60 @@ | ||
import { Text, View } from 'react-native'; | ||
import styles from './styles'; | ||
import Emoji from 'react-native-emoji'; | ||
import globalStyles from '../../styles/globalStyles'; | ||
|
||
type ReactionDisplayProps = { | ||
reactions: string[]; | ||
}; | ||
|
||
function ReactionDisplay({ reactions }: ReactionDisplayProps) { | ||
const reactionColors: Record<string, string> = { | ||
heart: '#FFCCCB', | ||
clap: '#FFD580', | ||
cry: '#89CFF0', | ||
hugging_face: '#ffc3bf', | ||
muscle: '#eddcf7', | ||
}; | ||
const defaultColor = reactionColors['heart']; | ||
const setOfReactions = [...reactions]; | ||
setOfReactions.push('heart'); | ||
setOfReactions.push('clap'); | ||
setOfReactions.push('muscle'); | ||
|
||
const reactionDisplay = [...new Set(setOfReactions)].slice(0, 3); | ||
|
||
return ( | ||
<View | ||
style={{ | ||
flexDirection: 'row', | ||
gap: -7, | ||
}} | ||
> | ||
{reactionDisplay.map(reaction => { | ||
return ( | ||
<View | ||
key={reaction} | ||
style={[ | ||
styles.reactions, | ||
{ | ||
backgroundColor: | ||
reaction in reactionColors | ||
? reactionColors[reaction] | ||
: defaultColor, | ||
}, | ||
]} | ||
> | ||
<Emoji name={reaction} /> | ||
</View> | ||
); | ||
})} | ||
<View style={styles.reactionNumber}> | ||
<Text style={[globalStyles.subtext, styles.reactionText]}> | ||
{reactions?.length ?? 0} | ||
</Text> | ||
</View> | ||
</View> | ||
); | ||
} | ||
|
||
export default ReactionDisplay; |
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,27 @@ | ||
import { StyleSheet } from 'react-native'; | ||
import colors from '../../styles/colors'; | ||
|
||
const styles = StyleSheet.create({ | ||
reactions: { | ||
width: 32, | ||
height: 32, | ||
borderRadius: 32 / 2, | ||
borderWidth: 1, | ||
backgroundColor: '#89CFF0', //different per emoji reaction | ||
borderColor: 'white', | ||
marginTop: 10, | ||
marginRight: -5, // -10 | ||
overflow: 'hidden', | ||
justifyContent: 'center', | ||
paddingLeft: 4, | ||
}, | ||
reactionText: { | ||
color: colors.grey, | ||
}, | ||
reactionNumber: { | ||
marginLeft: 16, | ||
marginTop: 16, | ||
}, | ||
}); | ||
|
||
export default styles; |
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