-
-
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.
feat(buttons): adds reusable buttons
- Loading branch information
1 parent
3e486e7
commit b3276f0
Showing
11 changed files
with
365 additions
and
1 deletion.
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
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
51 changes: 51 additions & 0 deletions
51
libs/ngxsmart/src/lib/buttons/delete-button/delete-button.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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Component, Input, NgModule, OnInit } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
|
||
@Component({ | ||
selector: 'app-delete-button', | ||
template: ` | ||
<button class="btn btn-danger {{ loading ? 'disabled' : '' }}" mat-raised-button type="{{ type }}"> | ||
<span *ngIf="loading" aria-hidden="true" class="spinner-border spinner-border-sm" role="status"></span> | ||
<mat-icon *ngIf="!loading">delete</mat-icon> | ||
{{ loading ? deleteMessage : nonDeleteMessage }} | ||
</button> | ||
`, | ||
}) | ||
export class DeleteButtonComponent implements OnInit { | ||
/** | ||
* Is search in progress and loading the data | ||
*/ | ||
@Input() loading: boolean | undefined = false; | ||
|
||
/** | ||
* Type of the button. Following values are supported. See BootStrap docs for more information | ||
* <pre> | ||
* 1. button | ||
* 2. submit | ||
* </pre> | ||
*/ | ||
@Input() type = 'button'; | ||
|
||
/** | ||
* If set, shows when Delete in Progress | ||
*/ | ||
@Input() deleteMessage = 'Deleting...'; | ||
|
||
/** | ||
* If set, shows when Delete is not in progress | ||
*/ | ||
@Input() nonDeleteMessage = 'Delete'; | ||
|
||
constructor() {} | ||
|
||
ngOnInit(): void {} | ||
} | ||
|
||
@NgModule({ | ||
declarations: [DeleteButtonComponent], | ||
imports: [CommonModule, MatIconModule, MatButtonModule], | ||
exports: [DeleteButtonComponent], | ||
}) | ||
export class DeleteButtonComponentModule {} |
43 changes: 43 additions & 0 deletions
43
libs/ngxsmart/src/lib/buttons/edit-button/edit-button.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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import {Component, Input, NgModule} from '@angular/core'; | ||
import {CommonModule} from '@angular/common'; | ||
import {MatIconModule} from '@angular/material/icon'; | ||
import {MatButtonModule} from '@angular/material/button'; | ||
|
||
@Component({ | ||
selector: 'mib-air-edit-button', | ||
template: ` | ||
<button class="primary-button" mat-raised-button type="{{ type }}"> | ||
<mat-icon>{{ icon }}</mat-icon> | ||
{{ message }} | ||
</button> | ||
`, | ||
styles: [], | ||
}) | ||
export class EditButtonComponent { | ||
/** | ||
* Type of the button. Following values are supported. See BootStrap docs for mor | ||
* e information | ||
* <pre> | ||
* 1. button | ||
* 2. submit | ||
* </pre> | ||
*/ | ||
@Input() type = 'button'; | ||
|
||
/** | ||
* If set, shows material icon | ||
*/ | ||
@Input() icon = 'edit'; | ||
|
||
/** | ||
* If set, shows when search in progress | ||
*/ | ||
@Input() message = 'Edit'; | ||
} | ||
|
||
@NgModule({ | ||
imports: [CommonModule, MatIconModule, MatButtonModule], | ||
declarations: [EditButtonComponent], | ||
exports: [EditButtonComponent], | ||
}) | ||
export class EditButtonComponentModule {} |
51 changes: 51 additions & 0 deletions
51
libs/ngxsmart/src/lib/buttons/save-primary-button/save-primary-button.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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Component, OnInit, NgModule, Input } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
|
||
@Component({ | ||
selector: 'mib-air-save-primary-button', | ||
template: ` <button class="btn btn-primary {{ loading ? 'disabled' : '' }}" mat-raised-button type="{{ type }}"> | ||
<span *ngIf="loading" aria-hidden="true" class="spinner-border spinner-border-sm" role="status"></span> | ||
<mat-icon *ngIf="!loading">{{ icon }}</mat-icon> | ||
{{ loading ? loadingMessage : message }} | ||
</button>`, | ||
styles: [], | ||
}) | ||
export class SavePrimaryButtonComponent { | ||
/** | ||
* Is search in progress and loading the data | ||
*/ | ||
@Input() loading: boolean | undefined = false; | ||
|
||
/** | ||
* Type of the button. Following values are supported. See BootStrap docs for more information | ||
* <pre> | ||
* 1. button | ||
* 2. submit | ||
* </pre> | ||
*/ | ||
@Input() type = 'button'; | ||
|
||
/** | ||
* If set, shows when search in progress | ||
*/ | ||
@Input() loadingMessage = 'Saving...'; | ||
|
||
/** | ||
* If set, shows when search is not in progress | ||
*/ | ||
@Input() message = 'Save'; | ||
|
||
/** | ||
* If set, shows material icon | ||
*/ | ||
@Input() icon = 'save'; | ||
} | ||
|
||
@NgModule({ | ||
imports: [CommonModule, MatIconModule, MatButtonModule], | ||
declarations: [SavePrimaryButtonComponent], | ||
exports: [SavePrimaryButtonComponent], | ||
}) | ||
export class SavePrimaryButtonComponentModule {} |
51 changes: 51 additions & 0 deletions
51
libs/ngxsmart/src/lib/buttons/search-button/search-button.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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Component, Input, NgModule, OnInit } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
|
||
@Component({ | ||
selector: 'app-search-button', | ||
template: ` | ||
<button class="btn btn-primary {{ loading ? 'disabled' : '' }}" mat-raised-button type="{{ type }}"> | ||
<span *ngIf="loading" aria-hidden="true" class="spinner-border spinner-border-sm" role="status"></span> | ||
<mat-icon *ngIf="!loading">search</mat-icon> | ||
{{ loading ? searchMessage : nonSearchMessage }} | ||
</button> | ||
`, | ||
}) | ||
export class SearchButtonComponent implements OnInit { | ||
/** | ||
* Is search in progress and loading the data | ||
*/ | ||
@Input() loading: boolean | undefined = false; | ||
|
||
/** | ||
* Type of the button. Following values are supported. See BootStrap docs for more information | ||
* <pre> | ||
* 1. button | ||
* 2. submit | ||
* </pre> | ||
*/ | ||
@Input() type = 'button'; | ||
|
||
/** | ||
* If set, shows when search in progress | ||
*/ | ||
@Input() searchMessage = 'Searching...'; | ||
|
||
/** | ||
* If set, shows when search is not in progress | ||
*/ | ||
@Input() nonSearchMessage = 'Search'; | ||
|
||
constructor() {} | ||
|
||
ngOnInit(): void {} | ||
} | ||
|
||
@NgModule({ | ||
declarations: [SearchButtonComponent], | ||
imports: [CommonModule, MatIconModule, MatButtonModule], | ||
exports: [SearchButtonComponent], | ||
}) | ||
export class SearchButtonComponentModule {} |
56 changes: 56 additions & 0 deletions
56
libs/ngxsmart/src/lib/buttons/success-button/success-button.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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Component, Input, NgModule, OnInit } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
|
||
@Component({ | ||
selector: 'app-success-button', | ||
template: ` | ||
<button class="btn btn-success {{ loading || disabled ? 'disabled' : '' }}" mat-raised-button type="{{ type }}"> | ||
<span *ngIf="loading" aria-hidden="true" class="spinner-border spinner-border-sm" role="status"></span> | ||
<mat-icon *ngIf="!loading">save</mat-icon> | ||
{{ loading ? loadingMessage : message }} | ||
</button> | ||
`, | ||
}) | ||
export class SuccessButtonComponent implements OnInit { | ||
/** | ||
* Is search in progress and loading the data | ||
*/ | ||
@Input() loading: boolean | undefined = false; | ||
|
||
/** | ||
* Is button disabled, default is false | ||
*/ | ||
@Input() disabled = false; | ||
|
||
/** | ||
* Type of the button. Following values are supported. See BootStrap docs for more information | ||
* <pre> | ||
* 1. button | ||
* 2. submit | ||
* </pre> | ||
*/ | ||
@Input() type = 'button'; | ||
|
||
/** | ||
* If set, shows when search in progress | ||
*/ | ||
@Input() loadingMessage = 'Updating...'; | ||
|
||
/** | ||
* If set, shows when search is not in progress | ||
*/ | ||
@Input() message = 'Update'; | ||
|
||
constructor() {} | ||
|
||
ngOnInit(): void {} | ||
} | ||
|
||
@NgModule({ | ||
declarations: [SuccessButtonComponent], | ||
imports: [CommonModule, MatIconModule, MatButtonModule], | ||
exports: [SuccessButtonComponent], | ||
}) | ||
export class SuccessButtonComponentModule {} |
42 changes: 42 additions & 0 deletions
42
libs/ngxsmart/src/lib/buttons/view-button/view-button.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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {Component, Input, NgModule} from '@angular/core'; | ||
import {CommonModule} from '@angular/common'; | ||
import {MatIconModule} from '@angular/material/icon'; | ||
import {MatButtonModule} from '@angular/material/button'; | ||
|
||
@Component({ | ||
selector: 'mib-air-view-button', | ||
template: ` | ||
<button class="primary-button" mat-raised-button type="{{ type }}"> | ||
<mat-icon>{{ icon }}</mat-icon> | ||
{{ message }} | ||
</button> | ||
`, | ||
styles: [], | ||
}) | ||
export class ViewButtonComponent { | ||
/** | ||
* Type of the button. Following values are supported. See BootStrap docs for more information | ||
* <pre> | ||
* 1. button | ||
* 2. submit | ||
* </pre> | ||
*/ | ||
@Input() type = 'button'; | ||
|
||
/** | ||
* If set, shows material icon | ||
*/ | ||
@Input() icon = 'visibility'; | ||
|
||
/** | ||
* If set, shows when search is not in progress | ||
*/ | ||
@Input() message = 'View'; | ||
} | ||
|
||
@NgModule({ | ||
imports: [CommonModule, MatIconModule, MatButtonModule], | ||
declarations: [ViewButtonComponent], | ||
exports: [ViewButtonComponent], | ||
}) | ||
export class ViewButtonComponentModule {} |
13 changes: 13 additions & 0 deletions
13
libs/ngxsmart/src/lib/confirm-dialog/confirm-dialog.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div class="mat-dialog-title" style="text-align: center"> | ||
<h4>{{ title }}</h4> | ||
</div> | ||
|
||
<mat-divider></mat-divider> | ||
<div mat-dialog-content style="margin: 20px"> | ||
<p>{{ message }}</p> | ||
</div> | ||
|
||
<div align="end" class="modal-footer" mat-dialog-actions> | ||
<button (click)="onDismiss()" mat-raised-button>No</button> | ||
<button (click)="onConfirm()" color="primary" mat-raised-button>Yes</button> | ||
</div> |
Empty file.
50 changes: 50 additions & 0 deletions
50
libs/ngxsmart/src/lib/confirm-dialog/confirm-dialog.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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Component, Inject, NgModule, OnInit } from '@angular/core'; | ||
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatDividerModule } from '@angular/material/divider'; | ||
|
||
@Component({ | ||
selector: 'app-confirm-dialog', | ||
templateUrl: './confirm-dialog.component.html', | ||
styleUrls: ['./confirm-dialog.component.scss'], | ||
}) | ||
export class ConfirmDialogComponent implements OnInit { | ||
title: string; | ||
message: string; | ||
|
||
constructor( | ||
@Inject(MAT_DIALOG_DATA) public data: ConfirmDialogData, | ||
public dialogRef: MatDialogRef<ConfirmDialogComponent> | ||
) { | ||
// Update view with given values | ||
this.title = data.title; | ||
this.message = data.message; | ||
} | ||
|
||
ngOnInit(): void {} | ||
|
||
onDismiss() { | ||
// Close the dialog, return true | ||
this.dialogRef.close(false); | ||
} | ||
|
||
onConfirm() { | ||
// Close the dialog, return true | ||
this.dialogRef.close(true); | ||
} | ||
} | ||
|
||
/** | ||
* Class to represent confirm dialog model. | ||
*/ | ||
export interface ConfirmDialogData { | ||
title: string; | ||
message: string; | ||
} | ||
|
||
@NgModule({ | ||
declarations: [ConfirmDialogComponent], | ||
imports: [MatButtonModule, MatDividerModule, MatDialogModule], | ||
exports: [ConfirmDialogComponent], | ||
}) | ||
export class ConfirmDialogComponentModule {} |