Created
November 4, 2017 11:48
-
-
Save bartolkaruza/b74f228636bb78fea00aa8bd82e3766d to your computer and use it in GitHub Desktop.
Tester component for quickly displaying various line height scenario's in React Native
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
import React from 'react'; | |
import {View, ScrollView, Text, Dimensions, Platform} from 'react-native'; | |
const {width, height} = Dimensions.get('window'); | |
const scenarios = [ | |
{ | |
lineHeight: 12, | |
fontSize: 15 | |
}, | |
{ | |
lineHeight: 15, | |
fontSize: 15 | |
}, | |
{ | |
lineHeight: 25, | |
fontSize: 15 | |
} | |
]; | |
const colors = [ | |
'green', 'blue', 'purple' | |
]; | |
export default function LineHeightTester() { | |
return ( | |
<ScrollView style={{ | |
width, | |
height, | |
...Platform.select({ios: {marginTop: 40}}) | |
}}> | |
<View> | |
{scenarios.map(({lineHeight, fontSize}, index) => | |
<View | |
style={{alignItems: 'center'}} | |
key={index}> | |
<Text | |
style={{ | |
fontSize, | |
lineHeight, | |
color: 'white', | |
width: 200, | |
backgroundColor: colors[index % colors.length] | |
}} | |
>{`fontSize: ${fontSize} lineHeight: ${lineHeight} \n\n Sed virtute consulatu appellantur et, minim deleniti nec ad, ei cum falli offendit. Ne mea vidisse dissentiunt. Pri at percipit mediocritatem. Cu eum atqui aliquam reformidans, cu his officiis disputationi.`} | |
</Text> | |
</View> | |
)} | |
</View> | |
</ScrollView> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment