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

nira-modal

v1.0.7

Published

This library Supports Angular CLI versions greater than or equal to 16.1.0. This package creates a modal that gives you ability to access and customize some modal features, such as the **color of the screen** and ability to control whether the modal can

Downloads

13

Readme

NiraModal

This library Supports Angular CLI versions greater than or equal to 16.1.0. This package creates a modal that gives you ability to access and customize some modal features, such as the color of the screen and ability to control whether the modal can be closed by clicking outside. You can pass data to nira-modal and get result from that.

Installation

npm i nira-modal

How To Open Modal

  1. First inject NiraModalModule in the module you want to use nira-modal in it; like bellow:
import { NiraModalModule} from 'nira-modal';
@NgModule({
//other imports
imports: [NiraModalModule],
})
  1. Declare @Input() variables: You must declare NiraModalConfig and closeSubject with @Input() directive in component.tslike bellow:
 @Input() config!: NiraModalConfig;
 @Input() closeSubject!: Subject<any>;
  1. Opening modal:
  • Inject NiraModalService in component.ts file like this:
constructor(private niraModalService: NiraModalService) {}
  • In the method called in component.ts file, call this.niraModalService.open() and pass the component you want to show in it like bellow:
openModal(){
this.niraModalSerevice.open(TestModalComponent)}

Implementation

implement IModal interface to the component class to prevent forgetting @Input() directives:

export class TestModalComponent implements IModal {}

How To Pass data From Parent Component To nira-modal

You can pass any data to nira-modal with data property , exists in NiraModalConfig interface whilethis.niraModalService.open() method is called:

  openModal() {
    // 'modalData' is any data with any type you want to pass
    const modal = this.niraModalService.open(TestModalComponent, {
      data: modalData,
    });}

How To Close Modal

Now You can close nira-modal by calling .next() method in this.closeSubject like bellow:

 close() {
  this.closeSubject.next();
}

How To Emit result From Modal

  1. Emit Data From modal: you can emit any data by passing in the this.closeSubject.next() method while closing modal:
 close() {
  // 'modalResult'is any data you want to pass from modal to parrent component
  this.closeSubject.next(modalResult);
}
  1. Receive Emitted Data in parant component:
  • Assign this.niraModalService.open(YourModalComponent) to a variable:
openModal() {
 // 'modalData' is any data with any type you want to pass
   const modal = this.niraModalService.open(TestModalComponent);
   }
  • Subscribe .afterClosed() method in assigned variable:
openModal() {
 // 'modalData' is any data with any type you want to pass
   const modal = this.niraModalService.open(TestModalComponent);
   modal.afterClosed.subscribe((modalResult) => {});
   }

How To Customize Modal

You can customize nira-modal with some config in object structure by passing them in this.niraModalService.open() method . this is NiraModalConfig interface with all optional properties you can pass :

interface NiraModalConfig {
  outsideClose?: boolean;
  screenColor?: string;
  data?: any;
}
  • Config description: | property | description | Required/Optional | default value | | ---------------------- | --------------------------------------------------------| ---------------------- | ---------------------- | | outsideClose | by passing false with this property you can prevent closing modal by clicking outside. | optional | true | |screenColor| can customize color of screen behind the modal | optional | #0000004f | | data |You can pass any data you want to nira-modal with this property | optional | undefined |

    • Example of nira-modal customization:
    constructor(private niraModalSerevice: NiraModalService) {}
    
    openModal() {
      let modalData = {name:'Nira', age:20}
      this.niraModalSerevice.open(TestModalComponent, {
        outsideClose: false,
        screenColor: 'rgba(0, 0, 255, 0.3)',
        data: modalData
      });
    }