Skip to content

Commit ec948aa

Browse files
committed
(feat): toast notification on copied
1 parent c0b6e40 commit ec948aa

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

src/js/cheatsheet.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,14 @@ $(function(){
412412
$temp.text(element).trigger('select');
413413
document.execCommand("copy");
414414
$temp.remove();
415+
416+
var toastElList = [].slice.call(document.querySelectorAll('.notification .toast'))
417+
var toastList = toastElList.map(function (toastEl) {
418+
return new bootstrap.Toast(toastEl, {
419+
autohide: true,
420+
delay: 2000
421+
}).show()
422+
})
415423
}
416424

417425
// copy attribute on icon click

src/scss/custom/_demo.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,12 @@
110110
text-transform: uppercase;
111111
}
112112
}
113+
.notification {
114+
position: fixed;
115+
top: 1rem;
116+
right: 1rem;
117+
.toast{
118+
width: 200px;
119+
}
120+
}
113121
}

src/template-builder/base.pug

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ html
2323
//- BEGIN: Content
2424
.container.bs-content
2525
include contents/filters.html
26+
include contents/notification.html
2627
#grid.row
2728
block content
2829
include partials/no-items-found.html
2930
if showAlert
3031
include partials/alert-tip.html
31-
// END: Content
32+
//- END: Content
3233
3334
//- BEGIN: Footer
3435
block footer
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div class="notification">
2+
<div class="toast hide d-flex align-items-center text-white bg-info border-0" role="alert" aria-live="assertive" aria-atomic="true">
3+
<div class="toast-body">
4+
<span>Copied!!! 👍</span>
5+
</div>
6+
<button type="button" class="btn-close btn-close-white ms-auto me-2" data-bs-dismiss="toast" aria-label="Close"></button>
7+
</div>
8+
</div>

0 commit comments

Comments
 (0)