1.3.3 • Published 5 years ago
simple-text-ellipsis v1.3.3
Simple-Text-Ellipsis
Simple-Text-Ellipsis is an NPM module used to create simple text ellipsis' with React and Material UI.
Installation
Use Node's package manager npm to install in the root of the project you want to use the component.
npm install simple-text-ellipsisUsage
Using Character Example
import React from 'react';
import SimpleEllipsis from 'simple-text-ellipsis';
const yourComponent = () => {
const text = 'This is an example of using SimpleEllipsis component';
const count = 15;
const breakpoints = {
lg: { count: 20 }, // 'This is an example o...' displays at lg break point
xl: { count: 30 } // 'This is an example of using Si...' at xl break point
}; // 'This is an exam...' will display for all other break points since
// count prop is specified
const propsObject = { breakpoints, count, text };
return (
<React.Fragment>
<SimpleEllipsis {...propsObject} />
</React.Fragment>);
};
export default yourComponent;Using Words Example
import React from 'react';
import SimpleEllipsis from 'simple-text-ellipsis';
const yourComponent = () => {
const text = 'This is an example of using SimpleEllipsis component';
const truncatedBy = 'words';
const breakpoints = {
xs: { count: 3 }, // at xs break point, displays 'This is an...'
sm: { count: 6 } // at sm, displays 'This is an example of using...'
}; // will display entire text string for all other breakpoints since no
// count prop is specified
const propsObject = { breakpoints, text, truncatedBy };
return (
<React.Fragment>
<SimpleEllipsis {...propsObject} />
</React.Fragment>);
};
export default yourComponent;Props
allowShortenedWordsboolean: when truncating by characters, allow cutting off words. default truebreakpointsobject: breakpoints for specific Material UI breakpointsbreakpoints.xsobject: contains count key to override default prop of countbreakpoints.smobjectbreakpoints.mdobjectbreakpoints.lgobjectbreakpoints.xlobject
countnumber: character/word count to cut text off at; when not provided, text will not be truncatedellipsisstring: text to be displayed as ellipsis; defaults to '...', no ellipsis displayed if passed as nulltruncatedBystring: determing how count is used to truncate text; 'characters' or 'words'. defaults to 'characters'
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
1.3.3
5 years ago
1.3.2
6 years ago
1.3.0
6 years ago
1.2.0
6 years ago
1.1.0
6 years ago
1.0.0
6 years ago
0.0.15
6 years ago
0.0.14
6 years ago
0.0.13
6 years ago
0.0.12
6 years ago
0.0.11
6 years ago
0.0.10
6 years ago
0.0.9
6 years ago
0.0.8
6 years ago
0.0.7
6 years ago
0.0.6
6 years ago
0.0.5
6 years ago
0.0.4
6 years ago
0.0.3
6 years ago
0.0.2
6 years ago
0.0.1
6 years ago