Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
feat: 新增风车Loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Summer-andy committed Nov 18, 2019
1 parent 3df3bad commit 93f2f99
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 41 deletions.
82 changes: 43 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# React-Loading
![npm version](https://img.shields.io/npm/v/react-loading) ![](https://img.shields.io/github/license/sixiaodong123/react-loading) ![](https://img.shields.io/npm/dm/react-loadingg)

![npm version](https://img.shields.io/npm/v/react-loading) ![](https://img.shields.io/github/license/sixiaodong123/react-loading) ![](https://img.shields.io/npm/dm/react-loadingg)

### 项目介绍

基于 React 的 Loading 组件。

#### Demo

🎉 [查看demo](http://139.196.82.33:8080/iframe.html?id=demo--demo)
🎉 [查看 demo](http://139.196.82.33:8080/iframe.html?id=demo--demo)

### 使用教程

Expand All @@ -22,48 +25,49 @@ import { BoxLoading } from 'react-loadingg'
<BoxLoading />
```

#### 🎉 组件API

| 组件 | color| speed | style |
| ---- | ---- | ---- |---- |
| BlockLoading ||||
| BoxLoading ||||
| BlockReserveLoading ||||
| CircleLoading ||||
| CircleToBlockLoading || 🚧 ||
| CommonLoading || 🚧 ||
| DisappearedLoading ||||
| LoopCircleLoading || 🚧 ||
| NineCellLoading ||||
| TouchBallLoading ||||
| TransverseLoading || 🚧 ||
| WaveLoading || 🚧 | |
| WaveTopBottomLoading ||||

#### ❤️ 组件列表

- [x] BlockLoading
- [x] BoxLoading
- [x] BlockReserveLoading
- [x] CircleLoading
- [x] CircleToBlockLoading
- [x] CommonLoading
- [x] DisappearedLoading
- [x] LoopCircleLoading
- [x] NineCellLoading
- [x] TouchBallLoading
- [x] TransverseLoading
- [x] WaveLoading
- [x] WaveTopBottomLoading
- [ ] 持续开发中...


#### ⌨️ 组件开发
#### 🎉 组件 API

| 组件 | color | speed | style |
| -------------------- | ----- | ----- | ----- |
| BlockLoading | | | |
| BoxLoading | | | |
| BlockReserveLoading | | | |
| CircleLoading | | | |
| CircleToBlockLoading | | 🚧 | |
| CommonLoading | | 🚧 | |
| DisappearedLoading | | | |
| LoopCircleLoading | | 🚧 | |
| NineCellLoading | | | |
| TouchBallLoading | | | |
| TransverseLoading | | 🚧 | |
| WaveLoading || 🚧 | |
| WaveTopBottomLoading | | | |
| WindMillLoading ||||

#### ❤️ 组件列表

- [x] BlockLoading
- [x] BoxLoading
- [x] BlockReserveLoading
- [x] CircleLoading
- [x] CircleToBlockLoading
- [x] CommonLoading
- [x] DisappearedLoading
- [x] LoopCircleLoading
- [x] NineCellLoading
- [x] TouchBallLoading
- [x] TransverseLoading
- [x] WaveLoading
- [x] WaveTopBottomLoading
- [ ] 持续开发中...

#### ⌨️ 组件开发

```bash
$ git clone https://github.com/sixiaodong123/react-loading
$ npm run dev
```

访问 [http://localhost:9001/](http://localhost:9001/)

#### 🔨 组件打包
Expand Down
87 changes: 87 additions & 0 deletions src/components/WindMillLoading/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import React from 'react';
import styled, { keyframes } from 'styled-components';

const bouncedelay = keyframes`
0% {
transform: rotate(360deg);
}
50% {
transform: rotate(180deg);
}
100% {
transform: rotate(0deg);
}
`;

const LoadingContainer = styled.div`
display: block;
height: 0;
width: 4px;
border-width: 0 4px 60px 4px;
border-style: none solid solid;
border-color: transparent transparent ${props => props.color || '#00adb5'};
position: relative;
`;

const ItemFirst = styled.div`
height: 0;
width: 2px;
border-width: 40px 2px 0px 2px;
border-style: solid solid none;
border-color: ${props => props.color || '#00adb5'} transparent transparent;
transform-origin: 0 -2px;
transform: rotate(60deg);
position: absolute;
`;

const ItemSecord = styled.div`
height: 0;
width: 2px;
border-width: 40px 2px 0px 2px;
border-style: solid solid none;
border-color: ${props => props.color || '#00adb5'} transparent transparent;
transform-origin: 2px -1px;
transform: rotate(180deg);
position: absolute;
`;

const ItemThree = styled.div`
height: 0;
width: 2px;
border-width: 40px 2px 0px 2px;
border-style: solid solid none;
border-color: ${props => props.color || '#00adb5'} transparent transparent;
transform-origin: 5px 0;
transform: rotate(300deg);
position: absolute;
`;

const Center = styled.div`
width: 4px;
height: 4px;
border: 3px ${props => props.color || '#00adb5'} solid;
background: #fff;
border-radius: 5px;
transform: translateX(-3px) translateY(-4px);
position:absolute;
`;

const Con = styled.div`
position: relative;
animation: ${bouncedelay} ${props => props.speed || 5}s infinite linear;
`;

const WindMillLoading = ({ style, color, speed }) => {
return (
<LoadingContainer style={style} color={color}>
<Center color={color} />
<Con speed={speed}>
<ItemFirst color={color} />
<ItemSecord color={color} />
<ItemThree color={color} />
</Con>
</LoadingContainer>
);
};

export default WindMillLoading;
2 changes: 2 additions & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ export { default as DisappearedLoading } from './DisappearedLoading'
export { default as BlockReserveLoading } from './BlockReserveLoading'
export { default as WaveTopBottomLoading } from './WaveTopBottomLoading'
export { default as NineCellLoading } from './NineCellLoading'
export { default as WindMillLoading } from './WindMillLoading'

14 changes: 14 additions & 0 deletions src/stories/WindMillLoading.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { withKnobs } from '@storybook/addon-knobs';
import { WindMillLoading } from '~/components';
import Container from './compoment/Container';
storiesOf('WindMillLoading', module)
.addDecorator(withKnobs)
.add('WindMillLoading', () => {
return (
<Container>
<WindMillLoading></WindMillLoading>
</Container>
);
});
5 changes: 3 additions & 2 deletions src/stories/compoment/DemoContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
BlockReserveLoading,
WaveTopBottomLoading,
CircleLoading,
NineCellLoading
NineCellLoading,
WindMillLoading
} from '~/components';
import './style.scss';
const DemoContainer = () => {
Expand Down Expand Up @@ -62,7 +63,7 @@ const DemoContainer = () => {
<LoopCircleLoading style={style} />
</div>
<div className="item">
<TransverseLoading style={{...style, marginTop: 60}} />
<WindMillLoading style={style} />
</div>
<div className="item">
<BoxLoading style={style} />
Expand Down

0 comments on commit 93f2f99

Please sign in to comment.