Giter Club home page Giter Club logo

react-ellipsis-block's Introduction

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.

react-ellipsis-block's People

Contributors

dependabot[bot] avatar rickeyward avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.