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
404618a
commit f34e347
Showing
13 changed files
with
571 additions
and
59 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,34 @@ | ||
import React from 'react'; | ||
import styled, { keyframes } from 'styled-components'; | ||
import { commonStyle, sizeContainer } from '../utils/style'; | ||
const changeSharp = (color, size) => keyframes` | ||
0%{box-shadow: inset 0px 0px 0px ${color};} | ||
100%{box-shadow: inset ${size} 0px 0px ${color}} | ||
`; | ||
|
||
const LoadContainer = styled.div` | ||
width: ${props => sizeContainer[props.size] || sizeContainer['default']}; | ||
height: 14px; | ||
border: 1px #fff solid; | ||
border-radius: 2px; | ||
position: relative; | ||
animation: ${props => | ||
changeSharp(props.color || '#00adb5', sizeContainer[props.size] || sizeContainer['default'])} | ||
${props => props.speed || 4}s linear infinite; | ||
&::after { | ||
width: 2px; | ||
height: 7px; | ||
background-color: #fff; | ||
border-radius: 0px 1px 1px 0px; | ||
position: absolute; | ||
content: ''; | ||
top: 2px; | ||
right: -4px; | ||
} | ||
`; | ||
|
||
const BatteryLoading = ({ style = commonStyle, color, size = 'default', speed }) => { | ||
return <LoadContainer style={style} color={color} size={size} speed={speed}></LoadContainer>; | ||
}; | ||
|
||
export default BatteryLoading; |
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,47 @@ | ||
import React from 'react'; | ||
import styled, { keyframes } from 'styled-components'; | ||
import { commonStyle, sizeContainer } from '../utils/style'; | ||
const changeSharp = keyframes` | ||
0%{ | ||
height: 0px; | ||
}, | ||
100%{ | ||
height: 6px; | ||
} | ||
`; | ||
|
||
const LoadContainer = styled.div` | ||
height: ${props => sizeContainer[props.size] || sizeContainer['default']}; | ||
width: ${props => sizeContainer[props.size] || sizeContainer['default']}; | ||
border: 1px ${props => props.color || '#00adb5'} solid; | ||
border-radius: 0px 0px 5px 5px; | ||
position: relative; | ||
&::after { | ||
content: ''; | ||
width: 5px; | ||
height: 12px; | ||
position: absolute; | ||
border: 1px solid ${props => props.color || '#00adb5'}; | ||
border-left: none; | ||
border-radius: 0px ${props => sizeContainer[props.size] || sizeContainer['default']} ${props => sizeContainer[props.size] || sizeContainer['default']} 0px; | ||
top: 4px; | ||
left: ${props => sizeContainer[props.size] || sizeContainer['default']}; | ||
} | ||
&::before { | ||
content: ''; | ||
width: 1px; | ||
height: 6px; | ||
position: absolute; | ||
background-color: ${props => props.color || '#00adb5'}; | ||
top: -10px; | ||
left: ${props => props.size === 'small' ? 6 : (props.size === 'large' ? 12 : 8)}px; | ||
box-shadow: 5px 0px 0px 0px ${props => props.color || '#00adb5'}, 5px -5px 0px 0px ${props => props.color || '#00adb5'}, 10px 0px 0px 0px ${props => props.color || '#00adb5'}; | ||
animation: ${changeSharp} ${props => props.speed || 1}s linear infinite alternate; | ||
} | ||
`; | ||
|
||
const CoffeeLoading = ({ style = commonStyle, color, size = 'default', speed }) => { | ||
return <LoadContainer style={style} color={color} size={size} speed={speed}></LoadContainer>; | ||
}; | ||
|
||
export default CoffeeLoading; |
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,27 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { withKnobs , text, number, radios } from '@storybook/addon-knobs'; | ||
import { BatteryLoading } from '~/components'; | ||
import Container from './compoment/Container'; | ||
storiesOf('BatteryLoading', module) | ||
.addDecorator(withKnobs) | ||
.add('BatteryLoading', () => { | ||
let speed = 1; | ||
let color = ''; | ||
speed = number('动画速度(s)') | ||
color = text('颜色') | ||
let size = radios( | ||
'动画尺寸', | ||
{ | ||
'small': 'small', | ||
'default': 'default', | ||
'large': 'large' | ||
}, | ||
'default' | ||
); | ||
return ( | ||
<Container> | ||
<BatteryLoading color={color} speed={speed} size={size}></BatteryLoading> | ||
</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 , text, number, radios } from '@storybook/addon-knobs'; | ||
import { CoffeeLoading } from '~/components'; | ||
import Container from './compoment/Container'; | ||
storiesOf('CoffeeLoading', module) | ||
.addDecorator(withKnobs) | ||
.add('CoffeeLoading', () => { | ||
let speed = 1; | ||
let color = ''; | ||
speed = number('动画速度(s)') | ||
color = text('颜色') | ||
let size = radios( | ||
'动画尺寸', | ||
{ | ||
'small': 'small', | ||
'default': 'default', | ||
'large': 'large' | ||
}, | ||
'default' | ||
); | ||
return ( | ||
<Container> | ||
<CoffeeLoading color={color} speed={speed} size={size}></CoffeeLoading> | ||
</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.