npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-mat-loading

v1.1.1

Published

Customizable Loading overlay service and directive for Angular Material.

Downloads

11

Readme

NgxMatLoading

Customizable Loading overlay service and directive for Angular Material.

StackBlitz Demo

Features

  • Global or Element/Component overlay
  • Custom inner component

TODO

  • Tests
  • Documentation

Installation

npm -i ngx-mat-loading

Update angular.json

  "styles": [
    "node_modules/ngx-mat-loading/ngx-mat-loading.css",
    "src/styles.scss"
  ]

Import and configure

import { NgxMatLoadingModule, NGX_MAT_LOADING_DEFAULT_OPTIONS } from "ngx-mat-loading";

@NgModule({
  ...,
  imports: [
    NgxMatLoadingModule
  ],
  providers: [
    {
      provide: NGX_MAT_LOADING_DEFAULT_OPTIONS, 
      useValue: {
        backdropClass: 'ngx-mat-loading-dark-backdrop',
        innerOverlay: true,
        componentClass: 'my-loading-component', 
        componentProps: { indicator: 'bar', text: 'LOADING...' }
      }
    }
  ],
  ...
})

Example

Global loading

import { Component } from "@angular/core";
import { concatMap, delay, finalize, tap } from "rxjs/operators";
import { NgxMatLoadingService } from "ngx-mat-loading";

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  
  constructor(
      private _loading: NgxMatLoadingService
  ) {}
  
  showLoading() {
    this._loading.show({
      mode: "determinate",
      text: 'Starting...'
    }, {
      componentStyle: {
        'width': '150px'
      }
    });
    of(0, 3, 15, 34, 62, 63, 64, 65, 99, 100).pipe(
      concatMap(x => of(x).pipe(delay(500))),
      tap(v => this._loading.update({ value: v, text: `Processing ${v}%...` })),
      finalize(() => this._loading.hide())
    ).subscribe();
  }
}

Element/Component loading

export class MyComponent {
  loading: boolean = false;
}
<div
  class="my-div"
  [ngxMatLoading]="loading"
  ngxMatLoadingBackdropClass="ngx-mat-loading-light-backdrop"
  ngxMatLoadingInnerOverlay>
  
  content
  
</div>

<button (click)="loading = !loading">Toggle loading</button>

Services

NgxMatLoadingService

Properties

| Property | Description | | :------- | :---------- | | visible: boolean | | | componentRef?: ComponentRef<any> | Reference to inner loading component. |

Methods

| Method | Description | | :----- | :---------- | | show(props?: NgxMatLoadingComponentProps | any, options?: NgxMatLoadingOptions): void | Show overlay. | | update(props?: NgxMatLoadingComponentProps | any): void | Update overlay's component content. | | hide(): void | Hide overlay.|

Directives

NgxMatLoadingDirective

Selector: ngxMatLoading Exported as: ngxMatLoading

Properties

| Property | Description | | :------- | :---------- | | @Input('ngxMatLoading')show: boolean | | | @Input('ngxMatLoadingBackdropClass')backdropClass?: string | | | @Input('ngxMatLoadingPanelClass')panelClass?: string | | | @Input('ngxMatLoadingInnerOverlay')innerOverlay: boolean | Default false.| | @Input('ngxMatLoadingComponentType')componentType?: ComponentType<any> | | | @Input('ngxMatLoadingComponentProps')componentProps?: NgxMatLoadingComponentProps | any | | | @Input('ngxMatLoadingComponentClass')componentClass?: string | | | @Input('ngxMatLoadingComponentStyle')componentStyle?: {[key:string]: string} | | | visible: boolean | | | componentRef?: ComponentRef<any> | Reference to inner loading component. |

Methods

| Method | Description | | :----- | :---------- | | show(props?: NgxMatLoadingComponentProps | any): void | Show overlay. | | update(props?: NgxMatLoadingComponentProps | any): void | Update overlay's component content. | | hide(): void | Hide overlay.|

Interfaces

NgxMatLoadingComponentProps

export interface NgxMatLoadingComponentProps {
  /**
   * Loading message
   */
  text?: string;

  /**
   * Spinner's or Bar's value. Works only with 'spinner' or 'bar' indicator with 'determinate' mode.
   */
  value?: number;

  /**
   * Spinner's or Bar's mode
   */
  mode?: 'indeterminate' | 'determinate';

  /**
   * Show progress with MatSpinner or MatProgressBar.
   */
  indicator?: 'none' | 'spinner' | 'bar';

  /**
   * Spinner's diameter
   */
  indicatorDiameter?: number;

  /**
   * Spinner's stroke width or Bar width
   */
  indicatorWidth?: number;

  /**
   * Spinner or Bar color
   */
  indicatorColor?: string;
}

NgxMatLoadingOptions

export interface NgxMatLoadingOptions {
  /**
   * Loading's overlay backdrop class
   */
  backdropClass?: string;

  /**
   * Loading's overlay content panel class
   */
  panelClass?: string;

  /**
   * Whether overlay is inside covered element or in global overlay container. Works only with NgxMatLoading directive.
   * Default false.
   */
  innerOverlay?: boolean;

  /**
   * Whether loading overlay will block global scroll. Works only with NgxMatLoading service. Default is false.
   */
  blockScroll?: boolean,

  /**
   * Loading's overlay content component. Default NgxMatLoadingComponent.
   */
  componentType?: ComponentType<any>;

  /**
   * Loading's overlay content component's CSS class.
   */
  componentClass?: string;

  /**
   * Loading's overlay content component's CSS style.
   */
  componentStyle?: {[key: string]: string};

  /**
   * Loading's overlay content component properties (inputs).
   */
  componentProps?: NgxMatLoadingComponentProps | any;
}