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

@uiw/react-loader

v4.22.3

Published

Loader component

Downloads

930

Readme

Loader 加载器

Buy me a coffee Open in unpkg NPM Downloads npm version

用于页面和区块的加载中状态。

import { Loader } from 'uiw';
// or
import Loader from '@uiw/react-loader';

基础实例

import React from 'react';
import { Loader } from "uiw";

export default function Demo() {
  return (
    <div>
      <Loader size="small" />
      <Loader />
      <Loader size="large" />
    </div>
  );
}

警告提示中加载

import React, { Component } from 'react';
import { Loader, Row, Col, Message, Icon, Button } from "uiw";

class Demo extends Component {
  constructor(props) {
    super(props);
    this.state = {
      loading: true,
    };
  }
  render() {
    return (
      <div>
        <Row gutter={10}>
          <Col>
            <Button
              style={{ marginBottom: 10 }}
              size="small"
              onClick={() => {
                this.setState({
                  loading: !this.state.loading,
                });
              }}
            >
              点击切换加载状态
            </Button>
          </Col>
        </Row>
        <Row gutter={10}>
          <Col fixed>
            <Loader loading={this.state.loading}>
              <Message
                type="success"
                title="成功提示标题"
                description={
                  <span>
                    <Icon
                      type="uiw"
                      verticalAlign="baseline"
                      style={{ fill: "#009688" }}
                    />
                    这里是成功提示详情描述。
                  </span>
                }
              />
            </Loader>
          </Col>
          <Col fixed>
            <Loader loading={this.state.loading}>
              <Message
                type="warning"
                title="成功提示标题"
                description="这里是成功提示详情描述。"
              />
            </Loader>
          </Col>
        </Row>
      </div>
    );
  }
}
export default Demo;

卡片加载中

import React from 'react';
import { Loader, Card, Col, Row } from "uiw";

export default function Demo() {
  return (
    <Row gutter={10}>
      <Col fixed>
        <Card
          title="图标与文字一行显示"
          extra={<a href="#">更多</a>}
          style={{ minWidth: 230 }}
        >
          <Loader color="red" tip="加载中..." style={{ width: "100%" }}>
            <div>
              卡片内容
              <br />
              卡片内容
              <br />
              卡片内容
              <br />
            </div>
          </Loader>
        </Card>
      </Col>
      <Col fixed>
        <Card
          title="图标与文字垂直显示"
          extra={<a href="#">更多</a>}
          style={{ minWidth: 230 }}
        >
          <Loader tip="loading..." vertical style={{ width: "100%" }}>
            <div>
              卡片内容
              <br />
              卡片内容
              <br />
              卡片内容
              <br />
            </div>
          </Loader>
        </Card>
      </Col>
      <Col fixed>
        <Card
          title="自定义背景颜色"
          extra={<a href="#">更多</a>}
          style={{ minWidth: 230 }}
        >
          <Loader
            bgColor="rgba(0, 0, 0, 0.4)"
            color="#fff"
            tip="loading..."
            vertical
            style={{ width: "100%" }}
          >
            <div>
              卡片内容
              <br />
              卡片内容
              <br />
              卡片内容
              <br />
            </div>
          </Loader>
        </Card>
      </Col>
    </Row>
  );
}

自定义加载图标动画

import React from 'react';
import { Loader, Card, Icon } from "uiw";

export default function Demo() {
  return (
    <div>
      <Card title="Card标题" extra={<a href="#">更多</a>} style={{ width: 300 }}>
        <Loader
          tip="加载中..."
          color="red"
          indicator={
            <Icon
              type="loading"
              spin={true}
              style={{ verticalAlign: "text-top" }}
            />
          }
          style={{ width: "100%" }}
        >
          <div>
            卡片内容
            <br />
            卡片内容
            <br />
            卡片内容
            <br />
          </div>
        </Loader>
      </Card>
    </div>
  );
}

整页加载

页面数据加载时显示。

import React from 'react';
import { Loader, Icon, Button } from "uiw";

class Demo extends React.Component {
  constructor() {
    super();
    this.state = {
      fullscreen: false,
    };
  }
  render() {
    return (
      <div>
        <Button
          style={{ marginBottom: 10 }}
          type="primary"
          onClick={() => {
            this.setState(
              {
                fullscreen: !this.state.fullscreen,
              },
              () => {
                setTimeout(() => {
                  this.setState({
                    fullscreen: !this.state.fullscreen,
                  });
                }, 3000);
              }
            );
          }}
        >
          显示整页加载,3 秒后消失
        </Button>
        {this.state.fullscreen && (
          <Loader
            tip="加载中..."
            size="large"
            bgColor="rgba(255, 255, 255, 0.9)"
            fullscreen={this.state.fullscreen}
          />
        )}
      </div>
    );
  }
}

export default Demo;

Props

| 参数 | 说明 | 类型 | 默认值 | | ---------- | ------- | ------- | --------- | | size | 尺寸 | Enum{small, default, large} | default | | loading | 是否旋转 | Boolean | true | | indicator | 加载指示符,可以加载一个 Icon 动画 | ReactNode | - | | tip | 当作为包裹元素时,可以自定义描述文案 | String | - | | color | 设置图标与文字的颜色 | String | - | | vertical | 图标与文字垂直显示 | Boolean | - | | bgColor | 自定义背景颜色 | String | - | | fullscreen | 是否全屏显示 | Boolean | false |