// @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', } }