npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-delete-row

v1.0.0

Published

A Reactjs component for rendering a table row with a delete button and fade effect.

Downloads

16

Readme

React Delete Row

A ReactJs UI component for rendering a table row with a delete button and fade effect.

Screenshot

ReactJs component for deleting a row in a table with a fade effect.

Try the Demo

Usage

  1. Install the react-delete-row module from npm.
npm install react-delete-row
  1. Render an array of data in a table, with the first table body <tr> defined with <ReactDeleteRow>.
import ReactDeleteRow from 'react-delete-row';

// ...

const App = () => {
  const data = [
    { title: 'One', body: 'one' },
    { title: 'Two', body: 'two' },
    { title: 'Three', body: 'three' }
  ];

  return (
    <table className="table">
        <thead>
            <tr>
                <th scope="col">Title</th>
                <th scope="col">Body</th>
                <th scope="col"></th>
            </tr>
        </thead>
        <tbody>
            { data.map((item, i) => { return (
            <ReactDeleteRow key={i} data={item} onDelete={ item => { return window.confirm(`Are you sure?`) }}>
                <td>{item.title}</td>
                <td>{item.body}</td>
            </ReactDeleteRow>
            )}) }
        </tbody>
    </table>
  );
}

Options

The following options are available on ReactDeleteRow:

  • data - Payload data to return in event handler callbacks (onDelete, etc).

  • className - CSS class to apply to the table row. Optional

  • iconClassName - CSS class to apply to the delete icon. Optional

  • delay - Number of milliseconds for the fade effect before removing the row from the DOM. Default is 300ms

  • deleteElement - String or JSX elements (HTML) to render for the delete icon. Default is 'X'

  • onDelete - Callback event handler for when the delete icon is clicked. Return TRUE to fade the row and remove from the DOM. Return FALSE to prevent removing the row. Optional

  • onDeleteComplete - Callback event handler for after the row has been removed from the DOM. Optional

Example Options

<ReactDeleteRow
  key={i}
  data={item}
  deleteElement={ <i className="fas fa-trash-alt" /> }
  iconClassName='text-danger'
  className='text-success'
  onDelete={ item => { return window.confirm(`Are you sure you want to delete "${item.title}"?`) }}>
    <td>{item.title}</td>
    <td>{item.body}</td>
</ReactDeleteRow>

Building the Library

To build the npm module, follow the steps below.

  1. Clone the repository.
  2. Open a terminal and navigate to the root folder.
  3. Run the command npm install.
  4. Run the command npm pack to test the tarball for the npm publish.

The contents from npm pack will include the /dist and /src folders, along with a package.json containing a main pointer to the file /dist/index.js.

You can also manually run the command npm run prepare to create a new build.

Running the Example

To run the example, follow the steps below.

  1. Clone the repository.
  2. Open a terminal and navigate to the folder test.
  3. Run the command npm install.
  4. Run the command npm start.

Notes

The component uses the CSS class fade to fade out the table row upon clicking. This can be overridden in your CSS to customize the animation effect.

.fade {
    opacity: 0;
    transition: opacity 500ms;
}

License

MIT

Author

Kory Becker http://www.primaryobjects.com/kory-becker