src/modal/overlay.component.ts
Component for the overlay object that acts as a backdrop to the Modal
component.
The main purpose for this component is to be able to handle click events that fall outside
the bounds of the Modal
component.
selector | ibm-overlay |
template |
|
Properties |
Methods |
Inputs |
Outputs |
theme
|
Classification of the modal.
Type :
Default value : |
Defined in src/modal/overlay.component.ts:33
|
overlaySelect
|
To emit the event where the user selects the overlay behind the $event Type: EventEmitter
|
Defined in src/modal/overlay.component.ts:37
|
overlayClick | ||||
overlayClick(event)
|
||||
Defined in src/modal/overlay.component.ts:46
|
||||
Handles the user clicking on the
Parameters :
Returns :
void
|
overlay |
overlay:
|
Type : ElementRef
|
Decorators :
@ViewChild('overlay')
|
Defined in src/modal/overlay.component.ts:41
|
Maintains a reference to the view DOM element of the |
import {
Component,
Output,
EventEmitter,
ViewChild,
ElementRef,
Input
} from "@angular/core";
/**
* Component for the overlay object that acts as a backdrop to the `Modal` component.
*
* The main purpose for this component is to be able to handle click events that fall outside
* the bounds of the `Modal` component.
*/
@Component({
selector: "ibm-overlay",
template: `
<section
class="bx--modal bx--modal-tall is-visible"
[ngClass]="{'bx--modal--danger': theme === 'danger'}"
(click)="overlayClick($event)"
#overlay>
<ng-content></ng-content>
</section>
`
})
export class Overlay {
/**
* Classification of the modal.
*/
@Input() theme: "default" | "danger" = "default";
/**
* To emit the event where the user selects the overlay behind the `Modal`.
*/
@Output() overlaySelect = new EventEmitter();
/**
* Maintains a reference to the view DOM element of the `Overlay`.
*/
@ViewChild("overlay") overlay: ElementRef;
/**
* Handles the user clicking on the `Overlay` which resides outside the `Modal` object.
*/
overlayClick(event) {
if (event.target !== this.overlay.nativeElement) { return; }
event.stopPropagation();
this.overlaySelect.emit(event);
}
}