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

Commit

Permalink
feat: 增加组件SolarSystemLoading组件
Browse files Browse the repository at this point in the history
  • Loading branch information
vortesnail committed Dec 2, 2019
1 parent ce4bf2f commit a7ae5d8
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ import { BoxLoading } from 'react-loadingg'
| RotateCircleLoading ||||
| StickyBallLoading ||||
| SemipolarLoading ||||
| SolarSystemLoading ||||

#### ❤️ 组件列表

- [x] BlockLoading
Expand All @@ -80,6 +82,7 @@ import { BoxLoading } from 'react-loadingg'
- [x] RotateCircleLoading
- [x] StickyBallLoading
- [x] SemipolarLoading
- [x] SolarSystemLoading
- [ ] 持续开发中...

#### ⌨️ 组件开发
Expand Down
94 changes: 94 additions & 0 deletions src/components/SolarSystemLoading/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import React from 'react';
import styled, { keyframes } from 'styled-components';

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


const LoadContainer = styled.div`
width: 50px;
height: 50px;
position: relative;
/* overflow: hidden; */
`;

const Sun = styled.div`
width: 4px;
height: 4px;
border-radius: 50%;
background-color: ${props => props.color || '#00adb5'};
position: absolute;
left: 50%;
top: 50%;
margin-left: -2px;
margin-top: -2px;
`

const FirstTrack = styled.div`
width: 30px;
height: 30px;
border-radius: 50%;
border: 1px solid;
border-color: ${props => props.color || '#00adb5'};
position: absolute;
left: 50%;
top: 50%;
margin-left: -15px;
margin-top: -15px;
box-sizing: border-box;
animation: ${rotate} ${props => props.speed || 2}s linear infinite;
`

const Earth = styled.div`
width: 6px;
height: 6px;
border-radius: 50%;
background-color: ${props => props.color || '#00adb5'};
position: absolute;
left: -1px;
top: 2px;
`

const SecondTrack = styled.div`
width: 60px;
height: 60px;
border-radius: 50%;
border: 1px solid;
border-color: ${props => props.color || '#00adb5'};
position: absolute;
left: 50%;
top: 50%;
margin-left: -30px;
margin-top: -30px;
box-sizing: border-box;
animation: ${rotate} ${props => props.speed * 1.5 || 3}s linear infinite;
`

const Mars = styled.div`
width: 8px;
height: 8px;
border-radius: 50%;
background-color: ${props => props.color || '#00adb5'};
position: absolute;
left: 7px;
top: 2px;
`

const SolarSystemLoading = ({ style, color, speed }) => {
return (
<LoadContainer style={style}>
<Sun color={color}/>
<FirstTrack color={color} speed={speed}>
<Earth color={color}/>
</FirstTrack>
<SecondTrack color={color} speed={speed}>
<Mars color={color}/>
</SecondTrack>
</LoadContainer>
);
};

export default SolarSystemLoading;
1 change: 1 addition & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export { default as MeteorRainLoading } from './MeteorRainLoading'
export { default as RotateCircleLoading } from './RotateCircleLoading'
export { default as StickyBallLoading } from './StickyBallLoading'
export { default as SemipolarLoading } from './SemipolarLoading'
export { default as SolarSystemLoading } from './SolarSystemLoading'
21 changes: 21 additions & 0 deletions src/stories/SolarSystemLoading.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { withKnobs,number, text } from '@storybook/addon-knobs';
import { SolarSystemLoading } from '~/components';
import Container from './compoment/Container';
storiesOf('SolarSystemLoading', module)
.addDecorator(withKnobs)
.add(
'SolarSystemLoading',
() => {
let speed = 1;
let color = '';
speed = number('动画速度(s)')
color = text('颜色')
return (
<Container>
<SolarSystemLoading speed={speed} color={color}></SolarSystemLoading>
</Container>
);
}
);
6 changes: 5 additions & 1 deletion src/stories/compoment/DemoContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
MeteorRainLoading,
RotateCircleLoading,
StickyBallLoading,
SemipolarLoading
SemipolarLoading,
SolarSystemLoading
} from '~/components';
import './style.scss';
const DemoContainer = () => {
Expand Down Expand Up @@ -148,6 +149,9 @@ const DemoContainer = () => {
<div className="item" onClick={() => setName('SemipolarLoading')}>
<SemipolarLoading style={style} speed={2}/>
</div>
<div className="item" onClick={() => setName('SolarSystemLoading')}>
<SolarSystemLoading style={style} speed={2}/>
</div>
</div>
</div>
);
Expand Down

0 comments on commit a7ae5d8

Please sign in to comment.