Skip to content

Commit b2f4d20

Browse files
committed
IBX-10555: Added blured loader for modal
1 parent 152ca4d commit b2f4d20

File tree

3 files changed

+98
-1
lines changed

3 files changed

+98
-1
lines changed

src/bundle/Resources/public/js/scripts/helpers/modal.helper.js

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,54 @@ const controlManyZIndexes = (items, listenerContainer) => {
5050
};
5151
};
5252

53-
export { controlZIndex, controlManyZIndexes };
53+
const showModalLoader = ({ headerText, descriptionText, modalNode }) => {
54+
if (!modalNode) {
55+
return;
56+
}
57+
58+
const modalDialog = modalNode.querySelector('.modal-dialog');
59+
const headerNode = modalNode.querySelector('.modal-header');
60+
const loaderNode = modalNode.querySelector('.ibexa-modal__loader');
61+
const headerRect = headerNode ? headerNode.getBoundingClientRect() : { height: 0 };
62+
const dialogRect = modalDialog.getBoundingClientRect();
63+
const { height: dialogHeight, width: dialogWidth } = dialogRect;
64+
const { height: headerHeight } = headerRect;
65+
66+
loaderNode.style.height = `${dialogHeight - headerHeight}px`;
67+
loaderNode.style.width = `${dialogWidth}px`;
68+
loaderNode.style.top = `${headerHeight}px`;
69+
70+
if (headerText) {
71+
const headerTextNode = modalNode.querySelector('.ibexa-modal__loader-header-text');
72+
73+
headerTextNode.innerText = headerText;
74+
}
75+
76+
if (descriptionText) {
77+
const descriptionTextNode = modalNode.querySelector('.ibexa-modal__loader-description-text');
78+
79+
descriptionTextNode.innerText = descriptionText;
80+
}
81+
82+
modalNode.classList.add('ibexa-modal--with-blurred-loader');
83+
};
84+
85+
const hideModalLoader = ({ modalNode }) => {
86+
if (!modalNode) {
87+
return;
88+
}
89+
90+
const headerTextNode = modalNode.querySelector('.ibexa-modal__loader-header-text');
91+
const descriptionTextNode = modalNode.querySelector('.ibexa-modal__loader-description-text');
92+
93+
headerTextNode.innerText = '';
94+
descriptionTextNode.innerText = '';
95+
96+
modalNode.classList.remove('ibexa-modal--with-blurred-loader');
97+
};
98+
99+
document.body.addEventListener('hidden.bs.modal', (event) => {
100+
hideModalLoader({ modalNode: event.target });
101+
});
102+
103+
export { controlZIndex, controlManyZIndexes, showModalLoader, hideModalLoader };

src/bundle/Resources/public/scss/_modals.scss

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,38 @@
4646
@include modal-footer();
4747
}
4848

49+
&__loader {
50+
position: absolute;
51+
left: 0;
52+
z-index: 1;
53+
display: none;
54+
backdrop-filter: blur(8px);
55+
pointer-events: none;
56+
border-radius: 0 0 $ibexa-border-radius $ibexa-border-radius;
57+
}
58+
59+
&__loader-content {
60+
display: flex;
61+
flex-direction: column;
62+
align-items: center;
63+
}
64+
65+
&__loader-header-text:not(:empty) {
66+
margin-top: calculateRem(24px);
67+
font-weight: bold;
68+
}
69+
70+
&__loader-description-text:not(:empty) {
71+
margin-top: calculateRem(8px);
72+
}
73+
74+
&__loader-spinner {
75+
@include spinner(calculateRem(48px), calculateRem(6px), $ibexa-color-primary);
76+
}
77+
78+
&__loader-header-text {
79+
}
80+
4981
&--no-header {
5082
.close {
5183
@include close-button();
@@ -96,4 +128,12 @@
96128
}
97129
}
98130
}
131+
132+
&--with-blurred-loader {
133+
.ibexa-modal__loader {
134+
display: flex;
135+
align-items: center;
136+
justify-content: center;
137+
}
138+
}
99139
}

src/bundle/Resources/views/themes/admin/ui/component/modal/modal.html.twig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@
9696
{% endif %}
9797
{% endblock %}
9898
{% block body %}
99+
<div class="ibexa-modal__loader">
100+
<div class="ibexa-modal__loader-content">
101+
<div class="ibexa-modal__loader-spinner"></div>
102+
<div class="ibexa-modal__loader-header-text"></div>
103+
<div class="ibexa-modal__loader-description-text"></div>
104+
</div>
105+
</div>
99106
{% if block('body_content') is defined %}
100107
<div class="modal-body">
101108
{{ block('body_content') }}

0 commit comments

Comments
 (0)