Example #1
0
module.exports = function truncate(string, opt) {

    // Asserting
    assertArgument(isVoid(string) || isString(string), 1, 'string');
    assertArgument(isVoid(opt) || isObject(opt), 2, 'Object');

    // Returning
    return string ? _truncate(string, opt) : '';
};
Example #2
0
  render() {
    const { branchName } = this.props;

    return(
      <S.Branch>
        <S.Icon icon={faCodeBranch} />
        {truncate(branchName, {length: 48, separator: '...'})}
      </S.Branch>
    )
  }
Example #3
0
const ArticleNavigation = ({ next, prev }) => {
  return (
    <Pager className={classnames(styles.root, styles.pager)}>
      {next ? (
        <LinkContainer to={next.url} title={`Next Article: ${next.title}`}>
          <Pager.Item next>
            {truncate(next.title, { length: 30 })}
            {' '}
            <Octicon name='chevron-right' className={styles.icon} />
          </Pager.Item>
        </LinkContainer>
      ) : null}
      {prev ? (
        <LinkContainer to={prev.url} title={`Previous Article: ${prev.title}`}>
          <Pager.Item previous>
            <Octicon name='chevron-left' className={styles.icon} />
            {' '}
            {truncate(prev.title, { length: 30 })}
          </Pager.Item>
        </LinkContainer>
      ) : null}
    </Pager>
  )
}
Example #4
0
 render() {
   return (
     <View>
       <View style={styles.basketCardContainer}>
         <View style={{ flexDirection: 'row', alignItems: 'center' }}>
           <Image style={styles.thumbnail} source={this.props.source} />
           <View style={styles.separator} />
           <View style={styles.basketCardSubContainer}>
             <View style={styles.topContainer}>
               <Title font={font} size={12} weight="500">
                 {truncate(this.props.name.toUpperCase(), { length: 19 })}
                 <Title font={font} size={8} weight="600" color="rgba(72, 72, 72, 0.4)">
                   &nbsp;/&nbsp;{this.props.brand.toUpperCase()}
                 </Title>
               </Title>
               <TouchableOpacity
                 style={{ marginRight: 10, marginTop: -8 }}
                 onPress={this.props.onPressDeleteProduct}
               >
                 <Title
                   font={font}
                   weight="600"
                   size={10}
                   color={Colors.red}
                   style={{ marginTop: 5 }}
                 >
                   {translate('remove_product')}
                 </Title>
               </TouchableOpacity>
             </View>
             <View style={styles.bottomContainer}>
               <View style={{ flex: 1, flexDirection: 'column' }}>
                 <TouchableOpacity onPress={this.props.onPressViewProduct}>
                   <Title
                     font={font}
                     weight="300"
                     size={11}
                     color="#484848"
                     style={{ marginTop: 5 }}
                   >
                     {translate('see_product')}
                   </Title>
                 </TouchableOpacity>
                 <View style={{ marginTop: 5, flex: 1 }}>
                   {this.props.selectedOptions.map(selectedOption => (
                     <View key={selectedOption.id} style={styles.optionContainer}>
                       <Title
                         style={{ marginRight: 5 }}
                         font={font}
                         size={8}
                         color="rgba(71,71,71,0.6)"
                         weight="600"
                       >
                         {selectedOption.option.name.toUpperCase()}
                       </Title>
                       <Title
                         font={font}
                         size={11}
                         color="rgba(71,71,71,0.8)"
                         weight="600"
                       >
                         {selectedOption.value.name}
                       </Title>
                     </View>
                   ))}
                 </View>
               </View>
               {this.isValid() ? (
                 <TouchableOpacity
                   onPress={this.promptQuantity}
                   style={styles.quantityContainer}
                 >
                   <Title font={font} size={28} color="rgba(0,0,0,0.7)" weight="300">
                     {this.props.quantity}
                   </Title>
                 </TouchableOpacity>
               ) : null}
             </View>
           </View>
         </View>
       </View>
       {this.isValid() ? <SubTotal totalPrice={this.props.totalPrice} /> : null}
       {!this.isValid() ? (
         <ItemDeletedSubBanner
           text={
             this.props.isDeleted
               ? translate('product_deleted')
               : translate('product_not_available')
           }
         />
       ) : null}
     </View>
   );
 }
Example #5
0
function prepareNotificationText(text) {
  return truncate(text, { length: 50 }).replace('\n', ' ');
}
 {communications.map((com, idx) =>
   (<MenuItem
     value={com.id}
     key={idx}
     primaryText={truncate(com.objet, { length: 40 })}
   />)