From a43ff0ec7f160028de4021b9ac32fa0b9753aae0 Mon Sep 17 00:00:00 2001 From: Boris Joskic Date: Sat, 26 May 2018 14:50:30 +0200 Subject: [PATCH] Initial --- README.md | 31 +++++++++++++++++++++++++++++++ index.js | 21 +++++++++++++++++++++ package.json | 24 ++++++++++++++++++++++++ style.css | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+) create mode 100644 README.md create mode 100644 index.js create mode 100644 package.json create mode 100644 style.css diff --git a/README.md b/README.md new file mode 100644 index 0000000..8869d78 --- /dev/null +++ b/README.md @@ -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(); + diff --git a/index.js b/index.js new file mode 100644 index 0000000..5d1ed98 --- /dev/null +++ b/index.js @@ -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; \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..e31a7d9 --- /dev/null +++ b/package.json @@ -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" +} diff --git a/style.css b/style.css new file mode 100644 index 0000000..1cfb64a --- /dev/null +++ b/style.css @@ -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%; + } +} \ No newline at end of file