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

Added background bluring when modal is shown #2466

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions src/cryptoadvance/specter/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*::-webkit-scrollbar,
*::-webkit-scrollbar-track-piece,
*::-webkit-scrollbar-corner {
@apply !bg-transparent !w-2;
@apply !bg-transparent !w-2;
}

*::-webkit-scrollbar-thumb {
Expand Down Expand Up @@ -49,7 +49,7 @@
p {
@apply text-lg my-1 max-w-prose text-dark-100;
}

a {
@apply !no-underline;
}
Expand Down
2 changes: 1 addition & 1 deletion src/cryptoadvance/specter/templates/base.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
{% endif %}
{% endblock %}

<div id="mobile-distance-element-bottom" class="mobile-distance-element-bottom"></div>
<div id="mobile-distance-element-bottom" class="mobile-distance-element-bottom"></div>
</main>
</div>
</div>
Expand Down
32 changes: 30 additions & 2 deletions src/cryptoadvance/specter/templates/includes/overlay/overlay.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<style>
.blur-background {
filter: blur(5px);
transition: filter 0.3s ease;
}
</style>
<div class="hidden z-30 absolute w-screen h-screen" id="page_overlay">
<div class="w-screen overflow-auto h-screen bg-black/40 flex flex-col relative justify-center items-center py-5" id="page_overlay_popup">
<div class="box-shadow-xl transition-all absolute max-w-[700px] overflow-hidden rounded-xl text-white" id="page_overlay_popup_content"></div>
Expand Down Expand Up @@ -35,6 +41,9 @@
var overlay = document.getElementById("page_overlay");
overlay.style.display = "flex";

// Blur the background
blurBackground(true);

// Position and show the popup
var overlayPopup = document.getElementById("page_overlay_popup");
overlayPopup.style.display = "flex";
Expand Down Expand Up @@ -67,7 +76,7 @@
holder.appendChild(document.getElementById(document.getElementById("page_overlay_popup_content").children[0].id));

var overlay = document.getElementById("page_overlay");
overlay.style.display = "none";
overlay.style.display = "none";

var overlayPopup = document.getElementById("page_overlay_popup");
overlayPopup.style.display = "none";
Expand All @@ -78,12 +87,31 @@
contentContainer.style.right = "auto";
contentContainer.style.bottom = "auto";
contentContainer.style.justifySelf = "center";

/*
// A file using `overlay.html` should implement `onCancelOverlay` JS function to handle popup cancel logic
onCancelOverlay();
*/
// Remove blur from background
blurBackground(false);

// Trigger any custom logic for canceling the overlay
if (typeof onCancelOverlay === 'function') {
onCancelOverlay();
}
}
}

function blurBackground(blur = true) {
const contentToBlur = document.querySelectorAll('body > *:not(#page_overlay):not(#page_overlay_popup)');
contentToBlur.forEach(element => {
if (blur) {
element.classList.add('blur-background');
} else {
element.classList.remove('blur-background');
}
});
}

function overlayIsActive(){
let el = document.getElementById("page_overlay");
return el.style.display != "none";
Expand Down