Skip to content

Commit

Permalink
es4 module
Browse files Browse the repository at this point in the history
  • Loading branch information
Otto Wachter authored and Otto Wachter committed Oct 9, 2024
1 parent e46ecdd commit 1486b94
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions js/modules/es4/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const toastModule = new function() {
// Create the container for the toasts
createContainer(position) {
const container = document.createElement('div');
container.className = `enable-toast enable-toast--${position}`;
container.className = `enable-toast__container enable-toast__container--${position}`;
return container;
}

Expand All @@ -57,7 +57,7 @@ const toastModule = new function() {
toastElement.offsetHeight; // Force reflow to ensure the element is rendered before adding the visible class

setTimeout(() => {
toastElement.classList.add('enable-toast--visible');
toastElement.classList.add('enable-toast__item--visible');
}, 100); // Slight delay to ensure screen readers catch the change

// Update the toast rack with the new toast
Expand All @@ -66,7 +66,7 @@ const toastModule = new function() {
this.updateToggleRackButton();
}

// Create the individual toast element
// Create the individual toast element (Using enable-toast__item)
createToastElement(toastData) {
const { message, level, id } = toastData;
const toast = document.createElement('div');
Expand Down Expand Up @@ -98,7 +98,7 @@ const toastModule = new function() {
dismissToast(toastData) {
const toastElement = this.container.querySelector(`[data-id="${toastData.id}"]`);
if (toastElement) {
toastElement.classList.add('enable-toast--exit');
toastElement.classList.add('enable-toast__item--exit');
setTimeout(() => {
toastElement.remove();
this.visibleQueue = this.visibleQueue.filter(t => t.id !== toastData.id);
Expand All @@ -123,9 +123,9 @@ const toastModule = new function() {
this.visibleQueue.forEach((toast, index) => {
const toastElement = this.container.querySelector(`[data-id="${toast.id}"]`);
if (index < this.maxVisible) {
toastElement.classList.add('enable-toast--visible');
toastElement.classList.add('enable-toast__item--visible');
} else {
toastElement.classList.remove('enable-toast--visible');
toastElement.classList.remove('enable-toast__item--visible');
}
});

Expand All @@ -146,7 +146,7 @@ const toastModule = new function() {
this.toastQueue.forEach(toastData => {
const { message, level, id } = toastData;
const toastElement = document.createElement('div');
toastElement.className = 'enable-toast__item enable-toast--visible';
toastElement.className = 'enable-toast__item enable-toast__item--visible';
toastElement.style.backgroundColor = this.levels[level]?.color || '#333';
toastElement.setAttribute('data-id', id);

Expand Down

0 comments on commit 1486b94

Please sign in to comment.