Giter Club home page Giter Club logo

svierk / angular-bootstrap-toast-service Goto Github PK

View Code? Open in Web Editor NEW
18.0 2.0 7.0 2.71 MB

๐Ÿž Angular project for sending Bootstrap based toast notifications including Vercel deployment

Home Page: https://angular-bootstrap-toast-service.vercel.app

License: MIT License

JavaScript 6.94% TypeScript 60.66% HTML 20.04% SCSS 12.11% Shell 0.26%
angular bootstrap5 toaster toast-notifications typescript git-hooks husky vercel-deployment jasmine

angular-bootstrap-toast-service's Introduction

Hi there โœŒ๐Ÿป

  • ๐Ÿ‘จ๐Ÿผโ€๐Ÿ’ป I'm a passionate Solution Architect and Salesforce Trailblazer
  • ๐Ÿ‘€ I'm interested in everything related to JavaScript / TypeScript
  • โœ๐Ÿป I like writing technical posts on Medium
  • โ˜ Iโ€™m currently working on Salesforce based projects
  • โšก๏ธ Ask me about Lightning Web Components

StackExchange Profile

profile for Sebastiano Schwarz on Stack Exchange, a network of free, community-driven Q&A sites

Recent Medium Posts

logo How to Render 3D Elements with
Lightning Web Components
logo How to open a Record Page from Salesforce
Flow using LWC
logo Local Development for Lightning Web Components
logo How to Create a Toast Service Using Angular 14
and Bootstrap 5

angular-bootstrap-toast-service's People

Contributors

dependabot[bot] avatar svierk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

angular-bootstrap-toast-service's Issues

Dropdown stopped opening when adding Toast component

Hello Sebastiano,

Thank you for putting this project together, it has helped me a lot.

I do have one issue however. When I add the Toast component, all my existing dropdown (Bootstrap 5) elements stop opening. I have been able to isolate it to the Toast component (not Toaster).

I forked your code and added a drop down and it works just fine, so it is something with my code.

Any ideas why this may be happening?

Thanks!
Shai

Adding Actions to the Toast

HI Sebastian,

You might remember you helped me last week. I've been able to overcome that issue with your guidance, thank you.

I am now trying to implement buttons/actions on the toast.

In the component, I call the service
customer.component.ts
this.toastService.actionToast("Test", "Test");

Then in the service, I've adapted your code to take Action EventType and showButtons parameter:

toast.service.ts

  actionToast(title: string, message: string) {
    this._toastEvents.next({
      title: title,
      message: message,
      type: EventTypes.Action,
      icon: "../../../../assets/img/action-toast.png",
      errorCode: "",
      showButtons: true
    });
  }

I have also added the two buttons to the toast, with *ngIf

toast.component.html

<div
  #toastElement
  class="toast fade mt-5"
  [ngClass]="type"
  role="alert"
  aria-live="assertive"
  aria-atomic="true"
  style="width: 500px;"
>
  <div class="toast-header">
    <img src={{icon}} class="rounded me-2" alt="toast icon" >
    <strong class="me-auto">{{title}}</strong>
    <button type="button" class="btn-close" aria-label="Close" (click)="hide()"></button>
  </div>
  <div class="toast-body" style="padding-bottom: 40px;">{{message}}</div>
  <div> {{errorCode}}</div>
  <div>
    <button type="button" *ngIf="showButtons" (click)="yes()">Yes</button>
    <button type="button" *ngIf="showButtons" (click)="no()">No</button>
  </div>
</div>

I would like to emit the Yes and No events back to the original calling component via the ToastService. I have added

toast.component.ts

@Output() onYes: EventEmitter<any> = new EventEmitter();
.
.
.
  yes() {
    this.onYes.emit();
    this.hide();
  }
.
.
.

But I am not sure how to "listen" to the emitter from the ToastService. Any suggestions?

Thanks!
Shai

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.