├── src ├── assets │ ├── .gitkeep │ └── demo.gif ├── favicon.ico ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── styles.css ├── app │ ├── app.component.css │ ├── app.module.ts │ ├── app.component.html │ ├── app.component.spec.ts │ └── app.component.ts ├── index.html ├── main.ts ├── test.ts └── polyfills.ts ├── .prettierrc ├── projects └── ngx-loaders-css │ ├── src │ ├── public_api.ts │ ├── lib │ │ ├── ngx-loaders-css.component.css │ │ ├── ngx-loaders-css.module.ts │ │ ├── ngx-loaders-css.component.spec.ts │ │ └── ngx-loaders-css.component.ts │ └── test.ts │ ├── ng-package.json │ ├── tsconfig.lib.prod.json │ ├── tsconfig.spec.json │ ├── tsconfig.lib.json │ ├── CHANGELOG.md │ ├── .browserslistrc │ ├── package.json │ └── karma.conf.js ├── e2e ├── src │ ├── app.po.ts │ └── app.e2e-spec.ts ├── tsconfig.e2e.json └── protractor.conf.js ├── tsconfig.app.json ├── .editorconfig ├── tsconfig.spec.json ├── .browserslistrc ├── .gitignore ├── tsconfig.json ├── LICENSE ├── karma.conf.js ├── package.json ├── README.md ├── tslint.json └── angular.json /src/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t7yang/ngx-loaders-css/HEAD/src/favicon.ico -------------------------------------------------------------------------------- /src/assets/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t7yang/ngx-loaders-css/HEAD/src/assets/demo.gif -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "singleQuote": true, 4 | "trailingComma": "all", 5 | "endOfLine": "lf" 6 | } 7 | -------------------------------------------------------------------------------- /src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | body { 3 | width: 100vw; 4 | height: 100vh; 5 | background-color: palevioletred; 6 | } 7 | -------------------------------------------------------------------------------- /projects/ngx-loaders-css/src/public_api.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Public API Surface of ngx-loaders-css 3 | */ 4 | 5 | export * from './lib/ngx-loaders-css.component'; 6 | export * from './lib/ngx-loaders-css.module'; 7 | -------------------------------------------------------------------------------- /src/app/app.component.css: -------------------------------------------------------------------------------- 1 | .loaders-change { 2 | width: 100%; 3 | height: 200px; 4 | } 5 | 6 | .loaders-demo { 7 | display: flex; 8 | flex-flow: row wrap; 9 | justify-content: center; 10 | } 11 | -------------------------------------------------------------------------------- /projects/ngx-loaders-css/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "../../dist/ngx-loaders-css", 4 | "lib": { 5 | "entryFile": "src/public_api.ts" 6 | } 7 | } -------------------------------------------------------------------------------- /projects/ngx-loaders-css/src/lib/ngx-loaders-css.component.css: -------------------------------------------------------------------------------- 1 | .loader-container { 2 | display: flex; 3 | flex-flow: row nowrap; 4 | justify-content: center; 5 | align-items: center; 6 | width: 100%; 7 | height: 100%; 8 | } 9 | -------------------------------------------------------------------------------- /e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /projects/ngx-loaders-css/tsconfig.lib.prod.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.lib.json", 4 | "compilerOptions": { 5 | "declarationMap": false 6 | }, 7 | "angularCompilerOptions": { 8 | "compilationMode": "partial" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": ["src/main.ts", "src/polyfills.ts"], 9 | "include": ["src/**/*.d.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": ["jasmine"] 7 | }, 8 | "files": ["src/test.ts", "src/polyfills.ts"], 9 | "include": ["src/**/*.spec.ts", "src/**/*.d.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /projects/ngx-loaders-css/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "../../tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "../../out-tsc/spec", 6 | "types": ["jasmine"] 7 | }, 8 | "files": ["src/test.ts"], 9 | "include": ["**/*.spec.ts", "**/*.d.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('workspace-project App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toEqual('Welcome to ngx-loaders-css-app!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NgxLoadersCssApp 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /projects/ngx-loaders-css/src/lib/ngx-loaders-css.module.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from '@angular/common'; 2 | import { NgModule } from '@angular/core'; 3 | import { NgxLoadersCssComponent } from './ngx-loaders-css.component'; 4 | 5 | @NgModule({ 6 | imports: [CommonModule], 7 | declarations: [NgxLoadersCssComponent], 8 | exports: [NgxLoadersCssComponent], 9 | }) 10 | export class NgxLoadersCssModule {} 11 | -------------------------------------------------------------------------------- /projects/ngx-loaders-css/tsconfig.lib.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "../../tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "../../out-tsc/lib", 6 | "declaration": true, 7 | "declarationMap": true, 8 | "inlineSources": true, 9 | "types": [] 10 | }, 11 | "exclude": ["src/test.ts", "**/*.spec.ts"] 12 | } 13 | -------------------------------------------------------------------------------- /projects/ngx-loaders-css/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to the "ngx-loaders-css" extension will be documented in this file. 4 | 5 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 6 | 7 | ## [3.0.0] - 2021-11-05 8 | 9 | Update to Angular v13 10 | 11 | ## [2.0.0] - 2020-09-24 12 | 13 | ### Security 14 | 15 | - Update to Angular v10. 16 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | import { AppModule } from './app/app.module'; 4 | import { environment } from './environments/environment'; 5 | 6 | if (environment.production) { 7 | enableProdMode(); 8 | } 9 | 10 | platformBrowserDynamic() 11 | .bootstrapModule(AppModule) 12 | .catch((err) => console.error(err)); 13 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { NgxLoadersCssModule } from 'projects/ngx-loaders-css/src/public_api'; 4 | import { AppComponent } from './app.component'; 5 | 6 | @NgModule({ 7 | declarations: [AppComponent], 8 | imports: [BrowserModule, NgxLoadersCssModule], 9 | providers: [], 10 | bootstrap: [AppComponent], 11 | }) 12 | export class AppModule {} 13 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 |
5 | 6 |
7 |
8 | 9 |
10 |
11 | -------------------------------------------------------------------------------- /.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /projects/ngx-loaders-css/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /projects/ngx-loaders-css/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'core-js/es7/reflect'; 4 | import 'zone.js/dist/zone'; 5 | import 'zone.js/dist/zone-testing'; 6 | import { getTestBed } from '@angular/core/testing'; 7 | import { 8 | BrowserDynamicTestingModule, 9 | platformBrowserDynamicTesting 10 | } from '@angular/platform-browser-dynamic/testing'; 11 | 12 | declare const require: any; 13 | 14 | // First, initialize the Angular testing environment. 15 | getTestBed().initTestEnvironment( 16 | BrowserDynamicTestingModule, 17 | platformBrowserDynamicTesting() 18 | ); 19 | // Then we find all the tests. 20 | const context = require.context('./', true, /\.spec\.ts$/); 21 | // And load the modules. 22 | context.keys().map(context); 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | # Only exists if Bazel was run 8 | /bazel-out 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # profiling files 14 | chrome-profiler-events*.json 15 | 16 | # IDEs and editors 17 | /.idea 18 | .project 19 | .classpath 20 | .c9/ 21 | *.launch 22 | .settings/ 23 | *.sublime-workspace 24 | 25 | # IDE - VSCode 26 | .vscode/* 27 | !.vscode/settings.json 28 | !.vscode/tasks.json 29 | !.vscode/launch.json 30 | !.vscode/extensions.json 31 | .history/* 32 | 33 | # misc 34 | /.angular/cache 35 | /.sass-cache 36 | /connect.lock 37 | /coverage 38 | /libpeerconnection.log 39 | npm-debug.log 40 | yarn-error.log 41 | testem.log 42 | /typings 43 | 44 | # System Files 45 | .DS_Store 46 | Thumbs.db 47 | -------------------------------------------------------------------------------- /projects/ngx-loaders-css/src/lib/ngx-loaders-css.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { NgxLoadersCssComponent } from './ngx-loaders-css.component'; 4 | 5 | describe('NgxLoadersCssComponent', () => { 6 | let component: NgxLoadersCssComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ NgxLoadersCssComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(NgxLoadersCssComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /projects/ngx-loaders-css/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ngx-loaders-css", 3 | "version": "3.0.0", 4 | "description": "Loaders.css component for Angular X", 5 | "keywords": [ 6 | "angular", 7 | "ngx", 8 | "loaders.css", 9 | "spinner", 10 | "loader", 11 | "css" 12 | ], 13 | "homepage": "https://github.com/t7yang/ngx-loaders-css", 14 | "bugs": { 15 | "url": "https://github.com/t7yang/ngx-loaders-css/issues" 16 | }, 17 | "license": "MIT", 18 | "author": "t7yang (https://github.com/t7yang)", 19 | "repository": { 20 | "type": "git", 21 | "url": "https://github.com/t7yang/ngx-loaders-css.git" 22 | }, 23 | "dependencies": { 24 | "tslib": "^2.3.0" 25 | }, 26 | "peerDependencies": { 27 | "@angular/common": ">=12.0.0", 28 | "@angular/core": ">=12.0.0", 29 | "loaders.css": "^0.1.2" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: require('path').join(__dirname, './tsconfig.e2e.json') 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import { getTestBed } from '@angular/core/testing'; 4 | import { 5 | BrowserDynamicTestingModule, 6 | platformBrowserDynamicTesting, 7 | } from '@angular/platform-browser-dynamic/testing'; 8 | import 'zone.js/testing'; 9 | 10 | declare const require: { 11 | context( 12 | path: string, 13 | deep?: boolean, 14 | filter?: RegExp, 15 | ): { 16 | keys(): string[]; 17 | (id: string): T; 18 | }; 19 | }; 20 | 21 | // First, initialize the Angular testing environment. 22 | getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { 23 | teardown: { destroyAfterEach: false }, 24 | }); 25 | // Then we find all the tests. 26 | const context = require.context('./', true, /\.spec\.ts$/); 27 | // And load the modules. 28 | context.keys().map(context); 29 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "forceConsistentCasingInFileNames": true, 7 | "strict": true, 8 | "noImplicitOverride": true, 9 | "noPropertyAccessFromIndexSignature": true, 10 | "noImplicitReturns": true, 11 | "noFallthroughCasesInSwitch": true, 12 | "sourceMap": true, 13 | "paths": { 14 | "ngx-loaders-css": ["dist/ngx-loaders-css/ngx-loaders-css", "dist/ngx-loaders-css"] 15 | }, 16 | "declaration": false, 17 | "downlevelIteration": true, 18 | "experimentalDecorators": true, 19 | "moduleResolution": "node", 20 | "importHelpers": true, 21 | "target": "es2017", 22 | "module": "es2020", 23 | "lib": ["es2020", "dom"] 24 | }, 25 | "angularCompilerOptions": { 26 | "enableI18nLegacyMessageIdFormat": false, 27 | "strictInjectionParameters": true, 28 | "strictInputAccessModifiers": true, 29 | "strictTemplates": true 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 t7yang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | 4 | describe('AppComponent', () => { 5 | beforeEach(async(() => { 6 | TestBed.configureTestingModule({ 7 | declarations: [ 8 | AppComponent 9 | ], 10 | }).compileComponents(); 11 | })); 12 | 13 | it('should create the app', () => { 14 | const fixture = TestBed.createComponent(AppComponent); 15 | const app = fixture.debugElement.componentInstance; 16 | expect(app).toBeTruthy(); 17 | }); 18 | 19 | it(`should have as title 'ngx-loaders-css-app'`, () => { 20 | const fixture = TestBed.createComponent(AppComponent); 21 | const app = fixture.debugElement.componentInstance; 22 | expect(app.title).toEqual('ngx-loaders-css-app'); 23 | }); 24 | 25 | it('should render title in a h1 tag', () => { 26 | const fixture = TestBed.createComponent(AppComponent); 27 | fixture.detectChanges(); 28 | const compiled = fixture.debugElement.nativeElement; 29 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to ngx-loaders-css-app!'); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma'), 14 | ], 15 | client: { 16 | clearContext: false, // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, './coverage/ngx-loaders-css'), 20 | reports: ['html', 'lcovonly', 'text-summary'], 21 | fixWebpackSourcePaths: true, 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false, 30 | restartOnFileChange: true, 31 | }); 32 | }; 33 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { LoadersCSS } from 'projects/ngx-loaders-css/src/public_api'; 3 | 4 | @Component({ 5 | selector: 'app-root', 6 | templateUrl: './app.component.html', 7 | styleUrls: ['./app.component.css'], 8 | }) 9 | export class AppComponent { 10 | loader: LoadersCSS = 'pacman'; 11 | loaders = loaders; 12 | 13 | constructor() { 14 | const length = loaders.length; 15 | setInterval(() => { 16 | const random = Math.floor(Math.random() * length); 17 | this.loader = loaders[random]; 18 | }, 2000); 19 | } 20 | } 21 | 22 | const loaders: LoadersCSS[] = [ 23 | 'ball-pulse', 24 | 'ball-grid-pulse', 25 | 'ball-clip-rotate', 26 | 'ball-clip-rotate-pulse', 27 | 'square-spin', 28 | 'ball-clip-rotate-multiple', 29 | 'ball-pulse-rise', 30 | 'ball-rotate', 31 | 'cube-transition', 32 | 'ball-zig-zag', 33 | 'ball-zig-zag-deflect', 34 | 'ball-triangle-path', 35 | 'ball-scale', 36 | 'line-scale', 37 | 'line-scale-party', 38 | 'ball-scale-multiple', 39 | 'ball-pulse-sync', 40 | 'ball-beat', 41 | 'line-scale-pulse-out', 42 | 'line-scale-pulse-out-rapid', 43 | 'ball-scale-ripple', 44 | 'ball-scale-ripple-multiple', 45 | 'ball-spin-fade-loader', 46 | 'line-spin-fade-loader', 47 | 'triangle-skew-spin', 48 | 'pacman', 49 | 'ball-grid-beat', 50 | 'semi-circle-spin', 51 | ]; 52 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ngx-loaders-css", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "build:lib": "ng build ngx-loaders-css --configuration production && cp README.md ./dist/ngx-loaders-css", 9 | "pack": "cd dist/ngx-loaders-css && npm pack", 10 | "pub": "cd dist/ngx-loaders-css && npm publish", 11 | "test": "ng test", 12 | "lint": "ng lint", 13 | "e2e": "ng e2e", 14 | "update": "yarn upgradeInteractive" 15 | }, 16 | "private": true, 17 | "dependencies": { 18 | "@angular/animations": "~13.0.0", 19 | "@angular/common": "~13.0.0", 20 | "@angular/compiler": "~13.0.0", 21 | "@angular/core": "~13.0.0", 22 | "@angular/forms": "~13.0.0", 23 | "@angular/platform-browser": "~13.0.0", 24 | "@angular/platform-browser-dynamic": "~13.0.0", 25 | "@angular/router": "~13.0.0", 26 | "loaders.css": "^0.1.2", 27 | "rxjs": "~7.4.0", 28 | "tslib": "^2.3.0", 29 | "zone.js": "~0.11.4" 30 | }, 31 | "devDependencies": { 32 | "@angular-devkit/build-angular": "~13.0.1", 33 | "@angular/cli": "~13.0.1", 34 | "@angular/compiler-cli": "~13.0.0", 35 | "@types/jasmine": "~3.10.0", 36 | "@types/node": "^12.11.1", 37 | "jasmine-core": "~3.10.0", 38 | "karma": "~6.3.0", 39 | "karma-chrome-launcher": "~3.1.0", 40 | "karma-coverage": "~2.0.3", 41 | "karma-jasmine": "~4.0.0", 42 | "karma-jasmine-html-reporter": "~1.7.0", 43 | "ng-packagr": "^13.0.0", 44 | "typescript": "~4.4.3" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /projects/ngx-loaders-css/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma'), 14 | ], 15 | client: { 16 | jasmine: { 17 | // you can add configuration options for Jasmine here 18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html 19 | // for example, you can disable the random execution with `random: false` 20 | // or set a specific seed with `seed: 4321` 21 | }, 22 | clearContext: false, // leave Jasmine Spec Runner output visible in browser 23 | }, 24 | jasmineHtmlReporter: { 25 | suppressAll: true, // removes the duplicated traces 26 | }, 27 | coverageReporter: { 28 | dir: require('path').join(__dirname, '../../coverage/my-lib'), 29 | subdir: '.', 30 | reporters: [{ type: 'html' }, { type: 'text-summary' }], 31 | }, 32 | reporters: ['progress', 'kjhtml'], 33 | port: 9876, 34 | colors: true, 35 | logLevel: config.LOG_INFO, 36 | autoWatch: true, 37 | browsers: ['Chrome'], 38 | singleRun: false, 39 | restartOnFileChange: true, 40 | }); 41 | }; 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Angular Loaders.css 2 | 3 | [Loaders.css](https://connoratherton.com/loaders) component for Angular X. 4 | 5 | ## Demo 6 | 7 | ![demo](./src/assets/demo.gif) 8 | 9 | Click [here](https://ngx-loaders-css-demo.stackblitz.io) to see the live DEMO, or try it out on [stackblitz](https://stackblitz.com/edit/ngx-loaders-css-demo). 10 | 11 | ## Installation 12 | 13 | ```bash 14 | npm install ngx-loaders-css loaders.css 15 | or 16 | yarn add ngx-loaders-css loaders.css 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```typescript 22 | // ... 23 | import { NgxLoadersCssModule } from 'ngx-loaders-css'; 24 | 25 | @NgModule({ 26 | // ... 27 | imports: [BrowserModule, NgxLoadersCssModule], 28 | }) 29 | export class AppModule {} 30 | ``` 31 | 32 | ```typescript 33 | // ... 34 | import { Component } from '@angular/core'; 35 | import { LoadersCSS } from 'ngx-loaders-css'; 36 | 37 | @Component({ 38 | selector: 'app-root', 39 | template: '', 40 | styleUrls: ['./app.component.css'], 41 | }) 42 | export class AppComponent { 43 | loader: LoadersCSS = 'pacman'; 44 | bgColor = 'black'; 45 | color = 'rgba(100, 100, 100, 0.5)'; 46 | } 47 | ``` 48 | 49 | ## Props 50 | 51 | | props | type | optional | default | desc | 52 | | ------- | ----------- | -------- | ----------- | ------------------------------------------------------------ | 53 | | bgColor | string | true | transparent | set container background color, all valid css color | 54 | | color | string | true | #FFFFFF | set spinner elements color, all valid css color | 55 | | loader | `LoaderCSS` | true | ball-pulse | import `LoadersCSS` type to get intellisense and type check | 56 | | scale | number | true | 1 | zoom loader size | 57 | 58 | ## Known issues 59 | 60 | - Prop color only affect to those loaders that design without border color, the default color is generate by Loader.css style. 61 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** 22 | * By default, zone.js will patch all possible macroTask and DomEvents 23 | * user can disable parts of macroTask/DomEvents patch by setting following flags 24 | * because those flags need to be set before `zone.js` being loaded, and webpack 25 | * will put import in the top of bundle, so user need to create a separate file 26 | * in this directory (for example: zone-flags.ts), and put the following flags 27 | * into that file, and then add the following code before importing zone.js. 28 | * import './zone-flags.ts'; 29 | * 30 | * The flags allowed in zone-flags.ts are listed here. 31 | * 32 | * The following flags will work for all browsers. 33 | * 34 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 35 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 36 | * (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 37 | * 38 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 39 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 40 | * 41 | * (window as any).__Zone_enable_cross_context_check = true; 42 | * 43 | */ 44 | 45 | /*************************************************************************************************** 46 | * Zone JS is required by default for Angular itself. 47 | */ 48 | import 'zone.js'; // Included with Angular CLI. 49 | 50 | /*************************************************************************************************** 51 | * APPLICATION IMPORTS 52 | */ 53 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rulesDirectory": ["codelyzer"], 4 | "rules": { 5 | "align": { 6 | "options": ["parameters", "statements"] 7 | }, 8 | "array-type": false, 9 | "arrow-return-shorthand": true, 10 | "curly": true, 11 | "deprecation": { 12 | "severity": "warning" 13 | }, 14 | "eofline": true, 15 | "import-blacklist": [true, "rxjs/Rx"], 16 | "import-spacing": true, 17 | "indent": { 18 | "options": ["spaces"] 19 | }, 20 | "max-classes-per-file": false, 21 | "max-line-length": [true, 140], 22 | "member-ordering": [ 23 | true, 24 | { 25 | "order": ["static-field", "instance-field", "static-method", "instance-method"] 26 | } 27 | ], 28 | "no-console": [true, "debug", "info", "time", "timeEnd", "trace"], 29 | "no-empty": false, 30 | "no-inferrable-types": [true, "ignore-params"], 31 | "no-non-null-assertion": true, 32 | "no-redundant-jsdoc": true, 33 | "no-switch-case-fall-through": true, 34 | "no-var-requires": false, 35 | "object-literal-key-quotes": [true, "as-needed"], 36 | "quotemark": [true, "single"], 37 | "semicolon": { 38 | "options": ["always"] 39 | }, 40 | "space-before-function-paren": { 41 | "options": { 42 | "anonymous": "never", 43 | "asyncArrow": "always", 44 | "constructor": "never", 45 | "method": "never", 46 | "named": "never" 47 | } 48 | }, 49 | "typedef": [true, "call-signature"], 50 | "typedef-whitespace": { 51 | "options": [ 52 | { 53 | "call-signature": "nospace", 54 | "index-signature": "nospace", 55 | "parameter": "nospace", 56 | "property-declaration": "nospace", 57 | "variable-declaration": "nospace" 58 | }, 59 | { 60 | "call-signature": "onespace", 61 | "index-signature": "onespace", 62 | "parameter": "onespace", 63 | "property-declaration": "onespace", 64 | "variable-declaration": "onespace" 65 | } 66 | ] 67 | }, 68 | "variable-name": { 69 | "options": ["ban-keywords", "check-format", "allow-pascal-case"] 70 | }, 71 | "whitespace": { 72 | "options": [ 73 | "check-branch", 74 | "check-decl", 75 | "check-operator", 76 | "check-separator", 77 | "check-type", 78 | "check-typecast" 79 | ] 80 | }, 81 | "component-class-suffix": true, 82 | "contextual-lifecycle": true, 83 | "directive-class-suffix": true, 84 | "no-conflicting-lifecycle": true, 85 | "no-host-metadata-property": true, 86 | "no-input-rename": true, 87 | "no-inputs-metadata-property": true, 88 | "no-output-native": true, 89 | "no-output-on-prefix": true, 90 | "no-output-rename": true, 91 | "no-outputs-metadata-property": true, 92 | "template-banana-in-box": true, 93 | "template-no-negated-async": true, 94 | "use-lifecycle-interface": true, 95 | "use-pipe-transform-interface": true, 96 | "directive-selector": [true, "attribute", "app", "camelCase"], 97 | "component-selector": [true, "element", "app", "kebab-case"] 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /projects/ngx-loaders-css/src/lib/ngx-loaders-css.component.ts: -------------------------------------------------------------------------------- 1 | import { 2 | ChangeDetectionStrategy, 3 | Component, 4 | ElementRef, 5 | Input, 6 | QueryList, 7 | ViewChildren, 8 | } from '@angular/core'; 9 | 10 | @Component({ 11 | selector: 'loaders-css', 12 | template: ` 13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | `, 21 | styleUrls: [ 22 | '../../../../node_modules/loaders.css/loaders.min.css', 23 | './ngx-loaders-css.component.css', 24 | ], 25 | changeDetection: ChangeDetectionStrategy.OnPush, 26 | }) 27 | export class NgxLoadersCssComponent { 28 | @ViewChildren('spinner') spinners?: QueryList; 29 | 30 | @Input() bgColor = 'transparent'; 31 | 32 | @Input() color = '#FFFFFF'; 33 | 34 | $loader: LoadersCSS = 'ball-pulse'; 35 | 36 | children = Array.from({ length: 3 }); 37 | 38 | @Input() 39 | set loader(loader: LoadersCSS) { 40 | if (LoadersConfig[loader]) { 41 | this.$loader = loader; 42 | const config = LoadersConfig[this.$loader]; 43 | this.children = Array.from({ length: config.children }); 44 | this.updateSpinnersColor(config); 45 | } 46 | } 47 | 48 | $scale = getScale(1); 49 | 50 | @Input() 51 | set scale(scale: number) { 52 | this.$scale = getScale(scale); 53 | } 54 | 55 | private updateSpinnersColor(config: LoadersCSSConfig) { 56 | this.spinners 57 | ? this.spinners.forEach( 58 | (elm) => (elm.nativeElement.style.backgroundColor = config.hasBg ? this.color : ''), 59 | ) 60 | : setTimeout(() => this.updateSpinnersColor(config), 100); 61 | } 62 | } 63 | 64 | export type LoadersCSS = 65 | | 'ball-pulse' 66 | | 'ball-grid-pulse' 67 | | 'ball-clip-rotate' 68 | | 'ball-clip-rotate-pulse' 69 | | 'square-spin' 70 | | 'ball-clip-rotate-multiple' 71 | | 'ball-pulse-rise' 72 | | 'ball-rotate' 73 | | 'cube-transition' 74 | | 'ball-zig-zag' 75 | | 'ball-zig-zag-deflect' 76 | | 'ball-triangle-path' 77 | | 'ball-scale' 78 | | 'line-scale' 79 | | 'line-scale-party' 80 | | 'ball-scale-multiple' 81 | | 'ball-pulse-sync' 82 | | 'ball-beat' 83 | | 'line-scale-pulse-out' 84 | | 'line-scale-pulse-out-rapid' 85 | | 'ball-scale-ripple' 86 | | 'ball-scale-ripple-multiple' 87 | | 'ball-spin-fade-loader' 88 | | 'line-spin-fade-loader' 89 | | 'triangle-skew-spin' 90 | | 'pacman' 91 | | 'ball-grid-beat' 92 | | 'semi-circle-spin'; 93 | 94 | function getScale(scale: number) { 95 | return `scale(${scale}, ${scale})`; 96 | } 97 | type LoadersCSSConfig = { children: number; hasBg: boolean }; 98 | 99 | const LoadersConfig: { [k in LoadersCSS]: LoadersCSSConfig } = { 100 | 'ball-pulse': { children: 3, hasBg: true }, 101 | 'ball-grid-pulse': { children: 9, hasBg: true }, 102 | 'ball-clip-rotate': { children: 1, hasBg: false }, 103 | 'ball-clip-rotate-pulse': { children: 2, hasBg: false }, 104 | 'square-spin': { children: 1, hasBg: true }, 105 | 'ball-clip-rotate-multiple': { children: 2, hasBg: false }, 106 | 'ball-pulse-rise': { children: 5, hasBg: true }, 107 | 'ball-rotate': { children: 1, hasBg: false }, 108 | 'cube-transition': { children: 2, hasBg: true }, 109 | 'ball-zig-zag': { children: 2, hasBg: true }, 110 | 'ball-zig-zag-deflect': { children: 2, hasBg: true }, 111 | 'ball-triangle-path': { children: 3, hasBg: false }, 112 | 'ball-scale': { children: 1, hasBg: true }, 113 | 'line-scale': { children: 5, hasBg: true }, 114 | 'line-scale-party': { children: 4, hasBg: true }, 115 | 'ball-scale-multiple': { children: 3, hasBg: true }, 116 | 'ball-pulse-sync': { children: 3, hasBg: true }, 117 | 'ball-beat': { children: 3, hasBg: true }, 118 | 'line-scale-pulse-out': { children: 5, hasBg: true }, 119 | 'line-scale-pulse-out-rapid': { children: 5, hasBg: true }, 120 | 'ball-scale-ripple': { children: 1, hasBg: false }, 121 | 'ball-scale-ripple-multiple': { children: 3, hasBg: false }, 122 | 'ball-spin-fade-loader': { children: 8, hasBg: true }, 123 | 'line-spin-fade-loader': { children: 8, hasBg: true }, 124 | 'triangle-skew-spin': { children: 1, hasBg: false }, 125 | pacman: { children: 5, hasBg: false }, 126 | 'ball-grid-beat': { children: 9, hasBg: true }, 127 | 'semi-circle-spin': { children: 1, hasBg: false }, 128 | }; 129 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "ngx-loaders-css-app": { 7 | "projectType": "application", 8 | "schematics": { 9 | "@schematics/angular:application": { 10 | "strict": true 11 | } 12 | }, 13 | "root": "", 14 | "sourceRoot": "src", 15 | "prefix": "app", 16 | "architect": { 17 | "build": { 18 | "builder": "@angular-devkit/build-angular:browser", 19 | "options": { 20 | "outputPath": "dist/ngx-loaders-css-app", 21 | "index": "src/index.html", 22 | "main": "src/main.ts", 23 | "polyfills": "src/polyfills.ts", 24 | "tsConfig": "tsconfig.app.json", 25 | "aot": true, 26 | "assets": ["src/favicon.ico", "src/assets"], 27 | "styles": ["src/styles.css"], 28 | "scripts": [] 29 | }, 30 | "configurations": { 31 | "production": { 32 | "budgets": [ 33 | { 34 | "type": "initial", 35 | "maximumWarning": "500kb", 36 | "maximumError": "1mb" 37 | }, 38 | { 39 | "type": "anyComponentStyle", 40 | "maximumWarning": "2kb", 41 | "maximumError": "4kb" 42 | } 43 | ], 44 | "fileReplacements": [ 45 | { 46 | "replace": "src/environments/environment.ts", 47 | "with": "src/environments/environment.prod.ts" 48 | } 49 | ], 50 | "outputHashing": "all", 51 | "serviceWorker": true, 52 | "ngswConfigPath": "ngsw-config.json" 53 | }, 54 | "development": { 55 | "buildOptimizer": false, 56 | "optimization": false, 57 | "vendorChunk": true, 58 | "extractLicenses": false, 59 | "sourceMap": true, 60 | "namedChunks": true 61 | } 62 | }, 63 | "defaultConfiguration": "production" 64 | }, 65 | "serve": { 66 | "builder": "@angular-devkit/build-angular:dev-server", 67 | "options": { 68 | "browserTarget": "ngx-loaders-css-app:build" 69 | }, 70 | "configurations": { 71 | "production": { 72 | "browserTarget": "ngx-loaders-css-app:build:production" 73 | }, 74 | "development": { 75 | "browserTarget": "ngx-loaders-css-app:build:production" 76 | } 77 | }, 78 | "defaultConfiguration": "production" 79 | }, 80 | "extract-i18n": { 81 | "builder": "@angular-devkit/build-angular:extract-i18n", 82 | "options": { 83 | "browserTarget": "ngx-loaders-css-app:build" 84 | } 85 | }, 86 | "test": { 87 | "builder": "@angular-devkit/build-angular:karma", 88 | "options": { 89 | "main": "src/test.ts", 90 | "polyfills": "src/polyfills.ts", 91 | "tsConfig": "tsconfig.spec.json", 92 | "karmaConfig": "src/karma.conf.js", 93 | "styles": ["src/styles.css"], 94 | "scripts": [], 95 | "assets": ["src/favicon.ico", "src/assets"] 96 | } 97 | } 98 | } 99 | }, 100 | "ngx-loaders-css": { 101 | "projectType": "library", 102 | "root": "projects/ngx-loaders-css", 103 | "sourceRoot": "projects/ngx-loaders-css/src", 104 | "prefix": "lib", 105 | "architect": { 106 | "build": { 107 | "builder": "@angular-devkit/build-angular:ng-packagr", 108 | "options": { 109 | "project": "projects/ngx-loaders-css/ng-package.json" 110 | }, 111 | "configurations": { 112 | "production": { 113 | "tsConfig": "projects/ngx-loaders-css/tsconfig.lib.prod.json" 114 | }, 115 | "development": { 116 | "tsConfig": "projects/ngx-loaders-css/tsconfig.lib.json" 117 | } 118 | } 119 | }, 120 | "test": { 121 | "builder": "@angular-devkit/build-angular:karma", 122 | "options": { 123 | "main": "projects/ngx-loaders-css/src/test.ts", 124 | "tsConfig": "projects/ngx-loaders-css/tsconfig.spec.json", 125 | "karmaConfig": "projects/ngx-loaders-css/karma.conf.js" 126 | } 127 | } 128 | } 129 | } 130 | }, 131 | "defaultProject": "ngx-loaders-css-app" 132 | } 133 | --------------------------------------------------------------------------------