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

@cristiansarghe/ng-generic-modal

v14.0.1

Published

`@cristiansarghe/ng-generic-modal` is a _just-add-water_ customizable and lightweight Angular popup.

Downloads

3

Readme

Angular Generic Modal

Customizable Angular modal

What is it?

@cristiansarghe/ng-generic-modal is a just-add-water customizable and lightweight Angular popup.

Installation

npm i @cristiansarghe/ng-generic-modal

Customization

Content

  • The modal has 3 parts, driven by ng-templates: modalHeading, modalBody and modalActions. You can pass content to any of them in the following way:
<ng-generic-modal #modalReference>
	<ng-template #modalHeading>
		This is the heading
	</ng-template>

	<ng-template #modalBody>
		This is the modal body
	</ng-template>

	<ng-template #modalActions>
		<button>This is an action</button>
		<button>And this is another action</button>
	</ng-template>
</ng-generic-modal>

Opening and hiding

  • Given modalReference a reference to the modal element, method modalReference.open() will open the popup.
  • To hide the modal, it's enough to call modalReference.hide().
  • To rely less on method calling, the modal-close directive allows picking one or more elements inside the modal templates that close the modal when clicked. Example:
<ng-generic-modal #modalReference>
	<ng-template #modalActions>
		<button modal-close (click)="myMethod()">Submit</button>
		<button modal-close>Cancel</button>
		<button>Options</button>
	</ng-template>
</ng-generic-modal>

In the above example, the Close button will just hide the modal, while the Submit button will run myMethod() and then hide the modal. The Options button will not hide the modal, as it doesn't have modal-close attached.

  • NOTE: open method can receive a state of the modal (which can be any object or primitive value). That value can be accessed within the modal ng-templates by simply targeting the data variable:
<ng-generic-modal #modalReference>
	<ng-template #modalHeading let-data="data">  // Pass the variable to the template
		This is my name: {{data}}
	</ng-template>
</ng-generic-modal>

data can be accessed at any time, but it's pointless unless there's anything passed to .open(state)

data variable does NOT keep its value between popup sessions (gets erased on each .hide())

@Input()

| Input | Type | Required | Description | | -------------------------- | ------- | -------------------------- | ---------------------------------------------------------------| | hasBackdrop | boolean | Optional, default: true | Show a dark background behind the modal whenever it's open | | customModalContainerClass | string | Optional, default: null | Add a custom class on modal container | | closeOnBackdropClick | boolean | Optional, default: true | Allow closing modal by clicking outside (on the backdrop) | | showCloseButton | boolean | Optional, default: true | Show or hide the top right X closing button |

Output()

| Output | Type | Payload type | Description | | -------------------------- | ------------------ | ----------------------------------------------------------------- | -----------------------------------| | beforeOpen | EventEmitter<T> | The type of the passed state or undefined if there is no state | Event emitted before popup opens | | afterOpen | EventEmitter<T> | The type of the passed state or undefined if there is no state | Event emitted after popup opens | | beforeHide | EventEmitter<void> | undefined | Event emitted before popup hides | | afterHide | EventEmitter<void> | undefined | Event emitted after popup hides |