1.0.1 • Published 5 years ago

react-ellipsis-block v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

react-ellipsis-block

react element for ellipsis overflow that provides a title or tooltip only when hovered.

NPM JavaScript Style Guide

Demo

Live Demo

Install

Depends on ReactHooks, react 16.8+

npm install --save react-ellipsis-block

Usage

import React, { Component } from 'react'

import EllipsisBlock, {EllipsisBlockLazy} from 'react-ellipsis-block'

class Example extends Component {
  render () {
    const longTitleThatMightEllipse = "I'm a long title that might get ellipsis-ed? but we still need to know what it is.";
    return (
      <EllipsisBlock
        title={longTitleThatMightEllipse}
      >
        {longTitleThatMightEllipse}
      </EllipsisBlock>
      <EllipsisBlock
        title={longTitleThatMightEllipse}
        renderAs="h1" /* render with a different tag */
      >
        {longTitleThatMightEllipse}
      </EllipsisBlock>

      /* Lazy use block, uses a single resize event, and waits for window resizing to settle before setting state on the react components, This is better for longer lists of ellipsis elements, but extra overhead for one offs or just a few on a page. */
      <EllipsisBlockLazy
        title={longTitleThatMightEllipse}
      >
        {longTitleThatMightEllipse}
      </EllipsisBlockLazy>
      
    )
  }
}

License

MIT © rickeyward

contributing

Using create-react-library with hooks causes a weird issue running the example and the library at the same time, it makes you have 2 reacts, somehow. you MAY need to run

npm link example/node_modules/react

if you get an "using react hooks" error. due to reason on the list. Though I think this is fixed by asking the exaple to use the parent folder's node module, though this requires that the root npm install has already been ran before running example npm install.