包详细信息

react-loading-indicators

hane-smitter32.1kMIT1.0.1

Kit of elegant loading indicators for react applications

react, react-loading, react-spinners, react-loading-indicators

自述文件

react-loading-indicators

A kit of elegant loading indicators to enhance waiting experience of users when your system has something to do in the background for a while.

Built with Typescript. Type safety and improved DX guaranteed.

A demo for your insights

A glimpse of what is wrapped 🎁.
See DEMO page.

Installation

npm install react-loading-indicators

Components

<Atom />
<Commet />
<OrbitProgress />
<BlinkBlur />
<FourSquare />
<TrophySpin />
<ThreeDot />
<LifeLine />
<Mosaic />
<Riple />
<Slab />

Examples

Importing a loading indicator

import { Atom } from "react-loading-indicators";
/* 
| OR directly pull it 😎
| import Atom from "react-loading-indicators/Atom";
*/

const Loading = () => <Atom text="Loading..." />;

export default Loading;
<summary>Example usage</summary> jsx <Suspense fallback={<Loading />}> <Albums artistId={artist.id} /> </Suspense> Side note: You can use suspense for data fetching other than lazy loading.

Lighter build

This library is kept at fairly small. You have an option to even shrink further what you include from this library.
You can directly pull a loading indicator you want:

import React from "react";
import OrbitProgress from "react-loading-indicators/OrbitProgress";

const Loading = () => (
    <OrbitProgress variant="track-disc" color="crimson" size="small" />
);

export default Loading;

Props

Each of these components will accept the following optional props.

Name DataType Default Value Possible Values
size string medium small, medium, large
color string or array limegreen CSS color values
style object null CSS styles(in Reactjs format)
text string or boolean false Boolean value or string
textColor string undefined CSS color values
speedPlus number 0 Number in the range -5 through 5
easing string default ease function CSS easing function

What do these props do?

  • size - Sets the size of the loading indicator.
  • color - Sets the color of the loading indicator.
  • style - Applies CSS to the loading indicator. This will style the outer element that wraps an indicator.
  • text - Displays message in the loading indicator.
  • textColor - Sets the color of text message in the loading indicator.
  • speedPlus - Controls speed of animation. Negative values slows down. Positive numbers speeds up animation. 0 is normal speed.
  • easing - Controls the smoothness of the animation, altered with values such as linear, ease-in.

<OrbitProgress /> and <ThreeDot /> have more than one variant of loading animation. You can pick an alternative animation using a variant prop.

Name DataType
variant string

<OrbitProgress /> supports the following variants: dotted, spokes, disc, split-disc, track-disc. Defaults to disc.
<ThreeDot /> has the following variants: pulsate, bounce, bob, brick-stack. Defaults to pulsate.
You can have an interactive run-through of the variants in the DEMO site.

How to resize

You can resize a loading indicator to fit into your needs with the size prop that accepts predefined string values.
For more size customization, you can specify a fontSize property in the style prop. A valid value for the fontSize property will evenly alter the animation's size, for example:

const Loading = () => <ThreeDot style={{ fontSize: "8px" }} />;

License

Distributed under the MIT License. See LICENSE for more information.

Contact

@smitterhane

更新日志

1.0.0

  • All components can animate between colors when provided with an array in color prop.
  • Default color is used when invalid color is passed.
  • Shrinking indicator design for the <OrbitProgress variant="disc" /> indicator.
  • <Atom />, <Slab />, <Mosaic /> animations updated/improved.
  • Renamed indicators:
    • <OrbitProgress variant="bubble-dotted" /> - <OrbitProgress variant="spokes" />.
    • <ThreeDot variant="windmill" /> - <ThreeDot variant="bounce" />.
  • Improved algorithmic animation distribution in <BlinkBlur />.
  • Loading animations packaged directly at root.

0.2.0

  • New props: easing and speedPlus.
  • Updated readme.
  • Renamed indicators:
    • <CircularProgress /> - <OrbitProgress />
    • <Seek /> - <ThreeDot />
    • <GlidingBlink /> - <BlinkBlur />
    • <Twist /> - <TrophySpin />
    • <Pulse /> - <LifeLine />
  • New track-disc variant to <OrbitProgress />.
  • Variants prop on <ThreeDot />.
  • Refactor <BlinkBlur />.
  • Light build option.
  • Less files lib.

0.1.1

  • Update readme

0.1.0

  • New indicators GlidingBlink, Twist, Pulse & Slab.
  • Centralize default vars.
  • Fine tune Atom and Commet indicators.
  • Code refactor.
  • Tree-shaking optimization.

0.0.11

  • Configure global styles for storybook.
  • Fix text display on FourSquare loader.
  • Remove duplicated d-i-b css class and add rli-d-i-b as a global style.

0.0.10

  • Common props for all components.
  • New FourSquare loading indicator as a contribution.
  • Refactor FourSquare loader.

0.0.9

  • Fix split-disc component width.
  • Add homepage property to package.json.

0.0.8

  • Fix Stacking Context issues in Commet and Circular Progress(Disc variant) components.

0.0.7

  • Add style fixes to Atom Component.
  • Update README.md.
  • Renamed package from @hane-smitter/react-loading-indicator to react-loading-indicators.
  • Removed publishConfig property from package.json.
  • Added loaders keyword to package.json.

0.0.6

  • Modify peer deps to react version >=16.8.0

0.0.5

  • Fix default export not being exported from src/index.ts.

0.0.4

  • Replace div tags with span style them with display: inline-block; class(d-i-b).
  • Add styles variable to hold values of style prop.

0.0.3

  • Add src folder to files option in package.json. To fix error source maps error
  • Add CHANGELOG.md.
  • Add react and react-dom to both peerDependencies and devDependencies.
  • Update @rollup/plugin-typescript to version 8.3.3.