From be31598ed90b83ccde8e6179aace36bd22b15498 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Thu, 4 Aug 2016 04:08:12 -0400 Subject: [PATCH] Add TruncatedText component --- js/component/common.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/js/component/common.js b/js/component/common.js index 467899508..b914b860e 100644 --- a/js/component/common.js +++ b/js/component/common.js @@ -11,6 +11,22 @@ var Icon = React.createClass({ } }); +var TruncatedText = React.createClass({ + propTypes: { + limit: React.PropTypes.string, + }, + getDefaultProps: function() { + return { + limit: 250, + } + }, + render: function() { + var text = this.props.children; + var limit = this.props.limit; + return {text.slice(0, limit) + (text.length > limit ? ' ...' : '')}; + } +}); + var toolTipStyle = { position: 'absolute', zIndex: '1',