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

Commit

Permalink
feat: 组件可以传递color属性
Browse files Browse the repository at this point in the history
  • Loading branch information
Summer-andy committed Nov 15, 2019
1 parent e578c11 commit be2de89
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 130 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ import { BoxLoading } from 'react-loadingg'
<BoxLoading />
```

#### 🎉 组件API

| 组件 | color| speed | style |
| ---- | ---- | ---- |---- |
| BlockLoading ||||
| BoxLoading || 🚧 ||
| CircleLoading || 🚧 ||
| CommonLoading || 🚧 ||
| LoopCircleLoading || 🚧 ||
| TransverseLoading || 🚧 ||
| WaveLoading || 🚧 ||
| CircleToBlockLoading || 🚧 ||

#### ❤️ 组件列表

- [x] BlockLoading
Expand Down
12 changes: 3 additions & 9 deletions src/components/BoxLoading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ import styled from 'styled-components';
const LoadContainer = styled.div`
width: 50px;
height: 50px;
margin: auto;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
&:before {
content: '';
width: 50px;
Expand All @@ -26,7 +20,7 @@ const LoadContainer = styled.div`
content: '';
width: 50px;
height: 50px;
background: #00adb5;
background: ${props => props.color || '#00adb5'};
animation: ${shadow} 0.5s linear infinite;
position: absolute;
top: 0;
Expand All @@ -35,9 +29,9 @@ const LoadContainer = styled.div`
}
`;

const BoxLoading = ({ style }) => {
const BoxLoading = ({ style, color }) => {
return (
<LoadContainer></LoadContainer>
<LoadContainer style={style} color={color}></LoadContainer>
);
};

Expand Down
6 changes: 3 additions & 3 deletions src/components/CircleLoading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const LoadingContainer = styled.div`
content: '';
width: 70px;
height: 70px;
background-color: #00adb5;
background-color: ${props => props.color || '#00adb5'};
position: absolute;
left: 50%;
bottom: 50%;
Expand All @@ -54,9 +54,9 @@ const LoadingContainer = styled.div`
}
`;

const CircleLoading = ({ style }) => {
const CircleLoading = ({ style, color }) => {
return (
<LoadingContainer style={style} />
<LoadingContainer style={style} color={color} />
);
};

Expand Down
16 changes: 5 additions & 11 deletions src/components/CircleToBlockLoading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ const changeSharp = keyframes`
const LoadContainer = styled.div`
height: 100px;
width: 100px;
margin: auto;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
display: flex;
justify-content: space-between;
flex-wrap: nowrap;
Expand All @@ -31,7 +25,7 @@ const LoadContainer = styled.div`
const Item = styled.div`
height: 20px;
width: 20px;
background-color: #00adb5;
background-color: ${props => props.color || '#00adb5' };
position: absolute;
margin: auto;
border-radius: 2px;
Expand All @@ -51,12 +45,12 @@ const ItemThree = styled(Item)`
animation-delay: calc(3s * 4 / -1.5);
`

const CircleToBlockLoading = ({ style }) => {
const CircleToBlockLoading = ({ style, color }) => {
return (
<LoadContainer style={style}>
<ItemFirst />
<ItemTwo />
<ItemThree />
<ItemFirst color={color} />
<ItemTwo color={color} />
<ItemThree color={color} />
</LoadContainer>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/CommonLoading/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import './style.scss';
const CommonLoading = ({ style }) => {
const CommonLoading = ({ style, color }) => {
return (
<svg id="load" x="0px" y="0px" viewBox="0 0 150 150" style={style}>
<circle id="loading-inner" cx="75" cy="75" r="60" />
<circle id="loading-inner" cx="75" cy="75" r="60" stroke={color || '#00adb5'} />
</svg>
);
};
Expand Down
7 changes: 0 additions & 7 deletions src/components/CommonLoading/style.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
#load {
margin: auto;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 75px;
animation: loading 3s linear infinite;
#loading-inner {
Expand All @@ -16,7 +10,6 @@
linecap: round;
}
animation: loading-circle 2s linear infinite;
stroke: #00adb5;
fill: transparent;
}
}
Expand Down
33 changes: 14 additions & 19 deletions src/components/LoopCircleLoading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ const bouncedelay = keyframes`
`;

const LoadContainer = styled.div`
margin: auto;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 48px;
height: 48px;
`;
Expand All @@ -34,7 +29,7 @@ const container = styled.div`
const circle = styled.div`
width: 12px;
height: 12px;
background-color: #00adb5;
background-color: ${props => props.color || '#00adb5'} ;
border-radius: 100%;
position: absolute;
animation: ${bouncedelay} 1.2s infinite ease-in-out;
Expand Down Expand Up @@ -122,26 +117,26 @@ const CircleFour2 = styled(circle)`
bottom: 0;
`;

const LoopCircleLoading = ({ style }) => {
const LoopCircleLoading = ({ style, color }) => {
return (
<LoadContainer style={style}>
<ContainerFirst>
<CircleFirst />
<CircleTwo />
<CircleThree />
<CircleFour />
<CircleFirst color={color} />
<CircleTwo color={color} />
<CircleThree color={color} />
<CircleFour color={color} />
</ContainerFirst>
<ContainerTwo>
<CircleFirst1 />
<CircleTwo1 />
<CircleThree1 />
<CircleFour1 />
<CircleFirst1 color={color} />
<CircleTwo1 color={color} />
<CircleThree1 color={color} />
<CircleFour1 color={color} />
</ContainerTwo>
<ContainerThree>
<CircleFirst2 />
<CircleTwo2 />
<CircleThree2 />
<CircleFour2 />
<CircleFirst2 color={color} />
<CircleTwo2 color={color} />
<CircleThree2 color={color} />
<CircleFour2 color={color} />
</ContainerThree>
</LoadContainer>
);
Expand Down
11 changes: 5 additions & 6 deletions src/components/TransverseLoading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ const bouncedelay = keyframes`
`

const LoadingContainer = styled.div`
margin: 50px auto;
width: 150px;
text-align: center;
`;

const load = styled.div`
width: 20px;
height: 20px;
background-color: #00adb5;
background-color: ${props => props.color || '#00adb5;'};
border-radius: 100%;
display: inline-block;
animation: ${bouncedelay} 1.4s infinite ease-in-out;
Expand All @@ -41,12 +40,12 @@ const LoadThree = styled(load)`
`

const TransverseLoading = ({ style }) => {
const TransverseLoading = ({ style, color }) => {
return (
<LoadingContainer style={style}>
<LoadFirst />
<LoadTwo />
<LoadThree />
<LoadFirst color={color} />
<LoadTwo color={color} />
<LoadThree color={color}/>
</LoadingContainer>
);
};
Expand Down
14 changes: 7 additions & 7 deletions src/components/WaveLoading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const LoadContainer = styled.div`
`;

const box = styled.div`
background-color: #00adb5;
background-color: ${props => props.color || '#00adb5'};
height: 100%;
width: 6px;
display: inline-block;
Expand Down Expand Up @@ -48,14 +48,14 @@ const BoxLoadingFive = styled(box)`
animation-delay: -0.8s;
`;

const WaveLoading = ({ style }) => {
const WaveLoading = ({ style, color }) => {
return (
<LoadContainer style={style}>
<BoxLoadingFirst />
<BoxLoadingTwo />
<BoxLoadingThree />
<BoxLoadingFour />
<BoxLoadingFive />
<BoxLoadingFirst color={color} />
<BoxLoadingTwo color={color} />
<BoxLoadingThree color={color} />
<BoxLoadingFour color={color} />
<BoxLoadingFive color={color} />
</LoadContainer>
);
};
Expand Down
14 changes: 14 additions & 0 deletions src/stories/Demo.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 DemoContainer from './compoment/DemoContainer';
storiesOf('Demo', module)
.addDecorator(withKnobs)
.add(
'Demo',
() => {
return (
<DemoContainer />
);
}
);
53 changes: 29 additions & 24 deletions src/stories/compoment/DemoContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ import {
} from '~/components';
import './style.scss';
const DemoContainer = () => {

const style = {
margin: 'auto',
position: 'absolute',
left: 0,
right: 0,
top: 0,
bottom: 0,
}

return (
<div className="demo-container">
<div className="top-container"></div>
Expand All @@ -20,62 +30,57 @@ const DemoContainer = () => {
<div className="title-area">
<h1>THE LOADING COMPONENT BASE ON REACT</h1>
<p>
Our goal is to make waiting more interestingWe only focus on loadingWelcome to our
team
Our goal is to make waiting more interesting.We only focus on loading.Welcome to our
team.
<br />
Completely open source and MIT licensed.
</p>
</div>
<div className="author-area">
<div>
<img alt="theme" src={require('./theme.jpeg')} />
<div>
<p>Andy&Rabbit</p>
</div>
</div>
</div>
<div className="component">
<div className="item">
<CommonLoading />
<CommonLoading style={style} />
</div>
<div className="item">
<WaveLoading style={style} />
</div>
<div className="item">
<WaveLoading style={{ margin: '28px auto' }} />
<BlockLoading style={style} />
</div>
<div className="item">
<BlockLoading />
<BoxLoading style={style} />
</div>
<div className="item">
<BoxLoading style={{ margin: '25px auto' }} />
<CircleToBlockLoading style={style} />
</div>
<div className="item">
<CircleToBlockLoading />
<LoopCircleLoading style={style} />
</div>
<div className="item">
<LoopCircleLoading />
<TransverseLoading style={{...style, marginTop: 60}} />
</div>
<div className="item">
<TransverseLoading />
<BoxLoading style={style} />
</div>
<div className="item">
<BoxLoading style={{ margin: '25px auto' }} />
<CommonLoading style={style} />
</div>
<div className="item">
<CommonLoading />
<LoopCircleLoading style={style} />
</div>
<div className="item">
<LoopCircleLoading />
<TransverseLoading style={{...style, marginTop: 60}} />
</div>
<div className="item">
<TransverseLoading />
<WaveLoading style={style} />
</div>
<div className="item">
<WaveLoading style={{ margin: '28px auto' }} />
<CommonLoading style={style} />
</div>
<div className="item">
<CommonLoading />
<BlockLoading style={style} />
</div>
<div className="item">
<BlockLoading />
<CircleToBlockLoading style={style} />
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit be2de89

Please sign in to comment.