Skip to content

Commit 79c82d8

Browse files
Otto WachterOtto Wachter
Otto Wachter
authored and
Otto Wachter
committed
fix styles, debugging styles
1 parent a8590c7 commit 79c82d8

File tree

2 files changed

+38
-13
lines changed

2 files changed

+38
-13
lines changed

js/modules/toast.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const toastModule = new function() {
3838
// Create the container for the toasts
3939
createContainer(position) {
4040
const container = document.createElement('div');
41-
container.className = `enable-toast enable-toast--${position}`;
41+
container.className = `enable-toast__container enable-toast__container--${position}`;
4242
return container;
4343
}
4444

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

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

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

69-
// Create the individual toast element
69+
// Create the individual toast element (Using enable-toast__item)
7070
createToastElement(toastData) {
7171
const { message, level, id } = toastData;
7272
const toast = document.createElement('div');
@@ -98,7 +98,7 @@ const toastModule = new function() {
9898
dismissToast(toastData) {
9999
const toastElement = this.container.querySelector(`[data-id="${toastData.id}"]`);
100100
if (toastElement) {
101-
toastElement.classList.add('enable-toast--exit');
101+
toastElement.classList.add('enable-toast__item--exit');
102102
setTimeout(() => {
103103
toastElement.remove();
104104
this.visibleQueue = this.visibleQueue.filter(t => t.id !== toastData.id);
@@ -123,9 +123,9 @@ const toastModule = new function() {
123123
this.visibleQueue.forEach((toast, index) => {
124124
const toastElement = this.container.querySelector(`[data-id="${toast.id}"]`);
125125
if (index < this.maxVisible) {
126-
toastElement.classList.add('enable-toast--visible');
126+
toastElement.classList.add('enable-toast__item--visible');
127127
} else {
128-
toastElement.classList.remove('enable-toast--visible');
128+
toastElement.classList.remove('enable-toast__item--visible');
129129
}
130130
});
131131

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

@@ -189,4 +189,4 @@ const toastModule = new function() {
189189
}
190190
};
191191

192-
export default toastModule;
192+
export default toastModule;

less/toast.less

+30-5
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,22 @@
1313
@rack-width: 300px;
1414
@rack-max-height: 400px;
1515

16-
// Toast container positions
16+
// Debugging colors for visibility
17+
@debug-border-color: yellow;
18+
@debug-background: rgba(255, 255, 0, 0.2);
19+
@debug-z-index: 9999;
20+
21+
// Toast container positions with added debugging styles
1722
.enable-toast {
1823
&__container {
1924
position: fixed;
20-
z-index: 9999;
25+
z-index: @debug-z-index; // Increased z-index for debugging visibility
2126
display: flex;
2227
transition: @toast-transition;
28+
border: 2px dashed @debug-border-color; // Debugging border to visualize container
29+
30+
// Debugging background to visualize container
31+
background-color: @debug-background;
2332

2433
&--bottom-right,
2534
&--bottom-left,
@@ -56,7 +65,8 @@
5665
}
5766
}
5867

59-
&__toast {
68+
// Toast item styles with debugging styles for visibility
69+
&__item {
6070
display: flex;
6171
align-items: center;
6272
justify-content: space-between;
@@ -69,6 +79,10 @@
6979
opacity: 0;
7080
transition: opacity 0.5s ease-in-out;
7181

82+
// Debugging border and background to visualize the toast
83+
border: 2px solid red;
84+
background-color: @debug-background;
85+
7286
&--visible {
7387
opacity: 1;
7488
}
@@ -78,19 +92,21 @@
7892
}
7993
}
8094

81-
&__close-button {
95+
&__close {
8296
background: none;
8397
border: none;
8498
color: @toast-close-color;
8599
font-size: 16px;
86100
cursor: pointer;
87101

102+
// Debugging hover color
88103
&:hover {
89104
color: @toast-close-hover-color;
105+
border: 1px solid @debug-border-color; // Debugging border
90106
}
91107
}
92108

93-
// toast rack
109+
// Toast rack with debugging styles
94110
&__rack {
95111
position: fixed;
96112
top: 20px;
@@ -103,5 +119,14 @@
103119
overflow-y: auto;
104120
display: none;
105121
z-index: 9998;
122+
123+
// Debugging styles
124+
background-color: rgba(
125+
0,
126+
255,
127+
0,
128+
0.2
129+
); // Light green background for rack visibility
130+
border: 2px dashed orange;
106131
}
107132
}

0 commit comments

Comments
 (0)