Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow showing multiple snackbar messages at the same time #851

Merged
merged 1 commit into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions assets/js/snackbar/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
class Snackbar {
element: HTMLElement;
container: HTMLElement;

constructor() {
const e = document.createElement('div');
e.className =
'snackbar opacity-0 position-fixed w-100 d-flex justify-content-center';
document.body.appendChild(e);
this.element = e;
const container = document.createElement('div');
container.className = 'snackbar-container position-fixed d-flex justify-content-center align-items-center top-50 start-50 flex-column';
document.body.appendChild(container);
this.container = container;
}

show(body: string, duration = 2000) {
this.element.innerHTML =
'<div class="snackbar-body text-bg-secondary rounded px-3 py-2">' +
body +
'</div>';
this.element.classList.add('show');
const ele = document.createElement('div')
ele.className = 'snackbar text-bg-secondary rounded px-3 py-2 my-1'
ele.innerText = body
this.container.appendChild(ele)
setTimeout(() => {
this.element.classList.remove('show');
setTimeout(() => {
this.element.innerHTML = '';
}, 1000)
}, duration);
ele.remove()
}, duration)
}
}

Expand Down
8 changes: 4 additions & 4 deletions purgecss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ const purgecss = require('@fullhuman/postcss-purgecss')({
'col-xxl-10',
'd-flex',
'end-0',
'fs-lg', 'fs-sm', 'fs-xl', 'fs-xs', 'fst-italic',
'flex-column', 'fs-lg', 'fs-sm', 'fs-xl', 'fs-xs', 'fst-italic',
'justify-content-center',
'm-1', 'mb-0', 'mb-1', 'my-2', 'mx-2', 'mb-2',
'm-1', 'mb-0', 'mb-1', 'my-1', 'my-2', 'mx-2', 'mb-2',
'list-unstyled',
'offcanvas-backdrop',
'opacity-0', 'opacity-50', 'opacity-100', 'overflow-hidden',
'p-1', 'pb-0', 'pe-3', 'pt-0', 'pt-1', 'px-2', 'py-1', 'px-3', 'py-2', 'p-2', 'position-absolute', 'position-fixed', 'position-relative', 'position-sticky',
'rounded', 'rounded-top',
'show',
'text-nowrap', 'text-pre-wrap', 'text-uppercase', 'text-white', 'top-0', 'text-bg-secondary', 'text-success', 'text-truncate',
'show', 'start-50',
'text-nowrap', 'text-pre-wrap', 'text-uppercase', 'text-white', 'top-0', 'top-50', 'text-bg-secondary', 'text-success', 'text-truncate',
'user-select-all',
'w-100',
'was-validated',
Expand Down