This repository has been archived by the owner on Nov 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fdb99a2
commit 98e14fa
Showing
5 changed files
with
86 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react'; | ||
import styled, { keyframes } from 'styled-components'; | ||
import { commonStyle, sizeContainer } from '../utils/style'; | ||
const animate1 = keyframes` | ||
100% { | ||
transform:rotate(360deg) | ||
} | ||
`; | ||
|
||
const animate2 = keyframes` | ||
0%,100% { | ||
transform:scale(0) | ||
} | ||
50% { | ||
transform:scale(1) | ||
} | ||
`; | ||
|
||
const LoadingContainer = styled.div` | ||
position: relative; | ||
width: 45px; | ||
height: 45px; | ||
margin: 0 auto; | ||
animation: ${animate1} 2s linear infinite; | ||
`; | ||
|
||
const Item = styled.div` | ||
position:absolute; | ||
top:0; | ||
width:25px; | ||
height:25px; | ||
border-radius:100%; | ||
background-color: ${props => props.color || '#00adb5'}; | ||
animation: ${animate2} ${props => props.speed || 2}s ease-in-out infinite; | ||
`; | ||
|
||
const ItemOne = styled(Item)``; | ||
|
||
const ItemTwo = styled(Item)` | ||
animation-delay: -${props => props.speed / 2 || 1}s; | ||
top:auto; | ||
bottom:0; | ||
`; | ||
|
||
const BlockRotateLoading = ({ style = commonStyle, color, speed, size = 'default' }) => { | ||
return ( | ||
<LoadingContainer style={style}> | ||
<ItemOne color={color} speed={speed} /> | ||
<ItemTwo color={color} speed={speed} /> | ||
</LoadingContainer> | ||
); | ||
}; | ||
|
||
export default BlockRotateLoading; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { withKnobs, number, text, radios } from '@storybook/addon-knobs'; | ||
import { BlockRotateLoading } from '~/components'; | ||
import Container from './compoment/Container'; | ||
storiesOf('BlockRotateLoading', module) | ||
.addDecorator(withKnobs) | ||
.add( | ||
'BlockRotateLoading', | ||
() => { | ||
let speed = 1; | ||
let color = ''; | ||
speed = number('动画速度(s)') | ||
color = text('颜色') | ||
let size = radios( | ||
'动画尺寸', | ||
{ | ||
'small': 'small', | ||
'default': 'default', | ||
'large': 'large' | ||
}, | ||
'default' | ||
); | ||
return ( | ||
<Container> | ||
<BlockRotateLoading size={size} speed={speed} color={color}></BlockRotateLoading> | ||
</Container> | ||
); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters