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

@gecosuy/angular-loader

v17.0.0

Published

Librería utilitaria para manejo de loaders

Downloads

14

Readme

Angular Loader

Librería utilitaria para manejo de loaders.

Uso

Maneja 2 tipos de loader, uno global que se debe agregar en el app.component y cubre toda la pantalla. Y luego permite definición de multiples loaders internos nombrados.
Además cuenta con un interceptor HTTP para poder usar si se requiere, para mostrar automáticamente un loader en los request http.

Importar el módulo:

En el AppModule se debe importar el AngularLoaderModule y ademas agregar schemas: [CUSTOM_ELEMENTS_SCHEMA].

Agregar en el HTML

Agregar el loader en el html de la siguiente forma:

<lib-angular-loader ...></lib-angular-loader>

Se puede dar valor a las siguientes propiedades como inputs del componente, en otro caso se toman valores por defecto:

  • name: obligatorio para loader internos y NO se debe pasar para el loader global
  • message: mensaje a mostrar junto con el indicador de loading
  • backdropColor: color del backdrop
  • type: tipo de loader, ver https://labs.danielcardoso.net/load-awesome/animations.html
  • size: tamaño
  • color: color del indicador

Además estas propiedades pueden ser redefinidas cuando se llama al loader si se requiere.

Agregar las animaciones a usar en el angular.json

Cada una de las animaciones que se quieran usar (los diferentes 'type' que se quieran usar en la app), deben ser agregados en los styles del el angular.json como indica la librería ngx-spinner: https://www.npmjs.com/package/ngx-spinner#usage.

Invocar el loader

Se utiliza el AngularLoaderService para invocar al loader de la siguiente forma:

...
constructor(private loader: AngularLoaderService) {}
...
this.loader.showGlobalLoader(/* puede incluir redefinición de opciones*/);
...
this.loader.hideGlobalLoader();

Las posibles opciones a pasar al invocar son:

{
    name?: string;
    delay?: number;

    message?: string;
    /**
     * Debe ser en formato rgba con opacity
     */
    bdColor?: string;
    size?: LoaderSize;
    color?: string;
    /**
     * Alguna de las opciones de https://labs.danielcardoso.net/load-awesome/animations.html
     */
    type?: string;
}

Usar Interceptor HTTP

Si se requiere además usar el interceptor entonces agregar en el AppModule la configuración:

{
    provide: LOADER_CONFIG,
    useValue: {
        interceptor: {
            delay: 1500,
            customizeShowLoaderByRequest: (req: HttpRequest<any>) => {
                /* return true o false si se requiere mostrar o no segun el request */
            },
            customizeLoaderOptionsByRequest: (req: HttpRequest<any>) => {
                /* retornar una objeto LoaderConfig si se requiere customizar las opciones segun el request */
            }
        }
    }
},
{
    provide: HTTP_INTERCEPTORS,
    useClass: AngularLoaderHttpInterceptor,
    multi: true,
    deps: [AngularLoaderService, LOADER_CONFIG]
}

Themming

Se pueden utilizar las siguientes variables para customizar como se ve el loader. Estos son valores por defecto, luego al invocar se pueden pisar.

  • --loader-indicator-color: color del indicador de loader
  • --loader-backdrop-color: color del backdrop, debe ser en formato rgba con opacity, ejemplo rgba(50, 50, 50, 0.5)
  • --loader-text-color: color del texto
  • --loader-text-font: fuente del texto

TODO

Testear el uso de loaders internos (no global)