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

antd-spin

v2.0.1

Published

Enhancing Ant Design's Spin as a Service.

Downloads

41

Readme

antd-spin

NPM version Downloads License GitHub stars

Enhancing Ant Design's Spin as a Service. Inspired by Element Plus's Loading component.

Motivation

Enhance the Spin component of antd to support service calls, and the global state is a singleton mode.

Usage

Install

$ npm install antd-spin

Service

Import Spin service:

import { antdSpin } from "antd-spin";

Invoke it:

antdSpin.service(options);

The parameter options is the configuration of Spin, and its details can be found in the following table. SpinService returns a Spin instance, and you can close it by invoking its close method:

const spinInstance = antdSpin.service(options);
spinInstance.close();

Note that in this case the full screen Spin is singleton. If a new full screen Spin is invoked before an existing one is closed, the existing full screen Spin instance will be returned instead of actually creating another Spin instance:

const spinInstance1 = antdSpin.service();
const spinInstance2 = antdSpin.service();

// true
console.log(spinInstance1 === spinInstance2);

setTimeout(() => {
	// Calling the `close` method on any one of them can close this full screen Spin.
	spinInstance2.close();
}, 5000);

show time

singleton-mode

Directive

import { AntdSpin } from "antd-spin";

const DemoSpin = () => {
	return (
		<AntdSpin fullscreen={true} />
	);
}
  • fullscreen is true, return a fullscreen Spin.
  • fullscreen is false, return a Spin.

Options

| Name | Description | Type | Default | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------- | ------------- | | target | The DOM node Spin needs to cover. Accepts a DOM object or a string. If it's a string, it will be passed to document.querySelector to get the corresponding DOM node | string / HTMLElement | document.body | | fullscreen | Show a full screen Spin | boolean | true | | lock | Disable background scrolling | boolean | false | | background | Background color of the mask | string | — | | customClass | Custom class name for Spin | string | — | | spinProps | The properties of antd's Spin component | SpinProps | {} |

SpinProps

| Name | Type | Description | | --------------- | ------------------- | -------------------------------------------------------------------| | prefixCls | string | Prefix class name (optional) | | className | string | Class name (optional) | | rootClassName | string | Root element class name (optional) | | spinning | boolean | Whether to display the loading state | | style | React.CSSProperties | Custom style object (optional) | | size | SpinSize | Size (optional) | | tip | React.ReactNode | Tip content (optional) | | delay | number | Time in milliseconds to delay showing the loading state (optional) | | wrapperClassName| string | Wrapper element class name (optional) | | indicator | SpinIndicator | Custom loading indicator (optional) | | children | React.ReactNode | Child elements (optional) |