File tree Expand file tree Collapse file tree 3 files changed +20
-12
lines changed
Expand file tree Collapse file tree 3 files changed +20
-12
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 3535 align-items : center;
3636}
3737
38+ .toast-icon svg {
39+ width : 30px ;
40+ }
41+
3842.toast-duplicate-number ::before {
3943 content : "(" ;
4044}
Original file line number Diff line number Diff line change 11import { 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 ( ) ;
You can’t perform that action at this time.
0 commit comments