Skip to content

Commit

Permalink
Merge pull request #1417 from openmsupply/#1405-multiline-cell
Browse files Browse the repository at this point in the history
#1405 Multiline Cell component
  • Loading branch information
wlthomson authored Oct 21, 2019
2 parents f789909 + 352447b commit 74c90a7
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/widgets/DataTable/Cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,31 @@ import { getAdjustedStyle } from './utilities';
* @param {Object} textStyle Style object for the inner Text
* @param {Number} width optional flex property to inject into styles.
* @param {Bool} isLastCell Indicator for if this cell is the last
* @param {Number} maxLiens Maximum number of lines for the Text component
* in a row. Removing the borderRight if true.
*/
const Cell = React.memo(({ value, textStyle, viewStyle, width, isLastCell, debug }) => {
if (debug) console.log(`- Cell: ${value}`);
const internalViewStyle = getAdjustedStyle(viewStyle, width, isLastCell);
const Cell = React.memo(
({ value, textStyle, viewStyle, width, isLastCell, numberOfLines, debug }) => {
if (debug) console.log(`- Cell: ${value}`);
const internalViewStyle = getAdjustedStyle(viewStyle, width, isLastCell);

return (
<View style={internalViewStyle}>
<Text ellipsizeMode="tail" numberOfLines={1} style={textStyle}>
{value}
</Text>
</View>
);
});
return (
<View style={internalViewStyle}>
<Text ellipsizeMode="tail" numberOfLines={numberOfLines} style={textStyle}>
{value}
</Text>
</View>
);
}
);

Cell.propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
textStyle: PropTypes.object,
viewStyle: PropTypes.object,
width: PropTypes.number,
isLastCell: PropTypes.bool,
numberOfLines: PropTypes.number,
debug: PropTypes.bool,
};

Expand All @@ -43,6 +47,7 @@ Cell.defaultProps = {
viewStyle: {},
width: 0,
isLastCell: false,
numberOfLines: 2,
debug: false,
};

Expand Down

0 comments on commit 74c90a7

Please sign in to comment.