You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							39 lines
						
					
					
						
							767 B
						
					
					
				
			
		
		
	
	
							39 lines
						
					
					
						
							767 B
						
					
					
				// @flow
 | 
						|
import type { Styles } from '../types/style'
 | 
						|
 | 
						|
/**
 | 
						|
 * CSS to represent truncated text with an ellipsis.
 | 
						|
 *
 | 
						|
 * @example
 | 
						|
 * // Styles as object usage
 | 
						|
 * const styles = {
 | 
						|
 *   ...ellipsis('250px')
 | 
						|
 * }
 | 
						|
 *
 | 
						|
 * // styled-components usage
 | 
						|
 * const div = styled.div`
 | 
						|
 *   ${ellipsis('250px')}
 | 
						|
 * `
 | 
						|
 *
 | 
						|
 * // CSS as JS Output
 | 
						|
 *
 | 
						|
 * div: {
 | 
						|
 *   'display': 'inline-block',
 | 
						|
 *   'maxWidth': '250px',
 | 
						|
 *   'overflow': 'hidden',
 | 
						|
 *   'textOverflow': 'ellipsis',
 | 
						|
 *   'whiteSpace': 'nowrap',
 | 
						|
 *   'wordWrap': 'normal'
 | 
						|
 * }
 | 
						|
 */
 | 
						|
export default function ellipsis(width?: string | number = '100%'): Styles {
 | 
						|
  return {
 | 
						|
    display: 'inline-block',
 | 
						|
    maxWidth: width,
 | 
						|
    overflow: 'hidden',
 | 
						|
    textOverflow: 'ellipsis',
 | 
						|
    whiteSpace: 'nowrap',
 | 
						|
    wordWrap: 'normal',
 | 
						|
  }
 | 
						|
}
 |