1.0.2 • Published 5 years ago

ngx-toastit v1.0.2

Weekly downloads
14
License
-
Repository
-
Last release
5 years ago

ngx-toastit

An unobtrusive toast module for Angular. Demo

npm-badge

Usage

  • Install toastit
npm i -S ngx-toastit
  • Also install peer dependencies if you're missing them.
  • Add ToastitModule to your project
@NgModule({
    declarations: [AppComponent],
    imports: [ToastitModule],
    bootstrap: [AppComponent]
})
export class AppModule { }
  • Inject ToastitService when you want to add a toastit
public constructor(private toastitService: ToastitService) {}

public AddToastit(){
    this.toastitService.add(options: IToastit);
}

Methods

ToastitService.add(options: IToastit): number

Adds a toastit with the supplied options (Refer to options section for posible values). Returns added toastit id, you can use this for premature removing.


ToastitService.remove(id: number): void

Removes a toastit with the supplied id. This method will play exit animation. If a toastit is not found with this id, method will fail silently and will print a warning to console.


ToastitService.removeAll(): number

Removes all toastits from screen. This method will not play exit animations.

Options

Required

title: string = ''

Toastit title.

Optional

align: ToastitAlign = ToastitAlign.TR

The point where the toastit will appear. Default value is top right.

typeinfo
ToastitAlign.TRTop right
ToastitAlign.TCTop center
ToastitAlign.TLTop left
ToastitAlign.BRBottom right
ToastitAlign.BCBottom center
ToastitAlign.BLBottom left

enterAnimation: any = ToastitAnimation.fadeIn

Animation config for entering toastits. Animations use material design motion for its easings and timings. Check the demo page for visualization.

type
ToastitAnimation.fadeIn
ToastitAnimation.shrinkIn
ToastitAnimation.slideInLeft
ToastitAnimation.slideInRight
ToastitAnimation.slideInTop
ToastitAnimation.slideInBottom
ToastitAnimation.scaleIn

leaveAnimation: any = ToastitAnimation.fadeOut

Animation config for exiting toastits. Animations use material design motion for its easings and timings. Check the demo page for visualization.

type
ToastitAnimation.fadeOut
ToastitAnimation.shrinkOut
ToastitAnimation.slideOutLeft
ToastitAnimation.slideOutRight
ToastitAnimation.slideOutTop
ToastitAnimation.slideOutBottom
ToastitAnimation.scaleOut

parent: string | Element = 'body'

Toasit parent, could be a selector string or Element.


timeout: number = 5

Toastit will wait x seconds before exiting.


type: ToastitType = ToastitType.Info

Toastit type.

typeinfo
ToastitType.InfoUsed for info messages
ToastitType.PinPinned toastits will remain in place until you remove it manually
ToastitType.ProgressProgress toastit, used in conjunction with observables, has an animation icon
ToastitType.SuccessUsed for success messages
ToastitType.WarningUsed to show error messages

message: string = ''

Toastit message.


observable: Observable<any> = undefined

If an observable is supplied, toastit will subscribe to it and exit after the observable is finished.

Styling

Toastit uses BEM notation for its classes and ViewEncapsulation.NONE in Angular so its styles can be customized in global scope with ease.

classinfo
.toastitMain toastit class
.toastit--infoType added main class
.toastit--align-top-rightAlign added main class
.toastit__iconIcon class
.toastit__icon--infoType added icon class
.toastit__contentParent class of title and message
.toastit__titleTitle class
.toastit__title--infoType added title class
.toastit__messageMessage class
.toastit__message--infoType added message class
1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

1.0.6-alpha

5 years ago

1.0.5-alpha

5 years ago

1.0.4-alpha

5 years ago

1.0.3-alpha

5 years ago

1.0.2-alpha

5 years ago

1.0.1-alpha

5 years ago

1.0.0-alpha

5 years ago