@ussebastian/kitdigital
Version:
Kit Digital de la Universidad San Sebastián
62 lines (61 loc) • 1.4 kB
HTML
<div class="p-32">
<button id="showToast" class="uss-btn uss-btn--primary">Agregar Toast</button>
</div>
<script>
document.getElementById('showToast').addEventListener('click', (e) => {
const TimeStamp = +new Date();
const getRandomIndex = (array) => Math.floor(Math.random() * array.length);
const toastData = [
[
{
title: 'Toast Title',
},
'success',
10000,
],
[
{
title: 'Toast Title',
description: 'Toast Description',
action: {
label: 'Acción opcional',
fn: () => {
alert('hola');
},
},
},
'info',
10000,
],
[
{
title: 'Toast Title',
description: 'Toast Description',
action: {
label: 'Acción opcional',
fn: () => {
alert('hola');
},
},
},
'error',
10000,
],
[
{
title: 'Toast Title',
description: 'Toast Description',
action: {
label: 'Acción opcional',
fn: () => {
alert('hola');
},
},
},
'warning',
10000,
],
];
window.USSKitDigital.Static.Toast.show(...toastData[getRandomIndex(toastData)]);
});
</script>