File

projects/wvr-elements/src/lib/wvr-alert/wvr-alert.component.ts

Description

A message display with contextualized styling.

Extends

WvrBaseComponent

Implements

OnInit

Metadata

Index

Properties
Methods
Inputs
Outputs
HostBindings

Constructor

constructor(injector: Injector)
Parameters :
Name Type Optional
injector Injector No

Inputs

alertType
Type : "basic" | "self-closing" | "custom"
Default value : 'basic'

Used to define the type of alert.

closeable
Type : "true" | "false"
Default value : 'true'

Used to display the Close button.

closeTimer
Type : number
Default value : 5000

Setting the delay timer for the self closing alert message

animate
Type : string
Inherited from WvrBaseComponent

A setter which parses a json string describing animation instructions and stores the derived object in _animationSettings.

animateConfig
Type : string
Inherited from WvrBaseComponent

A setter which parses a json string describing animation setting and stores the derived object in _animationConfig.

animateId
Type : string
Inherited from WvrBaseComponent

An attribute input allowing for the designation of an animation identifier for the purpose of animation targeting.

animateTarget
Type : string
Inherited from WvrBaseComponent

An attribute input allowing for the designation of an animation target for animation events.

hiddenInMobile
Type : boolean
Default value : false
Inherited from WvrBaseComponent

An attribute input specifying if this component should be hidden in the mobile layout.

ngBindings
Type : string
Inherited from WvrBaseComponent
themeVariant
Type : ThemeVariantName
Inherited from WvrBaseComponent

Used to define the class type of an alert component.

wvrData
Type : string
Inherited from WvrBaseComponent
wvrTheme
Type : string
Inherited from WvrBaseComponent

Allows for the override of theme for the particular component.

Outputs

animationEventTrigger
Type : EventEmitter
Inherited from WvrBaseComponent

An Output biding used for triggering animations.

HostBindings

class.wvr-bootstrap
Type : boolean
Default value : true
Inherited from WvrBaseComponent

A host binding used to ensure the presense of the wvr-bootstrap class.

class.wvr-hidden
Type : boolean
Inherited from WvrBaseComponent

A host bound accessor which applies the wvr-hidden class if both isMobileLayout and hiddenInMobile evaluate to true.

style
Type : any
Inherited from WvrBaseComponent

Methods

clickClose
clickClose($event: MouseEvent)

An event handle method for the document:click event. Closes the alert box once the X is clicked.

Parameters :
Name Type Optional
$event MouseEvent No
Returns : void
ngOnInit
ngOnInit()
Inherited from WvrBaseComponent

Initializes the closing timer for a self closing alert.

Returns : void
applyThemeOverride
applyThemeOverride(customProperty: string, value: string)
Inherited from WvrBaseComponent
Parameters :
Name Type Optional
customProperty string No
value string No
Returns : void
bootstrapNgBindings
bootstrapNgBindings()
Inherited from WvrBaseComponent
Returns : void
getWvrData
getWvrData()
Inherited from WvrBaseComponent
Returns : string
hasWvrData
hasWvrData()
Inherited from WvrBaseComponent
Returns : boolean
initializeAnimationElement
initializeAnimationElement()
Inherited from WvrBaseComponent
Returns : void
initializeAnimationRegistration
initializeAnimationRegistration()
Inherited from WvrBaseComponent
Returns : void
ngAfterContentInit
ngAfterContentInit()
Inherited from WvrBaseComponent

Used for post content initialization animation setup.

Returns : void
ngOnDestroy
ngOnDestroy()
Inherited from WvrBaseComponent

Handles the the unregistering of this component with the component registry.

Returns : void
onAnimationEvent
onAnimationEvent($event: Event)
Inherited from WvrBaseComponent

Trigger's the animation specified by the incoming event.

Parameters :
Name Type Optional
$event Event No
Returns : void
Private processData
processData()
Inherited from WvrBaseComponent
Returns : void
triggerAnimations
triggerAnimations(animationTriggerType: string)
Inherited from WvrBaseComponent

Plays the animation specified by the incoming animation trigger.

Parameters :
Name Type Optional
animationTriggerType string No
Returns : void

Properties

alertClosed
Default value : false

Used to self close the alert box.

variantTypes
Type : []
Default value : ['alert']
Inherited from WvrBaseComponent
Private _animationConfig
Type : any
Default value : {}
Inherited from WvrBaseComponent

An object representation of the settings specifying the specific behavior of the animation for this component.

Private Readonly _animationService
Type : AnimationService<WvrBaseComponent>
Inherited from WvrBaseComponent

A reference to the AnimationService

Private _animationSettings
Type : any
Default value : {}
Inherited from WvrBaseComponent

An object representation of the animation instructions for this component.

Private _ngBindings
Type : literal type
Inherited from WvrBaseComponent
animationRootElem
Type : ElementRef
Decorators :
@ViewChild('animationRoot')
Inherited from WvrBaseComponent

A view child of the template element containing the #animationRoot identifier.

Private animationStateId
Type : number
Inherited from WvrBaseComponent

An identifier used to access the animation state for this component.

Readonly appConfig
Type : AppConfig
Inherited from WvrBaseComponent

A reference to the AppConfig

Readonly cdRef
Type : ChangeDetectorRef
Inherited from WvrBaseComponent

A reference to the ChangeDetectorRef

Readonly componentRegistry
Type : ComponentRegistryService<WvrBaseComponent>
Inherited from WvrBaseComponent

A reference to the ComponentRegistryService

data
Type : literal type
Default value : {}
Inherited from WvrBaseComponent
Readonly eRef
Type : ElementRef
Inherited from WvrBaseComponent

A reference to the ElementRef

Readonly id
Type : number
Inherited from WvrBaseComponent

A generated unique identifier for this comonent.

isMobile
Type : Observable<boolean>
Inherited from WvrBaseComponent
isMobileLayout
Type : boolean
Inherited from WvrBaseComponent
Private Readonly kebabize
Default value : () => {...}
Inherited from WvrBaseComponent
Private Readonly ngBindingsService
Type : NgBindingsService
Inherited from WvrBaseComponent

A reference to the NgBindingsService

Readonly store
Type : Store<RootState>
Inherited from WvrBaseComponent

A reference to the Store

style
Decorators :
@HostBinding('style')
Inherited from WvrBaseComponent
Protected subscriptions
Type : Array<Subscription>
Inherited from WvrBaseComponent
themeOverrides
Type : object
Default value : {}
Inherited from WvrBaseComponent
Private Readonly themeService
Type : ThemeService
Inherited from WvrBaseComponent

A reference to the ThemeService

wvrBootstrap
Default value : true
Decorators :
@HostBinding('class.wvr-bootstrap')
Inherited from WvrBaseComponent

A host binding used to ensure the presense of the wvr-bootstrap class.

import { ChangeDetectionStrategy, Component, Injector, Input, OnInit } from '@angular/core';
import { WvrBaseComponent } from '../shared/wvr-base.component';

/**
 * A message display with contextualized styling.
 */
@Component({
  selector: 'wvr-alert-component',
  templateUrl: './wvr-alert.component.html',
  styleUrls: ['./wvr-alert.component.scss'],
  changeDetection: ChangeDetectionStrategy.Default
})
export class WvrAlertComponent extends WvrBaseComponent implements OnInit {

  /** Used to define the type of alert. */
  @Input() alertType: 'basic' | 'self-closing' | 'custom' = 'basic';

  /** Used to self close the alert box. */
  alertClosed = false;

  /** Used to display the Close button. */
  @Input() closeable: 'true' | 'false' = 'true';

  /** Setting the delay timer for the self closing alert message */
  @Input() closeTimer = 5000;

  variantTypes = ['alert'];

  constructor(injector: Injector) {
    super(injector);
  }

  /**
   * An event handle method for the `document:click` event.
   * Closes the alert box once the `X` is clicked.
   */
  clickClose($event: MouseEvent): void {
      this.alertClosed = true;
      this.themeVariant = 'primary';
  }

  /** Initializes the closing timer for a self closing alert. */
  ngOnInit(): void {
    super.ngOnInit();
    if (this.alertType === 'self-closing') {
      setTimeout(() => {
        this.alertClosed = true;
      }, this.closeTimer);
    }
  }

}
<div *ngIf="!alertClosed" class="wvr-components wvr-alert alert alert-{{themeVariant}}" role="alert">

  <div *ngIf="alertType==='basic'" class="basic flex-fill align-self-stretch">
    <ng-container *ngTemplateOutlet="closeButton"></ng-container>
    <ng-container *ngTemplateOutlet="basic"></ng-container>
  </div>

  <div *ngIf="alertType==='self-closing'" class="self-closing flex-fill align-self-stretch">
    <ng-container *ngTemplateOutlet="selfClosing"></ng-container>
  </div>

  <div *ngIf="alertType==='custom'" class="custom flex-fill align-self-stretch">
    <ng-container *ngTemplateOutlet="closeButton"></ng-container>
    <ng-container *ngTemplateOutlet="custom"></ng-container>
  </div>

</div>

<ng-template #basic>
  <div [wvrContentProjection]="eRef" template="alert-content"></div>
</ng-template>

<ng-template #selfClosing>
  <div class="alert-dismissible" (close)="alertClosed = true">
    <ng-container *ngTemplateOutlet="basic"></ng-container>
  </div>
</ng-template>

<ng-template #custom>
  <div [wvrContentProjection]="eRef" template="custom-alert-content"></div>
</ng-template>

<ng-template #closeButton>
  <button type="button" class="close" data-dismiss="alert" aria-label="Close" (click)="clickClose($event)" *ngIf="closeable === 'true'">
    <wvr-text-component aria-hidden="true" value="&times;"></wvr-text-component>
  </button>
</ng-template>

<ng-content select="template"></ng-content>

./wvr-alert.component.scss

@import "../shared/styles/variables";

:host {
  @extend .variables;

  font-family: var(--wvr-font-family-sans-serif);
  
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""