Last active
July 2, 2021 12:10
-
-
Save itsashis4u/9edafdf30c6938da4bb734a573d29026 to your computer and use it in GitHub Desktop.
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
function Badge({ title }) { | |
const [discount, off] = title.split(' ') | |
return ( | |
<View style={{ margin: 10 }}> | |
<View style={badgeStyle.box3} /> | |
<View style={badgeStyle.box2} /> | |
<View style={badgeStyle.box1} /> | |
<View style={badgeStyle.main}> | |
<Text style={{ color: "white", fontWeight: 'bold' }}>{discount}</Text> | |
<Text style={{ color: "white", fontWeight: 'bold' }}>{off}</Text> | |
</View> | |
</View> | |
); | |
} | |
const badgeStyle = StyleSheet.create({ | |
box3: { | |
height: 40, | |
width: 40, | |
position: "absolute", | |
backgroundColor: "red", | |
borderRadius: 4, | |
transform: [ | |
{ | |
rotate: "67.5deg", | |
}, | |
], | |
}, | |
box2: { | |
height: 40, | |
width: 40, | |
borderRadius: 4, | |
backgroundColor: "red", | |
position: "absolute", | |
transform: [ | |
{ | |
rotate: "22.5deg", | |
}, | |
], | |
}, | |
box1: { | |
height: 40, | |
width: 40, | |
borderRadius: 4, | |
backgroundColor: "red", | |
position: "absolute", | |
transform: [ | |
{ | |
rotate: "45deg", | |
}, | |
], | |
}, | |
main: { | |
height: 40, | |
width: 40, | |
borderRadius: 4, | |
backgroundColor: "red", | |
justifyContent: 'center', | |
alignItems: 'center', | |
overflow: 'hidden' | |
}, | |
}); | |
<Badge title="50% off"/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment