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-animate-loader

v0.1.7

Published

An animated sleek loader for react components

Downloads

18

Readme

react-animate-loader

A animated sleek loader for react components

GitHub license

A animated sleek loader for any HTML element / React component.

Install

yarn add react-animate-loader

# or

npm i react-animate-loader

Usage

import React from 'react';
import ReactAnimateLoader from 'react-animate-loader';



function App() {
  return (
    <ReactAnimateLoader>
      <div></div>
    </ReactAnimateLoader>
  );
}

How ReactAnimateLoader works?

  1. ReactAnimateLoader is applied as a wrapper to any HTML / React element. It could a single element or a set of elements.
  2. ReactAnimateLoader will loop through each if its children and check whether it's empty.
  3. If the child element is not empty, the element is rendered as it is. No loader is added.
  4. If the child element is empty, it will create an loader animation on the component as a :after pseudo element.
  5. The :after pseudo element has a white gradient background. The element moves from left to right of the parent element for a default time period of 1.2 seconds. The movement is repeated for an infinitely, generating a nice loading experience.
  6. The loader can be stopped by removing the ReactAnimateLoader wrapper to the HTML / React element.
  7. Additional customizations in terms of element background color, minimum height etc can be set via the style props of ReactAnimateLoader element.
  8. Additioncal customizations on animation color, animation duration etc can be set via CSS styling for the selector .react___block__loader:empty:after.

Why CSS :after pseudo approach?

The alternate to adding a pseudo element is to step into the internals of the HTML / React element and add a child which does the animation. This would mean that the library is manipulating the DOM of the element without knowing anything about the element. This might cause unintended consequences to the element resulting in override of the element behaviour.

To avoid such issues, the library uses CSS only approach to append a pseudo element and run the animation in the pseudo element. This way, the library is unaware of the internals of the HTML / React element and prove to be a generic module.

Criteria for ReactAnimateLoader

ReactAnimateLoader applies loading animation to each of its immediate children. In case the immediate children has it's own children or text content, ReactAnimateLoader does not get applied. The element should be empty for ReactAnimateLoader to kick-in.

Props

| Prop | Type | Required | Default | Description | | ------------------------- | --------------- | --------------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | style | React.CSSProperties | Optional | {minHeight:1.5rem,backgroundColor:#e2e2e2} | Custom CSS styling for children of ReactAnimateLoader component. |

View examples

npm install
npm run build # or use npm run build:watch
npm run start:examples

Local development

npm install
npm run build:watch
npm run start:examples

License

MIT