Skip to content

Commit

Permalink
Merge branch 'release/v1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Heim committed Feb 26, 2021
2 parents 4357497 + 845e1fa commit 83d3371
Show file tree
Hide file tree
Showing 17 changed files with 320 additions and 55 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
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}"
}
]
}
68 changes: 67 additions & 1 deletion README.md
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'),
},
],
},
});
}
```
22 changes: 11 additions & 11 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@
"projects/ng-modal-factory/tsconfig.lib.json",
"projects/ng-modal-factory/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
"exclude": ["**/node_modules/**"]
}
}
}
Expand All @@ -67,9 +65,15 @@
"projects/ng-modal-factory-example/src/assets"
],
"styles": [
"projects/ng-modal-factory-example/src/styles.css"
"projects/ng-modal-factory-example/src/styles.css",
"node_modules/@clr/icons/clr-icons.min.css",
"node_modules/@clr/ui/clr-ui.min.css"
],
"scripts": []
"scripts": [
"node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js",
"node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js",
"node_modules/@clr/icons/clr-icons.min.js"
]
},
"configurations": {
"production": {
Expand Down Expand Up @@ -129,9 +133,7 @@
"projects/ng-modal-factory-example/src/favicon.ico",
"projects/ng-modal-factory-example/src/assets"
],
"styles": [
"projects/ng-modal-factory-example/src/styles.css"
],
"styles": ["projects/ng-modal-factory-example/src/styles.css"],
"scripts": []
}
},
Expand All @@ -143,9 +145,7 @@
"projects/ng-modal-factory-example/tsconfig.spec.json",
"projects/ng-modal-factory-example/e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
"exclude": ["**/node_modules/**"]
}
},
"e2e": {
Expand Down
1 change: 1 addition & 0 deletions gitflow
Submodule gitflow added at d409ef
72 changes: 72 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "0.0.1",
"author": "Philipp Heim",
"license": "MIT",
"keywords": ["angular"],
"keywords": [
"angular"
],
"homepage": "https://github.com/pheim1/ng-modal-factory#readme",
"bugs": "https://github.com/pheim1/ng-modal-factory/issues",
"scripts": {
Expand All @@ -15,8 +17,8 @@
"e2e": "ng e2e",
"lib:build": "ng build ng-modal-factory --prod",
"lib:dev": "ng build ng-modal-factory --prod --watch",
"lib:publish": "cd dist\\ng-modal-factory & npm publish",
"lib:bp": "ng build ng-modal-factory --prod & cd dist\\ng-modal-factory & npm publish"
"lib:publish": "cd dist\\ng-modal-factory && npm publish",
"lib:bp": "ng build ng-modal-factory --prod && cd dist/ng-modal-factory && npm publish"
},
"private": true,
"dependencies": {
Expand All @@ -28,6 +30,11 @@
"@angular/platform-browser": "~11.2.0",
"@angular/platform-browser-dynamic": "~11.2.0",
"@angular/router": "~11.2.0",
"@cds/core": "^5.0.1",
"@clr/angular": "^5.0.1",
"@clr/icons": "^5.0.1",
"@clr/ui": "^5.0.1",
"@webcomponents/webcomponentsjs": "^2.5.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.11.3"
Expand Down
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>
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;
}

}
3 changes: 3 additions & 0 deletions projects/ng-modal-factory-example/src/app/app.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
button {
margin: 1rem;
}
4 changes: 2 additions & 2 deletions projects/ng-modal-factory-example/src/app/app.component.html
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>
8 changes: 6 additions & 2 deletions projects/ng-modal-factory-example/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, ViewChild } from '@angular/core';
import { ModalFactoryService } from 'dist/ng-modal-factory';
import { AlertModalData, ModalFactoryService } from 'dist/ng-modal-factory';
import { BaseModalData } from 'projects/ng-modal-factory/src/public-api';
import { AlertModalComponent } from './alert-modal/alert-modal.component';

@Component({
Expand All @@ -15,9 +16,10 @@ export class AppComponent {

public openModal()
{
this.modalFactoryService.openNewAlertModal({
this.modalFactoryService.openNewModal<AlertModalData>({
component: AlertModalComponent,
inputs: {
headline: "My modal headline...",
bodyTemplate: this.modalBody,
buttons: [
{
Expand All @@ -38,5 +40,7 @@ export class AppComponent {
],
},
});

/* this.modalFactoryService.openNewModal<BaseModalData>({component: AlertModalComponent}) */
}
}
Loading

0 comments on commit 83d3371

Please sign in to comment.