Skip to content

Commit 09a2538

Browse files
committed
Support titles
1 parent 63e992b commit 09a2538

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

simpletoast.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
right: 0,
1313
zIndex: 1000,
1414
},
15+
title: {
16+
display: 'block',
17+
fontSize: '15px',
18+
'font-style': 'italic',
19+
},
1520
shared: {
1621
display: 'inline-block',
1722
maxWidth: '320px',
@@ -60,7 +65,7 @@
6065
})();
6166
let count = 0;
6267

63-
function Toast({text, css, buttons, timeout}) {
68+
function Toast({title, text, css, buttons, timeout}) {
6469
if (typeof arguments[0] === 'string') {
6570
text = arguments[0];
6671
}
@@ -72,7 +77,14 @@
7277
applyCSS(el, style.toast);
7378
applyCSS(el, css);
7479

75-
// Add body
80+
// Add title, body
81+
if (title) {
82+
const tel = document.createElement('span');
83+
applyCSS(tel, style.title);
84+
applyCSS(tel, title.css);
85+
tel.textContent = title.text || title;
86+
el.appendChild(tel);
87+
}
7688
const body = document.createElement('span');
7789
body.textContent = text;
7890
el.appendChild(body);

0 commit comments

Comments
 (0)