Guest User

Untitled

a guest
Jan 19th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. import React from 'react'
  2. import { Text as RNText, StyleSheet } from 'react-native'
  3. import colors from '~/constants/colors'
  4.  
  5. const styles = StyleSheet.create({
  6. base: {
  7. fontFamily: 'open-sans-regular',
  8. backgroundColor: 'transparent',
  9. color: colors.black,
  10. fontSize: 16
  11. },
  12. // Colors
  13. secondary: {
  14. color: colors.light
  15. },
  16. primary: {
  17. color: colors.primary
  18. },
  19. white: {
  20. color: colors.white
  21. },
  22. // Sizes
  23. xsmall: {
  24. fontSize: 12
  25. },
  26. small: {
  27. fontSize: 14
  28. },
  29. large: {
  30. fontSize: 18
  31. },
  32. xlarge: {
  33. fontSize: 20
  34. },
  35. // Highlights
  36. bold: {
  37. fontFamily: 'open-sans-bold'
  38. },
  39. light: {
  40. fontFamily: 'open-sans-light'
  41. },
  42. // Positioning
  43. centered: {
  44. textAlign: 'center'
  45. }
  46. })
  47.  
  48. export default class Text extends React.PureComponent {
  49. render () {
  50. const {
  51. style, children,
  52. size,
  53. primary, secondary, white,
  54. bold, light,
  55. centered,
  56. ...otherProps
  57. } = this.props
  58.  
  59. const passedStyle = [
  60. styles.base,
  61. primary && styles.primary,
  62. secondary && styles.secondary,
  63. white && styles.white,
  64. size && styles[size],
  65. light && styles.light,
  66. bold && styles.bold,
  67. centered && styles.centered,
  68. style
  69. ]
  70.  
  71. return (
  72. <RNText
  73. style={passedStyle}
  74. {...otherProps}
  75. >
  76. {children}
  77. </RNText>
  78. )
  79. }
  80. }
Add Comment
Please, Sign In to add comment