Skip to content

Commit

Permalink
feat: add remove content method to modal
Browse files Browse the repository at this point in the history
  • Loading branch information
stardustmeg committed May 29, 2024
1 parent e578106 commit 45a607a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/features/AddressAdd/model/AddressAddModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class AddressAddModel {
const cancelButton = this.view.getCancelButton().getHTML();
cancelButton.addEventListener('click', () => {
modal.hide();
modal.removeContent();
});
return true;
}
Expand Down
1 change: 1 addition & 0 deletions src/features/AddressEdit/model/AddressEditModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class AddressEditModel {
const cancelButton = this.view.getCancelButton().getHTML();
cancelButton.addEventListener('click', () => {
modal.hide();
modal.removeContent();
});
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class PersonalInfoEditModel {
const cancelButton = this.view.getCancelButton().getHTML();
cancelButton.addEventListener('click', () => {
modal.hide();
modal.removeContent();
});
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions src/shared/Modal/model/ModalModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class ModalModel {
this.view.hide();
}

public removeContent(): void {
this.view.removeContent();
}

public setContent(content: HTMLElement): void {
this.view.setContent(content);
}
Expand Down
7 changes: 6 additions & 1 deletion src/shared/Modal/view/ModalView.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import clearOutElement from '@/shared/utils/clearOutElement.ts';
import createBaseElement from '@/shared/utils/createBaseElement.ts';

import styles from './modalView.module.scss';
Expand Down Expand Up @@ -76,8 +77,12 @@ class ModalView {
document.body.classList.remove('stop-scroll');
}

public removeContent(): void {
clearOutElement(this.modalContent);
}

public setContent(content: HTMLElement): void {
this.modalContent.innerHTML = '';
clearOutElement(this.modalContent);
this.modalContent.append(content);
}

Expand Down

0 comments on commit 45a607a

Please sign in to comment.