Add TruncatedText component
This commit is contained in:
parent
aa2f48f359
commit
be31598ed9
1 changed files with 16 additions and 0 deletions
|
@ -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 <span>{text.slice(0, limit) + (text.length > limit ? ' ...' : '')}</span>;
|
||||
}
|
||||
});
|
||||
|
||||
var toolTipStyle = {
|
||||
position: 'absolute',
|
||||
zIndex: '1',
|
||||
|
|
Loading…
Add table
Reference in a new issue