-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
320 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "pwa-chrome", | ||
"request": "launch", | ||
"name": "Launch Chrome against localhost", | ||
"url": "http://localhost:4200", | ||
"webRoot": "${workspaceFolder}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,69 @@ | ||
# WARNING! | ||
:rotating_light: :rotating_light: :rotating_light: | ||
|
||
This package is still under development and is not optimized nor tested. Please have some time and check back later ;) | ||
|
||
:rotating_light: :rotating_light: :rotating_light: | ||
|
||
# NG Modal Factory | ||
|
||
TBD | ||
The purpose of this packages is to allow the display a (modal-)component, within everywhere inside of the application. The (modal-)component will be rendert inside of the outlet. | ||
|
||
## Installation | ||
|
||
```$ npm i ng-modal-factory``` | ||
|
||
## Quick Start | ||
|
||
### 1. Import the Module | ||
|
||
```TypeScript | ||
@NgModule({ | ||
... | ||
imports: [ | ||
..., | ||
ModalFactoryModule | ||
] | ||
... | ||
}) | ||
export class AppModule { } | ||
``` | ||
|
||
### 2. Place the outlet | ||
|
||
```HTML | ||
... | ||
<ng-modal-factory-outlet></ng-modal-factory-outlet> | ||
... | ||
``` | ||
|
||
### 3. Open a Modal (This example was using the Clarity Design Framework) | ||
|
||
```TypeScript | ||
public openModal() | ||
{ | ||
this.modalFactoryService.openNewAlertModal({ | ||
component: AlertModalComponent, <-- Your modal component | ||
inputs: { | ||
bodyTemplate: this.modalBody, <-- Your modal body | ||
buttons: [ | ||
{ | ||
text: 'custom', | ||
style: 'link', | ||
click: () => console.log('custom') | ||
}, | ||
{ | ||
text: 'Cancel', | ||
style: 'outline', | ||
click: () => console.log('Cancel'), | ||
}, | ||
{ | ||
text: 'Ok', | ||
type: 'primary', | ||
click: () => console.log('Ok'), | ||
}, | ||
], | ||
}, | ||
}); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule gitflow
added at
d409ef
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 12 additions & 1 deletion
13
projects/ng-modal-factory-example/src/app/alert-modal/alert-modal.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,12 @@ | ||
<p>alert-modal works!</p> | ||
<clr-modal [(clrModalOpen)]="modalOpen"> | ||
<h3 class="modal-title"> | ||
<ng-container>{{headline}}</ng-container> | ||
</h3> | ||
<div class="modal-body"> | ||
<ng-container *ngTemplateOutlet="bodyTemplate"></ng-container> | ||
</div> | ||
<div class="modal-footer"> | ||
<button *ngFor="let button of buttons" [disabled]="button.disabled" type="button" | ||
[class]="getCssClasses(button)" (click)="buttonClick(button)">{{ button.text }}</button> | ||
</div> | ||
</clr-modal> |
29 changes: 25 additions & 4 deletions
29
projects/ng-modal-factory-example/src/app/alert-modal/alert-modal.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,36 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Component, Inject, OnDestroy, OnInit, Optional, TemplateRef } from '@angular/core'; | ||
import { ClarityModalButton } from 'ng-modal-factory'; | ||
|
||
@Component({ | ||
selector: 'app-alert-modal', | ||
templateUrl: './alert-modal.component.html', | ||
styleUrls: ['./alert-modal.component.css'] | ||
}) | ||
export class AlertModalComponent implements OnInit { | ||
export class AlertModalComponent { | ||
|
||
constructor() { } | ||
modalOpen: boolean = true; | ||
|
||
ngOnInit(): void { | ||
constructor(@Inject('buttons') public buttons: ClarityModalButton[], | ||
@Optional() | ||
@Inject('bodyTemplate') public bodyTemplate: TemplateRef<any>, | ||
@Optional() | ||
@Inject('headline') public headline: string) {} | ||
|
||
public buttonClick(button: ClarityModalButton) { | ||
button.click(); | ||
this.modalOpen = false; | ||
} | ||
|
||
getCssClasses(button: ClarityModalButton) { | ||
let classes = `btn `; | ||
|
||
if (button.type) classes += `btn-${button.type} `; | ||
|
||
if (button.style) classes += `btn-${button.style} `; | ||
|
||
if (button.size) classes += `btn-${button.size} `; | ||
|
||
return classes; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
button { | ||
margin: 1rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<lib-ng-modal-factory-outlet></lib-ng-modal-factory-outlet> | ||
<ng-modal-factory-outlet></ng-modal-factory-outlet> | ||
|
||
<button (click)="openModal()">Open Modal</button> | ||
<button type="button" class="btn btn-primary" (click)="openModal()">Open Modal</button> | ||
|
||
<ng-template #modalBody>My CSTM Body</ng-template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.