Skip to content

Commit 9872c90

Browse files
committed
test buttons
1 parent 6a9ed8c commit 9872c90

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

templates/devtest/toast.tmpl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
<div>
44
<h1>Toast</h1>
55
<div>
6-
<button class="ui button" id="info-toast">Show Info Toast</button>
7-
<button class="ui button" id="warning-toast">Show Warning Toast</button>
8-
<button class="ui button" id="error-toast">Show Error Toast</button>
6+
<button class="ui button toast-test-button" data-toast-level="info" data-toast-message="test info">Show Info Toast</button>
7+
<button class="ui button toast-test-button" data-toast-level="warning" data-toast-message="test warning">Show Warning Toast</button>
8+
<button class="ui button toast-test-button" data-toast-level="error" data-toast-message="test error">Show Error Toast</button>
9+
<button class="ui button toast-test-button" data-toast-level="error" data-toast-message="test error (another)">Show Error Toast (another)</button>
910
</div>
1011
</div>
1112

web_src/css/modules/toast.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
align-items: center;
3636
}
3737

38+
.toast-icon svg {
39+
width: 30px;
40+
}
41+
3842
.toast-duplicate-number::before {
3943
content: "(";
4044
}

web_src/js/standalone/devtest.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import {showInfoToast, showWarningToast, showErrorToast} from '../modules/toast.js';
22

3-
document.querySelector('#info-toast').addEventListener('click', () => {
4-
showInfoToast('success 😀');
5-
});
6-
document.querySelector('#warning-toast').addEventListener('click', () => {
7-
showWarningToast('warning 😐');
8-
});
9-
document.querySelector('#error-toast').addEventListener('click', () => {
10-
showErrorToast('error 🙁');
11-
});
3+
function initDevtestToast() {
4+
const levelMap = {info: showInfoToast, warning: showWarningToast, error: showErrorToast};
5+
for (const el of document.querySelectorAll('.toast-test-button')) {
6+
el.addEventListener('click', () => {
7+
const level = el.getAttribute('data-toast-level');
8+
const message = el.getAttribute('data-toast-message');
9+
levelMap[level](message);
10+
});
11+
}
12+
}
13+
14+
initDevtestToast();

0 commit comments

Comments
 (0)