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

@scrumble-nl/react-quick-loader

v1.0.2

Published

A quick and easy wrapper for retrieving information async while displaying a loader.

Downloads

1,031

Readme

Quick-Loader

A quick and easy wrapper for retrieving information async while displaying a loader

Quick

alt text

Installation

npm install @scrumble-nl/react-quick-loader

or

yarn add @scrumble-nl/react-quick-loader

Usage

This package makes a distinction by two types of usage.

  1. Retrieving data from an url
  2. Passing through data manually (useful if you want one api call and multiple loaders)

Both wil pass the data to the data property to all of their children. The actual implementations are as followed:

Url variant

  1. Import QuickLoader
  2. Implement the loader by giving it a color, url and at least one child component.
  3. (optional) add errorCallback for handling the potential ajax errors
import React from 'react';
import QuickLoader from '@scrumble-nl/react-quick-loader'; // Step 1

export default class MyComponent extends React.Component<{}, {}> {
    render = (): JSX.Element => {
        return (
            <QuickLoader color="#ff9933" url='/api/user'> // Step 2
                <MyComponent/>
            </Quickloader>     
        )
    }
}

The following options can be used for customization:

| Name | Type | Required | Description | Default | |--------------|:----------------------------------------------------------------------------------------:|:----------:|:-------------------------------------| -------- | | color | string | true | The color for the loader | | | url | string | true | The url used to retrieve data | | type | 'blank', 'balls', 'bars', 'bubbles', 'cubes', 'cylon', 'spin', 'spinningBubbles', 'spokes' | false | The loader type | bars | | errorCallback | (error: any) => void | false | The custom callback for handling the error message | undefined

Data variant

The actual implementation is as follows:

  1. Import QuickLoader
  2. Implement the loader by giving it a color, data and at least one child component
    1. As long as the data property is undefined it will show a loader
import React from 'react';
import axios from 'axios';
import QuickLoader from '@scrumble-nl/react-quick-loader'; // Step 1

export default class MyComponent extends React.Component<{}, {}> {
    
    state = {
        userOne: undefined,
        userTwo: undefined,
    };
    
    componentDidMount = (): void => {
        axios.get('/api/user')
            .then(response => {
                this.setState({
                    userOne: response.data[0],
                    userTwo: response.data[1],
                });
            })
            .catch(error => {
                console.log(':(');
            });
    };

    render = (): JSX.Element => {
        return (
            <>
                <QuickLoader color="#ff9933" data={this.state.userOne}> // Step 2 (step 3.1)
                    <MyComponent/>
                </Quickloader>
                <QuickLoader color="#ff9933" data={this.state.userTwo}> // Step 2 (step 3.1)
                    <MyComponent/>
                </Quickloader>
            </>
        )
    }
}

The following options can be used for customization:

| Name | Type | Required | Description | Default | |--------------|:----------------------------------------------------------------------------------------:|:----------:|:-------------------------------------| -------- | | color | string | true | The color for the loader | | | data | any | true | The data passed to the children | undefined| | type | 'blank', 'balls', 'bars', 'bubbles', 'cubes', 'cylon', 'spin', 'spinningBubbles', 'spokes' | false | The loader type | bars |

Additional customization

Next to that you can override the classes .spinner-container and .react-loading to change the look of the loader.

Roadmap

  • [x] Packagize component
  • [ ] Improve styling customizability
  • [ ] Automated testing implementation
  • [ ] Switch from interfaces to types
  • [ ] Improve scss usage

Contributing

If you would like to see additions/changes to this package you are always welcome to add some code or improve it.

Scrumble

This product has been originally developed by Scrumble for internal use. As we have been using lots of open source packages we wanted to give back to the community. We hope this helps you getting forward as much as other people helped us!