Skip to content

Commit

Permalink
Merge pull request #88 from l3szcz/master
Browse files Browse the repository at this point in the history
Fix close button to be semantic html
  • Loading branch information
apvarun authored Dec 5, 2021
2 parents d21c577 + 5a1333e commit 5725170
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/toastify-es.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,11 @@ class Toastify {
// Adding a close icon to the toast
if (this.options.close === true) {
// Create a span for close element
let closeElement = document.createElement("span");
closeElement.innerHTML = "✖";

let closeElement = document.createElement("button");
closeElement.type = "button";
closeElement.setAttribute("aria-label", "Close");
closeElement.className = "toast-close";
closeElement.innerHTML = "✖";

// Triggering the removal of toast from DOM on close click
closeElement.addEventListener(
Expand Down
6 changes: 6 additions & 0 deletions src/toastify.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
}

.toast-close {
background: transparent;
border: 0;
color: white;
cursor: pointer;
font-family: inherit;
font-size: 1em;
opacity: 0.4;
padding: 0 5px;
}
Expand Down
7 changes: 4 additions & 3 deletions src/toastify.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,11 @@
// Adding a close icon to the toast
if (this.options.close === true) {
// Create a span for close element
var closeElement = document.createElement("span");
closeElement.innerHTML = "✖";

var closeElement = document.createElement("button");
closeElement.type = "button";
closeElement.setAttribute("aria-label", "Close");
closeElement.className = "toast-close";
closeElement.innerHTML = "✖";

// Triggering the removal of toast from DOM on close click
closeElement.addEventListener(
Expand Down

0 comments on commit 5725170

Please sign in to comment.