From 8f743828ff2bbb2a12ae4dcc107c7997dca3c9d1 Mon Sep 17 00:00:00 2001 From: Matthew Benjamin Date: Tue, 27 Dec 2016 09:45:18 -0500 Subject: [PATCH 1/2] Added tertiaryText Option --- src/ListItem/ListItem.react.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/ListItem/ListItem.react.js b/src/ListItem/ListItem.react.js index 268c2886..6dfe7386 100644 --- a/src/ListItem/ListItem.react.js +++ b/src/ListItem/ListItem.react.js @@ -37,6 +37,7 @@ const propTypes = { PropTypes.shape({ primaryText: PropTypes.string.isRequired, secondaryText: PropTypes.string, + tertiaryText: PropTypes.string, }), ]), @@ -65,7 +66,11 @@ function getNumberOfSecondaryTextLines(numberOfLines) { function getNumberOfLines(props) { const { numberOfLines, centerElement } = props; - if (centerElement && centerElement.secondaryText && (!numberOfLines || numberOfLines < 2)) { + if (centerElement && centerElement.secondaryText && centerElement.tertiaryText + && (!numberOfLines || numberOfLines < 3)) { + return 3; + } else if (centerElement && centerElement.secondaryText && + (!numberOfLines || numberOfLines < 2)) { return 2; } @@ -160,6 +165,10 @@ function getStyles(props, context, state) { listItem.secondaryText, props.style.secondaryText, ], + tertiaryText: [ + listItem.tertiaryText, + props.style.secondaryText, + ], rightElementContainer: [ listItem.rightElementContainer, props.style.rightElementContainer, @@ -243,8 +252,9 @@ class ListItem extends PureComponent { } renderCenterElement = (styles) => { const { centerElement } = this.props; + console.log(this.state.numberOfLines) const numberOfLines = getNumberOfSecondaryTextLines(this.state.numberOfLines); - + console.log(numberOfLines) let content = null; if (React.isValidElement(centerElement)) { @@ -252,15 +262,17 @@ class ListItem extends PureComponent { } else if (centerElement) { let primaryText = null; let secondaryText = null; + let tertiaryText = null; if (typeof centerElement === 'string') { primaryText = centerElement; } else { primaryText = centerElement.primaryText; secondaryText = centerElement.secondaryText; + tertiaryText = centerElement.tertiaryText; } - - + const lineNumber = tertiaryText === undefined ? numberOfLines : 1; + console.log(lineNumber) content = ( @@ -272,16 +284,22 @@ class ListItem extends PureComponent { {secondaryText && - + {secondaryText} } + {tertiaryText && + + + {tertiaryText} + + + } ); } - return ( {content} From 23ff75a51b171926177a7fdf8084739e09d8b804 Mon Sep 17 00:00:00 2001 From: Matthew Benjamin Date: Wed, 28 Dec 2016 13:31:29 -0500 Subject: [PATCH 2/2] Removed logLines --- src/ListItem/ListItem.react.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/ListItem/ListItem.react.js b/src/ListItem/ListItem.react.js index 6dfe7386..87eeebb2 100644 --- a/src/ListItem/ListItem.react.js +++ b/src/ListItem/ListItem.react.js @@ -252,9 +252,7 @@ class ListItem extends PureComponent { } renderCenterElement = (styles) => { const { centerElement } = this.props; - console.log(this.state.numberOfLines) const numberOfLines = getNumberOfSecondaryTextLines(this.state.numberOfLines); - console.log(numberOfLines) let content = null; if (React.isValidElement(centerElement)) { @@ -272,7 +270,6 @@ class ListItem extends PureComponent { tertiaryText = centerElement.tertiaryText; } const lineNumber = tertiaryText === undefined ? numberOfLines : 1; - console.log(lineNumber) content = (