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

ff-modal

v8.0.0

Published

[![Build Status](https://travis-ci.org/frontendfreelancerdk/ff-modal.svg?branch=master)](https://travis-ci.org/frontendfreelancerdk/ff-modal)

Downloads

12

Readme

Build Status

ff-modal

Installing

npm install ff-modal --save

Usage

You have two ways to use modal in your project:

  • from component
  • from service

!IMPORTANT The main difference - if you use with the service there can be only single modal, but if you are using with component there can be multiple modals. Also service method close can't close any modals which you created as a component.

First step : include FFModalModule in AppModule imports.

app.module.ts

import {NgModule} from '@angular/core';

import {AppComponent} from './app.component';
import {FFModalModule} from 'ff-modal';

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

Then you can use ff-modal component:

First way

As ng-content

app.component.html

<ff-modal *ngIf="flag" (closed)="flag = false">
  <p>Lorem ipsum dolor sit amet.</p>
</ff-modal>

<button (click)="flag = true">open modal</button>

Or with Template Reference Variables

app.compoent.html

<ff-modal *ngIf="flag" [ff-content]="myTemlate" (closed)="flag = false">
</ff-modal>

<ng-template #myTemlate>
  <p>Lorem ipsum dolor sit amet.</p>
</ng-template>

<button (click)="flag = true">open modal</button>

app.component.ts

import {Component} from '@angular/core';

@Component({
  selector: 'ff-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  flag = false;
}

Second way

Using with service and Template Reference Variables

app.component.ts

import {Component, TemplateRef, ViewChild} from '@angular/core';
import {FFModalService} from 'ff-modal';

@Component({
  selector: 'ff-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  @ViewChild('myTemlate') template: TemplateRef<any>;
  @ViewChild('someComponent') someComponent: TemplateRef<any>;
  
  constructor(public ffModalService: FFModalService) {
  }

  openModal(template) {
    this.ffModalService.open(template);
  }
  
  openModalFromViewChild(){
    this.ffModalService.open(this.template);
  }

  closeModal(){
    this.ffModalService.close();
  }
}

app.component.html

<ng-template #myTemlate>
  <div>
    Lorem ipsum dolor sit amet, consectetur adipisicing elit.
    Accusantium modi non vitae. A consequuntur delectus,
    dolore est maiores mollitia quaerat quisquam quos sit vel! ?
  </div>
</ng-template>

<ng-template #someComponent>
  <!--Your some component (e.g login)-->
  <some-component></some-component>
</ng-template>

<button (click)="openModal(someComponent)">open some component in modal</button>
<button (click)="openModalFromViewChild()">open another modal</button>
<button (click)="closeModal()">close modal</button>

API

<ff-modal>

// [ff-content] for set some template into modal
  @Input('ff-content') content: TemplateRef<any>;
// [ff-modal-options] for set options
  @Input('ff-modal-options') options: FFModalOptions;
// (closed) will be called after closing the modal (after all animations are done) 
  @Output() closed: EventEmitter<boolean>;

FFModalService

/* Method open modal. First parameter is required.
It takes some template, that you want to set.
Second - is optional. It takes options for modal */
  open(template:TemplateRef<any>, options: FFModalOptions)
// Method take some options that will be set to modal
  setOptions(options: FFModalOptions)
// Method just closes current modal
  close()

Options

// Default options
{
  disabled: false, // block closing
  cross: true, // should a cross be present
  overlay: true, // should a overlay (background) be present
  closeOnClickOutsideModal: true, // should close modal after click on overlay
  rounded: true, // should modal and cross be rounded
  overlayClass: '', // css class to be added to the overlay
  wrapperClass: '' // css class to be added to the wrapper
}

Styling

You can change default styles. That can be used to target a overlay, wrapper or cross.

styles.css your global styles

ff-modal.ff-modal-overlay{
  /* for change styles for overlay (e.g background) */
}

ff-modal .ff-modal-wrapper{
  /* for change styles for modal-wrapper 
  (e.g background, padding , position and so on) */
}

ff-modal .ff-modal-cross{
  /* for change styles for default cross */
}

License

MIT Frontend Freelancer