1.2.0 • Published 4 months ago

carbon-neos-loadinganimation v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Carbon.NeosUi.LoadingAnimation

It’s important that users understand that things are happening when they have to wait for something. This loading timer can be used to provide feedback when there is a server response delay.

This is a small package to help create a nice loading animation in the Neos UI. There are three variants of the loading animation: One with a CSS file, one with StyleX, and one with pure inline style attributes. Use the one that best suits your stack.

How it looks

Visualization of animation

How to install

Based on your package manager run:

# npm
npm install carbon-neos-loadinganimation --save-dev
# pnpm
pnpm add carbon-neos-loadinganimation -D
# Yarn
yarn add carbon-neos-loadinganimation --dev

How to use

// Styled with inline styles
import { LoadingWithStyles } from "carbon-neos-loadinganimation";

// Styled with css classes
import { LoadingWithClassNames } from "carbon-neos-loadinganimation";

// Styled with styleX classes
import { LoadingWithStyleX } from "carbon-neos-loadinganimation";

You can also directly import the loader:

// Styled with inline styles
import LoadingAnimation from "carbon-neos-loadinganimation/LoadingWithStyles";

// Styled with css classes
import LoadingAnimation from "carbon-neos-loadinganimation/LoadingWithClassNames";

// Styled with styleX classes
import LoadingAnimation from "carbon-neos-loadinganimation/LoadingWithStyleX";

You can use the component inside react like this

import React, { useState, useEffect } from "react";
import LoadingAnimation from "carbon-neos-loadinganimation/LoadingWithStyles";

function Editor({ id, isLoading }) {
  const [isLoading, setIsLoading] = useState(true);

  useEffect(() => {
    setLoading(true);
    // Do your calls
    // ...
    setLoading(false);
  }, []);

  return <LoadingAnimation id={id} isLoading={isLoading} delayTime={2000} timeoutTime={7000} heightMultiplier={2} />;
}

Every component receives following props:

Property nameDefault valueDescription
isLoadingfalseThe main property. True will start the animation process.
delayTime500The time in ms after the circle animations starts.
timeoutTime5000The time in ms after the dots animations starts.
idnullThe id of the container
title'Neos.Neos:Main:loading'The title of the container. Will shown a tooltip. Will be translated
width60Controls the size of the animation

delayTime and timeoutTime should be positive. timeoutTime is the time after delayTime is finished.

How it works

After a certain time when the isLoading is set to true, determined by delayTime and timeoutTime, the timers changes his state. If isLoading is false, nothing is displayed at all.

                      ┌────────────────────┐
              ┌───────│     isLoading      │───────┐
              │       └────────────────────┘       │

            true                                 false

              │                                    │
              ▼                                    ▼
┌───────────────────────────┐        ┌───────────────────────────┐
│                           │        │       cancel timer        │
│       reserve space       │        │             +             │
│                           │        │        return null        │
└───────────────────────────┘        └───────────────────────────┘
              │

    after delayTime in ms

              │
              ▼
┌───────────────────────────┐
│                           │
│   show circle animation   │
│                           │
└───────────────────────────┘
              │

   after timeoutTime in ms

              │
              ▼
┌───────────────────────────┐
│                           │
│    show dots animation    │
│                           │
└───────────────────────────┘
1.2.0

4 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.0

9 months ago

0.1.2

9 months ago

0.1.1

9 months ago

0.1.0

9 months ago