Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
BrsJsk committed May 26, 2018
0 parents commit a43ff0e
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Loader
=========

A small library for managing loaders.

## Installation

`npm install brsjs-loader`

## Usage
### Initialize loader with
```
let loader = new Loader('id', 'type');
```
#### 'id' is id of your element where you want to show your loader.
#### 'type' is type of loader. Currently only 'standard' is supported.
### Show loader with
```
loader.show();
```
### Hide loader with
```
loader.hide();
```

## Example

let loader = new Loader('app', 'standard');

loader.show();

21 changes: 21 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import './style.css';

class Loader {
uniqueClassName = '-brsjsloader';
constructor(placeToDisplay, type) {
this.type = type ? type : 'standard';
this.element = document.getElementById(placeToDisplay);
this.loader = document.createElement("div");
this.loader.className = this.type + this.uniqueClassName;
}

hide() {
this.loader.remove()
}

show() {
this.element.appendChild(this.loader)
}
}

export default Loader;
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "brsjs-loader",
"version": "1.0.0",
"description": "Simple library for managing loaders",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/BrsJsk/brsjs-loader.git"
},
"keywords": [
"javascript",
"loader",
"css"
],
"author": "Boris Joskic",
"license": "MIT",
"bugs": {
"url": "https://github.com/BrsJsk/brsjs-loader/issues"
},
"homepage": "https://github.com/BrsJsk/brsjs-loader#readme"
}
42 changes: 42 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.standard-brsjsloader {
height: 4px;
width: 100%;
position: absolute;
overflow: hidden;
background-color: #ddd;
top: 0;
z-index: 100;
}

.standard-brsjsloader:before {
display: block;
position: absolute;
content: "";
left: -200px;
width: 200px;
height: 4px;
background-color: #2980b9;
animation: standard-loading-brsjsloader 2s linear infinite;
}

@keyframes standard-loading-brsjsloader {
from {
left: -200px;
width: 30%;
}
50% {
width: 30%;
}
70% {
width: 70%;
}
80% {
left: 50%;
}
95% {
left: 120%;
}
to {
left: 100%;
}
}

0 comments on commit a43ff0e

Please sign in to comment.