/** * Copyright 2004-present Facebook. All Rights Reserved. * * @providesModule TextExample */ 'use strict'; var React = require('react-native'); var { StyleSheet, Text, View, } = React; var Entity = React.createClass({ render: function() { return ( {this.props.children} ); } }); var AttributeToggler = React.createClass({ getInitialState: function() { return {fontWeight: 'bold', fontSize: 15}; }, increaseSize: function() { this.setState({ fontSize: this.state.fontSize + 1 }); }, render: function() { var curStyle = {fontSize: this.state.fontSize}; return ( Tap the controls below to change attributes. See how it will even work on{' '} this nested text {'>> Increase Size <<'} ); } }); exports.title = ''; exports.description = 'Base component for rendering styled text.'; exports.examples = [ { title: 'Wrap', render: function() { return ( The text should wrap if it goes on multiple lines. See, this is going to the next line. ); }, }, { title: 'Font Family', render: function() { return ( Cochin Cochin bold Helvetica Helvetica bold Verdana Verdana bold ); }, }, { title: 'Font Size', render: function() { return ( Size 23 Size 8 ); }, }, { title: 'Color', render: function() { return ( Red color Blue color ); }, }, { title: 'Font Weight', render: function() { return ( Move fast and be bold ); }, }, { title: 'Nested', description: 'Nested text components will inherit the styles of their ' + 'parents (only backgroundColor is inherited from non-Text parents). ' + ' only supports other and raw text (strings) as children.', render: function() { return ( (Normal text, (and bold (and tiny inherited bold blue) ) ) Entity Name ); }, }, { title: 'Text Align', render: function() { return ( left left left left left left left left left left left left left left left center center center center center center center center center center center right right right right right right right right right right right right right ); }, }, { title: 'Spaces', render: function() { return ( A {'generated'} {' '} {'string'} and some     spaces ); }, }, { title: 'Line Height', render: function() { return ( A lot of space between the lines of this long passage that should wrap once. ); }, }, { title: 'Empty Text', description: 'It\'s ok to have Text with zero or null children.', render: function() { return ( ); }, }, { title: 'Toggling Attributes', render: function() { return ; }, }, { title: 'backgroundColor attribute', description: 'backgroundColor is inherited from all types of views.', render: function() { return ( Yellow background inherited from View parent, {' '}red background, {' '}blue background, {' '}inherited blue background, {' '}nested green background. ); }, }, { title: 'containerBackgroundColor attribute', render: function() { return ( Default containerBackgroundColor (inherited) + backgroundColor wash {"containerBackgroundColor: 'transparent' + backgroundColor wash"} ); }, }, { title: 'numberOfLines attribute', render: function() { return ( Maximum of one line no matter now much I write here. If I keep writing it{"'"}ll just truncate after one line Maximum of two lines no matter now much I write here. If I keep writing it{"'"}ll just truncate after two lines No maximum lines specified no matter now much I write here. If I keep writing it{"'"}ll just keep going and going ); }, }]; var styles = StyleSheet.create({ backgroundColorText: { left: 5, backgroundColor: 'rgba(100, 100, 100, 0.3)' }, entity: { fontWeight: 'bold', color: '#527fe4', }, });