From 5925f11083fba073e742b18a7eb6d3da1eda6814 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Fri, 21 Oct 2016 06:28:42 -0400 Subject: [PATCH] Switch TruncatedText component to use clamp.js --- dist/index.html | 1 + js/component/common.js | 18 ++++++++++++++---- js/page/discover.js | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/dist/index.html b/dist/index.html index 96b9c1c52..3ecc0a4d2 100644 --- a/dist/index.html +++ b/dist/index.html @@ -23,6 +23,7 @@ + diff --git a/js/component/common.js b/js/component/common.js index ed15aac93..a751d4d8c 100644 --- a/js/component/common.js +++ b/js/component/common.js @@ -13,17 +13,27 @@ var Icon = React.createClass({ var TruncatedText = React.createClass({ propTypes: { - limit: React.PropTypes.number, + lines: React.PropTypes.number, + height: React.PropTypes.string, + auto: React.PropTypes.bool, }, getDefaultProps: function() { return { - limit: 250, + lines: null, + height: null, + auto: true, } }, + componentDidMount: function() { + console.log('span is', this.refs.span); + console.log('type of lines is', typeof this.props.lines) + $clamp(this.refs.span, { + clamp: this.props.lines || this.props.height || 'auto', + }); + }, render: function() { var text = this.props.children; - var limit = this.props.limit; - return {text.slice(0, limit) + (text.length > limit ? ' ...' : '')}; + return {text}; } }); diff --git a/js/page/discover.js b/js/page/discover.js index 0663175cb..89db1d7fa 100644 --- a/js/page/discover.js +++ b/js/page/discover.js @@ -122,7 +122,7 @@ var SearchResultRow = React.createClass({
lbry://{this.props.name}

- + {this.props.title} @@ -132,7 +132,7 @@ var SearchResultRow = React.createClass({

- + {this.props.description}