Merge pull request #69 from AlineRinquin/component-alert

Component alert
This commit is contained in:
AlineRinquin 2022-03-01 21:52:53 +01:00 committed by GitHub
commit 8826efdd3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 66 additions and 5 deletions

View File

@ -43,6 +43,7 @@ import localeFr from '@angular/common/locales/fr';
import { CardAvatarComponent } from './components/card-avatar/card-avatar.component'; import { CardAvatarComponent } from './components/card-avatar/card-avatar.component';
import { HumeurComponent } from './components/humeur/humeur.component'; import { HumeurComponent } from './components/humeur/humeur.component';
import { DeconnexionComponent } from './components/deconnexion/deconnexion.component'; import { DeconnexionComponent } from './components/deconnexion/deconnexion.component';
import { AlertComponent } from './components/alert/alert.component';
registerLocaleData(localeFr) registerLocaleData(localeFr)
@NgModule({ @NgModule({
@ -82,7 +83,8 @@ registerLocaleData(localeFr)
PageUpdateAccountComponent, PageUpdateAccountComponent,
CardAvatarComponent, CardAvatarComponent,
DeconnexionComponent, DeconnexionComponent,
HumeurComponent HumeurComponent,
AlertComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,

View File

@ -0,0 +1,4 @@
<div class="alert alert-{{alert.type}} alert-dismissible fade show" role="alert" style="position:absolute;z-index:9999;top:10px;right:50%;transform: translateX(50%);width:600px; text-align:center;">
{{alert.content}}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close" (click)="onClickCloseAlert()"></button>
</div>

View File

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AlertComponent } from './alert.component';
describe('AlertComponent', () => {
let component: AlertComponent;
let fixture: ComponentFixture<AlertComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AlertComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(AlertComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,20 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
@Component({
selector: 'app-alert',
templateUrl: './alert.component.html',
styleUrls: ['./alert.component.scss']
})
export class AlertComponent implements OnInit {
@Input() alert:any;
@Output() eventClose = new EventEmitter<string>();
constructor() { }
ngOnInit(): void {
}
onClickCloseAlert(){
//console.log('fermeture from component');
this.eventClose.emit('true');
}
}

View File

@ -27,10 +27,13 @@
<!-- <div *ngIf="errorForm"> <!-- <div *ngIf="errorForm">
<p class="text-danger">Il manque des informations dans le formulaire...</p> <p class="text-danger">Il manque des informations dans le formulaire...</p>
</div> --> </div> -->
<div *ngIf="isShow">
<app-alert *ngIf="isShow" [alert]="alert" (eventClose)="onClickCloseAlert();"></app-alert>
<!-- <div *ngIf="isShow">
<div class="alert alert-{{alert.type}}" role="alert"> <div class="alert alert-{{alert.type}}" role="alert">
{{alert.content}} {{alert.content}}
</div> </div>
</div> </div> -->
</main> </main>
</div> </div>

View File

@ -44,4 +44,9 @@ export class SigninComponent implements OnInit {
this.isShow = true; this.isShow = true;
} }
} }
onClickCloseAlert(){
console.log('fermeture');
this.isShow = ! this.isShow;
}
} }

View File

@ -1,7 +1,9 @@
<app-header></app-header> <app-header></app-header>
<app-side-bar></app-side-bar> <app-side-bar></app-side-bar>
<div <app-alert *ngIf="isShow" [alert]="alert" (eventClose)="onClickCloseAlert();"></app-alert>
<!-- <div
class="alert alert-{{ alert.type }}" class="alert alert-{{ alert.type }}"
role="alert" role="alert"
style="position: absolute; z-index: 999; top: 50%; left: 40%; width: 500px" style="position: absolute; z-index: 999; top: 50%; left: 40%; width: 500px"
@ -18,7 +20,7 @@
> >
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div> -->
<div style="display: flex"> <div style="display: flex">
<div style="width: 150px"> <div style="width: 150px">