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.
		
		
		
		
		
			
		
			
				
					46 lines
				
				821 B
			
		
		
			
		
	
	
					46 lines
				
				821 B
			| 
											3 years ago
										 | "use strict"; | ||
|  | 
 | ||
|  | exports.__esModule = true; | ||
|  | exports["default"] = ellipsis; | ||
|  | 
 | ||
|  | /** | ||
|  |  * 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' | ||
|  |  * } | ||
|  |  */ | ||
|  | function ellipsis(width) { | ||
|  |   if (width === void 0) { | ||
|  |     width = '100%'; | ||
|  |   } | ||
|  | 
 | ||
|  |   return { | ||
|  |     display: 'inline-block', | ||
|  |     maxWidth: width, | ||
|  |     overflow: 'hidden', | ||
|  |     textOverflow: 'ellipsis', | ||
|  |     whiteSpace: 'nowrap', | ||
|  |     wordWrap: 'normal' | ||
|  |   }; | ||
|  | } | ||
|  | 
 | ||
|  | module.exports = exports.default; |