0.0.9 โ€ข Published 2 years ago

ya-custom-modal-lib v0.0.9

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

Custom Modal For Angular

Simple, lightweight and configurable modal box component to implemnt your dynamic pop up component.

๐Ÿงพ Features

  • Dynamic injection
  • Customization (Size, Color, Content, etc..)
  • Multiple modal at once
  • Host's component interaction wih model's actions (๐Ÿ†— button)
  • Auto closeable configuration

โœจ Installation

  npm i ya-custom-modal-lib

๐ŸšŠ Usage

Three steps and roll out ๐Ÿ˜€

  • Import CustomModalModule to your root AppModule
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { CustomModalModule } from 'custom-modal';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    CustomModalModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
  • Inject fallowing two services to component where you want to add custom modal
  
import { Component, ViewContainerRef } from '@angular/core';
import { ModalService } from 'custom-modal';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  
  constructor(
    private modalService: ModalService,
    private componentReference: ViewContainerRef
  ) { }

}
  • Create a function and call openModel function in ModalService with custom configuration.(You can pass prefered configuration by using parameters)
  
import { Component, ViewContainerRef } from '@angular/core';
import { ModalService } from 'custom-modal';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  
  constructor(
    private modalService: ModalService,
    private componentReference: ViewContainerRef
  ) { }

  onOpenModal() : void{
    this.modalService.openModel({
      viewContainerRef: this.componentReference,
      title: 'one',
      height: '500px',
      width: '500px',
      backgroundColor: '#f00',
      bodyText: 'one works!',
      closeAfter: 2000
    }).subscribe((res) => {

    });
  }

}

API Reference

openModel({modalConfigurations})

ParameterTypeDescription
viewContainerRefViewContainerRefRequired. Component Reference where need to be added modal
titlestringTitle for modal box
bodyTextstringBody text for the modal box
heightstringHeight of the modal box
backgroundColorstringBackground Color (Only applicable CSS colors)
closeAfternumberIf required auto closeable (milisecond)
0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago