diff --git a/src/ObjectDescription.js b/src/ObjectDescription.js index 185dd6e..4e3b13a 100644 --- a/src/ObjectDescription.js +++ b/src/ObjectDescription.js @@ -1,5 +1,11 @@ import React, { Component } from 'react'; +function shortenString(str) { + return str.length > 100 ? + str.substr(0, 50) + '…' + str.substr(-50) : + str; +} + /** * A short description of the object */ @@ -10,7 +16,9 @@ export default class ObjectDescription extends Component{ case 'number': return ({object}); case 'string': - return ("{object}"); + return ( + "{this.props.preview ? shortenString(object) : object}" + ); case 'boolean': return ({String(object)}); // why simple {object} won't work? case 'undefined': diff --git a/src/ObjectPreview.js b/src/ObjectPreview.js index 4e6e3ac..e5bf476 100644 --- a/src/ObjectPreview.js +++ b/src/ObjectPreview.js @@ -54,7 +54,7 @@ export default class ObjectPreview extends Component { {propertyName} :  - + {ellipsis} );