New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

antd-spin

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

antd-spin

Enhancing Ant Design's Spin as a Service.

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by66.67%
Maintainers
1
Weekly downloads
 
Created
Source

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

NameDescriptionTypeDefault
targetThe 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 nodestring / HTMLElementdocument.body
fullscreenShow a full screen Spinbooleantrue
lockDisable background scrollingbooleanfalse
backgroundBackground color of the maskstring
customClassCustom class name for Spinstring
spinPropsThe properties of antd's Spin componentSpinProps{}
SpinProps
NameTypeDescription
prefixClsstringPrefix class name (optional)
classNamestringClass name (optional)
rootClassNamestringRoot element class name (optional)
spinningbooleanWhether to display the loading state
styleReact.CSSPropertiesCustom style object (optional)
sizeSpinSizeSize (optional)
tipReact.ReactNodeTip content (optional)
delaynumberTime in milliseconds to delay showing the loading state (optional)
wrapperClassNamestringWrapper element class name (optional)
indicatorSpinIndicatorCustom loading indicator (optional)
childrenReact.ReactNodeChild elements (optional)

Keywords

FAQs

Package last updated on 10 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc