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

@acknow-srl/dialog

v0.1.12

Published

Handles two commonly used dialog windows: a loading modal dialog and a message dialog. It depends on Material Design `MatDialogModule`.

Downloads

29

Readme

Dialog

Handles two commonly used dialog windows: a loading modal dialog and a message dialog. It depends on Material Design MatDialogModule.

AckLoadingDialogConfig (Interface)

Configuration object for loading modal dialogs.

  • text (string): message text shown on the dialog. Default: ''.
  • label (string): HTML aria-label attribute for the dialog. Default: Loading....
  • color (string): Material Design color keyword for spinner (primary, accent or warn). Default: primary.
  • id (string): optional HTML id attribute for the dialog. Default: ''.
  • diameter (number): Material Design spinner diameter in pixels. Default: 64.
  • strokeWidth (number): Material Design spinner size in pixels. Default: 5.

AckMessageDialogConfig (Interface)

Configuration object for message dialogs.

  • text (string): message text shown on the dialog. Default: ''.
  • label (string): HTML aria-label attribute for the dialog. Default: Message.
  • color (string): Material Design color keyword for dialog button (primary, accent or warn). Default: primary.
  • id (string): optional HTML id attribute for the dialog. Default: ''.
  • button (string): optional button text. Default: OK.

AckDialog (Service)

It is provided in root, so it is available to the whole app.

Methods

  • loading(data: string|AckLoadingDialogConfig = ''): MatDialogRef: opens a modal dialog with a spinner (in indeterminate mode) and an optional custom message. Returns a reference to the opened MatDialog object. Loading dialogs are always modals, because it has to prevent all user interactions (i.e.: during adatabase read/write operation).
  • message(data: string|AckMessageDialogConfig): MatDialogRef: opens a dialog with a custom message and a button to close it. Returns a reference to the opened MatDialog object. This dialog is never a modal dialog, because the message is only for information purpose.

Example

/**
 * 1. Import the module in your main module (usually app.module.ts).
 */

import { AckDialogModule } from '@acknow-srl/dialog';

/**
 * 2. Add the module to your app imports.
 */

@NgModule({
  declarations: [
    AppComponent
    ...
  ],
  imports: [
    ...
    AckDialogModule,
    ...
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
}

/**
 * 3. Implement some dialogs in your components.
 */

import { AckDialog, AckMessageDialogConfig } from '@acknow-srl/dialog';

@Component({
    ...
})
export class MyComponent {

    constructor(private dialog: AckDialog) {
    }

    /**
     * Open a message dialog.
     * Since it has an OK button to close, no need to return a reference for closing.
     */

    openMessage() {
        this.dialog.message('A useful message for your users.');
    }

    /**
     * Open an error message dialog passing a full configuration object.
     */

    openErrorDialog() {

        const error: AckMessageDialogConfig = {
            text: 'Sorry, but an error has occurred!',
            label: 'Error',
            color: 'warn',
            id: 'my-error',
            button: 'Close'
        };

        this.dialog.message(error);
    }

    /**
     * Open a loading modal dialog without any text and close it after 5 seconds.
     * A loading modal dialog has no way to close itself from inside,
     * because it has to prevent all user interactions for some time.
     * So, we need to return a reference for the opened modal dialog to close it.
     */

    openLoading() {

        const loadingDialogRef = this.dialog.loading();

        setTimeout(function() {
            loadingDialogRef.close();
        },5000);

    }
}