Skip to content

Commit 54f0e5b

Browse files
committed
Initial Commit
0 parents  commit 54f0e5b

File tree

9 files changed

+8066
-0
lines changed

9 files changed

+8066
-0
lines changed

.babelrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"presets": [
3+
"env",
4+
"react",
5+
"stage-2"
6+
]
7+
}

.eslintrc.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
"extends": "airbnb",
3+
"parserOptions": {
4+
"ecmaVersion": 8,
5+
"ecmaFeatures": {
6+
"experimentalObjectRestSpread": true
7+
}
8+
},
9+
"rules": {
10+
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
11+
"comma-dangle": ["error", "never"],
12+
"semi": [2, "never"],
13+
"import/no-named-as-default": 0,
14+
"import/no-named-as-default-member": 0,
15+
"react/prefer-stateless-function": 0,
16+
"indent": ["error", 4],
17+
"indent": ["warn", 2],
18+
},
19+
"env": {
20+
"browser": true,
21+
"node": true
22+
}
23+
};

.gitignore

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
### Node ###
2+
# Logs
3+
logs
4+
*.log
5+
npm-debug.log*
6+
yarn-debug.log*
7+
yarn-error.log*
8+
9+
# Coverage directory used by tools like istanbul
10+
coverage
11+
12+
# Dependency directories
13+
node_modules/
14+
15+
#Dist directory
16+
dist/
17+
18+
### Visual Studio Code ###
19+
.settings/
20+
.vscode/
21+
tsconfig.json
22+
jsconfig.json
23+
24+
### macOS ###
25+
# General
26+
.DS_Store
27+
.AppleDouble
28+
.LSOverride
29+
30+
# Icon must end with two \r
31+
Icon
32+
33+
# Thumbnails
34+
._*
35+
36+
# Files that might appear in the root of a volume
37+
.DocumentRevisions-V100
38+
.fseventsd
39+
.Spotlight-V100
40+
.TemporaryItems
41+
.Trashes
42+
.VolumeIcon.icns
43+
.com.apple.timemachine.donotpresent
44+
45+
# Directories potentially created on remote AFP share
46+
.AppleDB
47+
.AppleDesktop
48+
Network Trash Folder
49+
Temporary Items
50+
.apdisk

example/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react'
2+
import ReactDOM from 'react-dom'
3+
import Loading from '../lib/loading'
4+
5+
ReactDOM.render(
6+
<div>
7+
<Loading loading background="#2ecc71" loaderColor="#3498db" />
8+
</div>,
9+
document.getElementById('app')
10+
)
11+

lib/loading.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
4+
import './styles.css'
5+
6+
class Loading extends React.Component {
7+
render() {
8+
const backgroundColor = {
9+
background: this.props.background
10+
}
11+
const loaderColor = {
12+
background: this.props.loaderColor
13+
}
14+
if (this.props.loading) {
15+
return (
16+
<div className="loading-background" style={backgroundColor}>
17+
<div className="loading-bar" >
18+
<div className="loading-circle-1" style={loaderColor} />
19+
<div className="loading-circle-2" style={loaderColor} />
20+
</div>
21+
</div>
22+
)
23+
}
24+
return null
25+
}
26+
}
27+
28+
Loading.defaultProps = {
29+
loading: false,
30+
background: 'rgba(236, 240, 241, 0.7)',
31+
loaderColor: '#e74c3c'
32+
}
33+
34+
Loading.propTypes = {
35+
loading: PropTypes.bool,
36+
background: PropTypes.string,
37+
loaderColor: PropTypes.string
38+
}
39+
40+
export default Loading

lib/styles.css

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
.loading-background {
2+
position: fixed;
3+
left: 0;
4+
top: 0;
5+
width: 100%;
6+
height: 100%;
7+
z-index: 99;
8+
cursor: progress;
9+
}
10+
.loading-background .loading-bar {
11+
position: absolute;
12+
left: 50%;
13+
top: 50%;
14+
width: 50px;
15+
height: 50px;
16+
transform: translate(-50%, -50%);
17+
}
18+
.loading-background .loading-bar .loading-circle-1,
19+
.loading-background .loading-bar .loading-circle-2 {
20+
content: " ";
21+
width: 100%;
22+
height: 100%;
23+
border-radius: 50%;
24+
background-color: #e74c3c;
25+
opacity: 0.6;
26+
position: absolute;
27+
top: 0;
28+
left: 0;
29+
-webkit-animation: sk-bounce 2s infinite ease-in-out;
30+
animation: sk-bounce 2s infinite ease-in-out;
31+
}
32+
.loading-background .loading-bar .loading-circle-2 {
33+
-webkit-animation-delay: -1s;
34+
animation-delay: -1s;
35+
}
36+
37+
@-webkit-keyframes sk-bounce {
38+
0%,
39+
100% {
40+
-webkit-transform: scale(0);
41+
}
42+
50% {
43+
-webkit-transform: scale(1);
44+
}
45+
}
46+
@keyframes sk-bounce {
47+
0%,
48+
100% {
49+
transform: scale(0);
50+
-webkit-transform: scale(0);
51+
}
52+
50% {
53+
transform: scale(1);
54+
-webkit-transform: scale(1);
55+
}
56+
}

0 commit comments

Comments
 (0)