1.0.5 • Published 3 years ago

loading-wrapper v1.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Loading Wrapper

A React component that wraps a tree of components and renders a wrapper div element when provided when flag is true. The content can be blurred, overlayed, deactivated; and a custom loading indicator can be added in addition to aforementioned features.

Sample

Installation

npm install loading-wrapper

Usage

import React from 'react';
import { LoadingWrapper } from 'loading-wrapper';

const App = () => {
    const [loading, setLoading] = useState(false);

    const toggleLoading = () => setLoading(loading => !loading);

    return (
        <React.Fragment>
            <button onClick={toggleLoading}>Toggle Loading State</button>
                <LoadingWrapper
                    when={loading}
                    blur={2}
                    opacity={1}
                    indicator={<Spin size="large" />}
                    overlay="lightyellow"
                    cursor="progress"
                >
                    <SampleContent />
                </LoadingWrapper>
        </React.Fragment>
}

LoadingWrapper Props

PropTypeDefaultDescription
whenbooleanfalseControls when the following styles applied to the wrapped component
blurnumber2Pixel unit blur value for css blur() function
opacitynumber0.5Percentage unit opacity value for css opacity property
inactivebooleanfalseControls pointer-events and user-select css properties
overlaystringnoneBackground color of the wrapper component for custom indicator
cursorstringdefaultCursor value for css property cursor when mouse hovered on LoadingWrapper component
indicatorJSX.ElementnullCustom indicator that is rendered in the center of LoadingWrapper when = true
1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago