Show more descriptive toast

This commit is contained in:
Jake Ginnivan 2020-08-01 18:30:17 +08:00 committed by GitHub
parent 55da52c696
commit 3635f85cab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -243,7 +243,7 @@
`.svg`"
x-bind:download="downloadType === 'download-svg' && item.icon_name"
class="flex flex-col relative items-center group justify-center text-gray-700 rounded shadow hover:shadow-xl bg-white cursor-pointer transition duration-150 ease-in-out h-32 md:h-40"
@click="handleClick(item, downloadType, $event), $dispatch('show:toast', item.icon_name), setTimeout(() => $dispatch('show:toast', false), 1000)"
@click="handleClick(item, downloadType, $event, $dispatch)"
>
<div>
<div
@ -260,7 +260,9 @@
x-transition:leave-start="opacity-100 transform scale-100"
x-transition:leave-end="opacity-0 transform scale-90"
>
Copied
<template x-if="downloadType == 'download-svg'">Downloading!</template>
<template x-if="downloadType == 'copy-cdn'">Copied URL</template>
<template x-if="downloadType == 'copy-svg'">Copied SVG Code</template>
</div>
</div>
<img
@ -1421,7 +1423,7 @@
.includes(this.search.toLowerCase());
});
},
handleClick(item, downloadType, event) {
handleClick(item, downloadType, event, $dispatch) {
if (downloadType === "copy-svg") {
event.preventDefault();
var url =
@ -1435,6 +1437,8 @@
if (response.ok) {
response.text().then(function (svg) {
navigator.clipboard.writeText(svg);
$dispatch('show:toast', item.icon_name)
setTimeout(() => $dispatch('show:toast', false), 1000)
});
}
});
@ -1449,6 +1453,12 @@
item.icon_path +
`.svg`;
navigator.clipboard.writeText(url);
$dispatch('show:toast', item.icon_name)
setTimeout(() => $dispatch('show:toast', false), 1000)
} else {
$dispatch('show:toast', item.icon_name)
setTimeout(() => $dispatch('show:toast', false), 1000)
}
},
};