-
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.
[react] Fetch reactions to story for content card (#87)
* accidently forgot to branch * mergong * reactions added to the PreviewCard and ContentCard * prettier problems * minor change * fixed small error * Improve performence * Preload reactions * Clean up code * Make content card use string[] * Add null checks for preview length * Add reactions display component * Run prettier --------- Co-authored-by: Marcos Hernandez <[email protected]> Co-authored-by: Aditya Pawar <[email protected]> Co-authored-by: Aditya Pawar <[email protected]>
- Loading branch information
1 parent
e0ffb52
commit 70b0844
Showing
17 changed files
with
202 additions
and
71 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
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
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; |
Oops, something went wrong.