Skip to content

Commit

Permalink
Merge pull request #93 from js-smart/development
Browse files Browse the repository at this point in the history
feat(progress-state): adds utility function to show loader
  • Loading branch information
pavankjadda authored Jan 9, 2024
2 parents a108cae + ede0b3b commit 5aae791
Show file tree
Hide file tree
Showing 53 changed files with 558 additions and 412 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"private": true,
"dependencies": {
"@angular/animations": "^17.0.0",
"@angular/common": "^17.0.0",
"@angular/cdk": "17.0.0",
"@angular/material": "17.0.0",
"@angular/common": "^17.0.0",
"@angular/compiler": "^17.0.0",
"@angular/core": "^17.0.0",
"@angular/forms": "^17.0.0",
"@angular/material": "17.0.0",
"@angular/platform-browser": "^17.0.0",
"@angular/platform-browser-dynamic": "^17.0.0",
"@angular/router": "^17.0.0",
Expand Down Expand Up @@ -51,7 +51,7 @@
"jest": "latest",
"jest-environment-jsdom": "latest",
"ng-packagr": "^17.0.0",
"prettier": "latest",
"prettier": "^3.1.0",
"typescript": "~5.2.2"
}
}
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

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

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div>
<h2>Success Alert</h2>
<alert [dismissOnTimeout]="dismissOnTimeout" [dismissible]="dismissible" type="success"> Success Alert </alert>
<alert [dismissOnTimeout]="dismissOnTimeout" [dismissible]="dismissible" type="success"> Success Alert </alert>
</div>

<div>
Expand Down
2 changes: 2 additions & 0 deletions projects/ngxsmart-demo/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ <h1 style="display: flex; justify-content: center; align-items: center; margin-t
<ul>
<li><a routerLink="/autocomplete-demo">Auto Complete Demo</a></li>
<li><a routerLink="/alert-demo">Alert Demo</a></li>
<li><a routerLink="/confirm-dialog-demo">Confirm Dialog Demo</a></li>
<li><a routerLink="/edit-svg-icon-demo">Edit Svg Icon Demo</a></li>
<li><a routerLink="/buttons-demo">Buttons Demo</a></li>
<li><a routerLink="/directives-demo">Directives Demo</a></li>
<li><a routerLink="/snack-bar-demo">Snack Bar Demo</a></li>
<li><a routerLink="/progress-state-demo">Progress State Demo</a></li>
</ul>
<hr />
<router-outlet></router-outlet>
2 changes: 1 addition & 1 deletion projects/ngxsmart-demo/src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const appConfig: ApplicationConfig = {
MatSelectModule,
MatAutocompleteModule,
MatNativeDateModule,
MatDatepickerModule
MatDatepickerModule,
),
Title,
DatePipe,
Expand Down
4 changes: 4 additions & 0 deletions projects/ngxsmart-demo/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import { ButtonsDemoComponent } from './buttons-demo/buttons-demo.component';
import { DirectivesDemoComponent } from './directives-demo/directives-demo.component';
import { EditSvgIconDemoComponent } from './edit-svg-icon-demo/edit-svg-icon-demo.component';
import { SnackBarDemoComponent } from './snack-bar-demo/snack-bar-demo.component';
import { ConfirmDialogDemoComponent } from './confirm-dialog-demo/confirm-dialog-demo.component.html-demo.component';
import { ProgressStateDemoComponent } from './progress-state-demo/progress-state-demo.component';

export const routes: Route[] = [
{ path: 'autocomplete-demo', component: AutocompleteDemoComponent },
{ path: 'alert-demo', component: AlertDemoComponent },
{ path: 'confirm-dialog-demo', component: ConfirmDialogDemoComponent },
{ path: 'edit-svg-icon-demo', component: EditSvgIconDemoComponent },
{ path: 'buttons-demo', component: ButtonsDemoComponent },
{ path: 'directives-demo', component: DirectivesDemoComponent },
{ path: 'snack-bar-demo', component: SnackBarDemoComponent },
{ path: 'progress-state-demo', component: ProgressStateDemoComponent },
];
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
<h1 style="display: flex; justify-content: center; align-items: center;margin-top: 50px">
Generic Auto Complete (Works with Objects and Strings)
<h1 style="display: flex; justify-content: center; align-items: center; margin-top: 50px">
Generic Auto Complete (Works with Objects and Strings)
</h1>
<div style="display: flex; justify-content: center; align-items: center; ">
<form [formGroup]="genericFormGroup">
<autocomplete
[data]="cities"
[inputFormGroup]="genericFormGroup"
[required]="true"
bindLabel="location"
bindValue="id"
label="City"
placeHolder="Select City">
</autocomplete>
</form>
<div style="display: flex; justify-content: center; align-items: center">
<form [formGroup]="genericFormGroup">
<autocomplete
[data]="cities"
[inputFormGroup]="genericFormGroup"
[required]="true"
bindLabel="location"
bindValue="id"
label="City"
placeHolder="Select City">
</autocomplete>
</form>
</div>
<div style="display: flex; justify-content: center; align-items: center; margin-top: 20px">
<p>Selected Option Is:</p>
<h2>{{ genericFormGroup.get('autocomplete')?.value?.location ?? '' }}</h2>
<p>Selected Option Is:</p>
<h2>{{ genericFormGroup.get('autocomplete')?.value?.location ?? '' }}</h2>
</div>
<hr />

<hr />

<h2 style="display: flex; justify-content: center; align-items: center;margin-top: 50px">Auto Complete (Works with
Strings)</h2>
<div style="display: flex; justify-content: center; align-items: center; ">
<form [formGroup]="stringInputFormGroup">
<autocomplete [data]="names" [inputFormGroup]="stringInputFormGroup" [required]="true" label="City"
placeHolder="Select City">
</autocomplete>
</form>
<h2 style="display: flex; justify-content: center; align-items: center; margin-top: 50px">Auto Complete (Works with Strings)</h2>
<div style="display: flex; justify-content: center; align-items: center">
<form [formGroup]="stringInputFormGroup">
<autocomplete [data]="names" [inputFormGroup]="stringInputFormGroup" [required]="true" label="City" placeHolder="Select City">
</autocomplete>
</form>
</div>
<div style="display: flex; justify-content: center; align-items: center; margin-top: 20px">
<p>Selected Option Is:</p>
<h2>{{ stringInputFormGroup.get('autocomplete')?.value ?? '' }}</h2>
<p>Selected Option Is:</p>
<h2>{{ stringInputFormGroup.get('autocomplete')?.value ?? '' }}</h2>
</div>
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { Component } from '@angular/core';
import {
BsLinkButtonComponent,
DeleteButtonComponent,
EditBsButtonComponent,
EditButtonComponent,
EditSvgIconButtonComponent,
ExcelExportButtonComponent,
ManageButtonComponent,
PdfExportButtonComponent,
PrimaryButtonComponent,
SavePrimaryButtonComponent,
SearchButtonComponent,
SuccessButtonComponent,
ViewButtonComponent,
ViewPrimaryButtonComponent,
BsLinkButtonComponent,
DeleteButtonComponent,
EditBsButtonComponent,
EditButtonComponent,
EditSvgIconButtonComponent,
ExcelExportButtonComponent,
ManageButtonComponent,
PdfExportButtonComponent,
PrimaryButtonComponent,
SavePrimaryButtonComponent,
SearchButtonComponent,
SuccessButtonComponent,
ViewButtonComponent,
ViewPrimaryButtonComponent,
} from '@js-smart/ngxsmart';
import { CommonModule } from '@angular/common';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="m-5">
<primary-button label="Click to Confirm" (click)="confirm()"></primary-button>

<br />
<br />
<section>
<h3 class="mat-h3">
<b class="m-2">Confirm Status:</b>{{confirmStatus()}}
</h3>
</section>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Component, inject, signal } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ConfirmDialogComponent, PrimaryButtonComponent } from '@js-smart/ngxsmart';

@Component({
selector: 'ngxsmart-confirm-dialog-demo',
standalone: true,
templateUrl: './confirm-dialog-demo.component.html',
styles: [``],
imports: [ConfirmDialogComponent, PrimaryButtonComponent],
})
export class ConfirmDialogDemoComponent {
dialog = inject(MatDialog);
confirmStatus = signal('');
confirm() {
const ref = this.dialog.open(ConfirmDialogComponent, {
data: {
title: 'Confirm',
message: 'Are you sure you want to do this?',
},
});

// Listen for confirmation result
ref.afterClosed().subscribe((status: boolean) => {
if (status) {
this.confirmStatus.set('Confirmed');
} else {
this.confirmStatus.set('Canceled');
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div class="custom-flex-justify-center">
<save-primary-button (click)="setLoading()" [loading]="updateState().isLoading" class="m-3" label="Save Data"></save-primary-button>
</div>
<p style="margin: 1rem">
<alert *ngIf="updateState().isSuccess && !updateState().isLoading" type="success" [dismissible]="true">
<strong>Success!</strong> Your data has been saved.
</alert>

<alert *ngIf="updateState().isError && !updateState().isLoading" type="danger" [dismissible]="true">
<strong>Failure!</strong> Your data has not been saved.
</alert>
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AlertComponent, initializeState, markLoading, markSuccess, SavePrimaryButtonComponent } from '@js-smart/ngxsmart';

@Component({
selector: 'app-progress-state-demo',
standalone: true,
imports: [CommonModule, SavePrimaryButtonComponent, AlertComponent],
templateUrl: './progress-state-demo.component.html',
})
export class ProgressStateDemoComponent {
updateState = initializeState();

setLoading() {
markLoading(this.updateState);

setTimeout(() => {
markSuccess(this.updateState, 'Successfully saved data');
}, 2000);
}
}
16 changes: 8 additions & 8 deletions projects/ngxsmart-demo/src/assets/app-buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@
.primary-button:hover,
.primary-button:active,
.primary-button:visited {
color: white !important;
background-color: var(--primary-color) !important;
color: white !important;
background-color: var(--primary-color) !important;
}

.secondary-button,
.secondary-button:hover,
.secondary-button:active,
.secondary-button:visited {
color: white !important;
background-color: var(--secondary-color) !important;
color: white !important;
background-color: var(--secondary-color) !important;
}

/* Adds CSS for Success Button class */
.success-button,
.success-button:hover,
.success-button:active,
.success-button:visited {
color: white !important;
background-color: var(--success-color) !important;
color: white !important;
background-color: var(--success-color) !important;
}

/* Adds CSS for Delete Button class */
.delete-button,
.delete-button:hover,
.delete-button:active,
.success-button:visited {
color: white !important;
background-color: var(--delete-color) !important;
color: white !important;
background-color: var(--delete-color) !important;
}
31 changes: 15 additions & 16 deletions projects/ngxsmart-demo/src/assets/app-mat-snack-bar.scss
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@

.success-snackbar {
color: white;
--mdc-snackbar-container-color: var(--success-color);
--mat-mdc-snack-bar-button-color: var(--white-color);
color: white;
--mdc-snackbar-container-color: var(--success-color);
--mat-mdc-snack-bar-button-color: var(--white-color);
}

.error-snackbar {
color: white;
--mdc-snackbar-container-color: var(--delete-color);
--mat-mdc-snack-bar-button-color: var(--white-color);
color: white;
--mdc-snackbar-container-color: var(--delete-color);
--mat-mdc-snack-bar-button-color: var(--white-color);
}

.light-success-snackbar {
color: #155724;
background-color: #d4edda;
--mdc-snackbar-container-color: #d4edda;
--mat-mdc-snack-bar-button-color: darkgreen;
color: #155724;
background-color: #d4edda;
--mdc-snackbar-container-color: #d4edda;
--mat-mdc-snack-bar-button-color: darkgreen;
}

.light-error-snackbar {
color: #721c24;
--mdc-snackbar-container-color: var(--success-color);
--mat-mdc-snack-bar-button-color: darkred;
border-color: #f5c6cb;
}
color: #721c24;
--mdc-snackbar-container-color: var(--success-color);
--mat-mdc-snack-bar-button-color: darkred;
border-color: #f5c6cb;
}
12 changes: 6 additions & 6 deletions projects/ngxsmart-demo/src/assets/app-variables.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
:root {
--primary-color: #153d77;
--secondary-color: #6c757d;
--white-color: #fff;
--success-color: #198754;
--delete-color: #dc3545;
--background-color: #f2f2f2;
--primary-color: #153d77;
--secondary-color: #6c757d;
--white-color: #fff;
--success-color: #198754;
--delete-color: #dc3545;
--background-color: #f2f2f2;
}
2 changes: 1 addition & 1 deletion projects/ngxsmart-demo/src/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
Loading

0 comments on commit 5aae791

Please sign in to comment.