auto-ellipsis

1.3.0 • Public • Published

auto-ellipsis Build Status

auto-ellipsis is a React component for truncation when content overlength.

install

npm install auto-ellipsis

build

Auto-ellipsis use css-modules to resolve css in react. So you may use some plugin to deal with css-modules. If you use webpack, you just need use css-loader: css-loader?modules.

custom UI

Auto-ellipsis use react-css-modules, it provide a high-order component to make css-modules apply in React component painlessly. We can use css-loader?modules&localIdentName=[local]-[hash:base64:5] in dev, then we can base [local] to set our own styles. You set your own styles, pass styles as props to component. More check example.

principle

Auto-ellipsis use DOM Range to compute the suitable endPoint. Range is a dom element, so we continually compare dom bottom with Range bottom(dom is container) from the back forward. Finally, we find the position suit: dom Range bottom <= dom bottom.

demo

See demo.

LICENSE

MIT.

Package Sidebar

Install

npm i auto-ellipsis

Weekly Downloads

3

Version

1.3.0

License

MIT

Last publish

Collaborators

  • ustccjw