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
73bbfb9
commit 0908bd4
Showing
9 changed files
with
290 additions
and
66 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
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,86 @@ | ||
import React from 'react'; | ||
import styled, { keyframes } from 'styled-components'; | ||
import { commonStyle, sizeItem } from '../utils/style'; | ||
|
||
const load = keyframes` | ||
0% { | ||
top: 19px; | ||
left: 19px; | ||
} | ||
100% { | ||
} | ||
`; | ||
|
||
const Container = styled.div` | ||
position: relative; | ||
width: 60px; | ||
height: 60px; | ||
border-radius: 50%; | ||
margin: 75px; | ||
display: inline-block; | ||
vertical-align: middle; | ||
`; | ||
|
||
const ItemDiv = styled.div` | ||
position: absolute; | ||
animation: ${load} ${props => props.speed || 1}s ease alternate infinite; | ||
transform: scale(0.2); | ||
&::before { | ||
position: absolute; | ||
content: ''; | ||
left: 50px; | ||
top: 0; | ||
width: 50px; | ||
height: 80px; | ||
background: ${props => props.color || '#00adb5'} ; | ||
border-radius: 50px 50px 0 0; | ||
transform: rotate(-45deg); | ||
transform-origin: 0 100%; | ||
} | ||
&::after { | ||
position: absolute; | ||
content: ''; | ||
left: 50px; | ||
top: 0; | ||
width: 50px; | ||
height: 80px; | ||
background:${props => props.color || '#00adb5'} ; | ||
border-radius: 50px 50px 0 0; | ||
left: 0; | ||
transform: rotate(45deg); | ||
transform-origin: 100% 100%; | ||
} | ||
`; | ||
|
||
const ItemFirst = styled(ItemDiv)` | ||
top: 0; | ||
left: 30px; | ||
`; | ||
|
||
const ItemTwo = styled(ItemDiv)` | ||
left: 60px; | ||
top: 30px; | ||
`; | ||
|
||
const ItemThree = styled(ItemDiv)` | ||
top: 60px; | ||
left: 30px; | ||
`; | ||
|
||
const ItemFour = styled(ItemDiv)` | ||
left: 0; | ||
top: 30px; | ||
`; | ||
|
||
const DiamonLoading = ({ style = commonStyle, speed, color }) => { | ||
return ( | ||
<Container {...{ style, speed, color }}> | ||
<ItemFirst color={color} speed={speed}></ItemFirst> | ||
<ItemTwo color={color} speed={speed} /> | ||
<ItemThree color={color} speed={speed} /> | ||
<ItemFour color={color} speed={speed} /> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default DiamonLoading; |
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,58 @@ | ||
import React from 'react'; | ||
import styled, { keyframes } from 'styled-components'; | ||
import { commonStyle, sizeItem } from '../utils/style'; | ||
|
||
const load = keyframes` | ||
0% { | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
transform: rotate(-360deg); | ||
} | ||
`; | ||
|
||
const Container = styled.div` | ||
position: absolute; | ||
width: 60px; | ||
height: 60px; | ||
border-radius: 50%; | ||
margin: 75px; | ||
display: inline-block; | ||
vertical-align: middle; | ||
border: 8px dotted ${props => props.color || '#00adb5'} ; | ||
transition: all 1s ease; | ||
animation: ${load} ${props => props.speed || 1}s linear infinite; | ||
border-bottom-width: 1px; | ||
border-bottom-color: ${props => props.color || '#00adb5'} ; | ||
border-left-width: 2px; | ||
border-left-color: ${props => props.color || '#00adb5'} ; | ||
border-top-width: 3px; | ||
border-right-width: 4px; | ||
border-top-color: ${props => props.color || '#00adb5'} ; | ||
`; | ||
|
||
const ItemDiv = styled.div` | ||
position: absolute; | ||
top: 45px; | ||
left: 25px; | ||
width: 0px; | ||
height: 0px; | ||
border-right: 12px solid transparent; | ||
border-top: 12px solid ${props => props.color || '#00adb5'} ; | ||
border-left: 12px solid ${props => props.color || '#00adb5'} ; | ||
border-bottom: 12px solid ${props => props.color || '#00adb5'} ; | ||
border-top-left-radius: 12px; | ||
border-top-right-radius: 12px; | ||
border-bottom-left-radius: 12px; | ||
border-bottom-right-radius: 12px; | ||
`; | ||
|
||
const EatLoading = ({ style = commonStyle, speed, color }) => { | ||
return ( | ||
<Container {...{ style, speed, color }}> | ||
<ItemDiv color={color}></ItemDiv> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default EatLoading; |
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,27 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { withKnobs, number, text, radios } from '@storybook/addon-knobs'; | ||
import { DiamonLoading } from '~/components'; | ||
import Container from './compoment/Container'; | ||
storiesOf('DiamonLoading', module) | ||
.addDecorator(withKnobs) | ||
.add('DiamonLoading', () => { | ||
let speed = 1; | ||
let color = ''; | ||
speed = number('动画速度(s)') | ||
color = text('颜色') | ||
// let size = radios( | ||
// '动画尺寸', | ||
// { | ||
// 'small': 'small', | ||
// 'default': 'default', | ||
// 'large': 'large' | ||
// }, | ||
// 'default' | ||
// ); | ||
return ( | ||
<Container> | ||
<DiamonLoading speed={speed} color={color} ></DiamonLoading> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { withKnobs, number, text, radios } from '@storybook/addon-knobs'; | ||
import { EatLoading } from '~/components'; | ||
import Container from './compoment/Container'; | ||
storiesOf('EatLoading', module) | ||
.addDecorator(withKnobs) | ||
.add('EatLoading', () => { | ||
let speed = 1; | ||
let color = ''; | ||
speed = number('动画速度(s)') | ||
color = text('颜色') | ||
// let size = radios( | ||
// '动画尺寸', | ||
// { | ||
// 'small': 'small', | ||
// 'default': 'default', | ||
// 'large': 'large' | ||
// }, | ||
// 'default' | ||
// ); | ||
return ( | ||
<Container> | ||
<EatLoading speed={speed} color={color} ></EatLoading> | ||
</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
Oops, something went wrong.