Extract Backbone Lightbox view module
This commit is contained in:
parent
8cfe12644a
commit
593976fe21
4 changed files with 38 additions and 7 deletions
25
ts/backbone/views/Lightbox.ts
Normal file
25
ts/backbone/views/Lightbox.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* @prettier
|
||||
*/
|
||||
export const show = (element: HTMLElement): void => {
|
||||
const container: HTMLDivElement | null = document.querySelector(
|
||||
'.lightboxContainer'
|
||||
);
|
||||
if (container === null) {
|
||||
throw new TypeError("'.lightboxContainer' is required");
|
||||
}
|
||||
container.innerHTML = '';
|
||||
container.style.display = 'block';
|
||||
container.appendChild(element);
|
||||
};
|
||||
|
||||
export const hide = (): void => {
|
||||
const container: HTMLDivElement | null = document.querySelector(
|
||||
'.lightboxContainer'
|
||||
);
|
||||
if (container === null) {
|
||||
return;
|
||||
}
|
||||
container.innerHTML = '';
|
||||
container.style.display = 'none';
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue