Skip to content

Commit 7cb4f4e

Browse files
devvaannshabose
authored andcommitted
feat: allow closing the toast notification with a dont show again button
1 parent ea28fe5 commit 7cb4f4e

File tree

1 file changed

+52
-8
lines changed

1 file changed

+52
-8
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3847,9 +3847,12 @@ function RemoteFunctions(config = {}) {
38473847
}
38483848

38493849
// if element is not editable and user clicks on it, then we show a toast notification saying
3850-
// that this element is not editable
3850+
// that this element is not editable (unless user dismissed it permanently)
38513851
if (!element.hasAttribute("data-brackets-id")) {
3852-
showToast("Element not editable - generated by script");
3852+
const hideToast = localStorage.getItem('phoenix-hide-dynamic-toast');
3853+
if (!hideToast) {
3854+
showToast("Element not editable - generated by script.");
3855+
}
38533856
}
38543857

38553858
// make sure that the element is actually visible to the user
@@ -4579,22 +4582,42 @@ function RemoteFunctions(config = {}) {
45794582
bottom: 30px !important;
45804583
left: 50% !important;
45814584
transform: translateX(-50%) translateY(0) !important;
4582-
background-color: #333333f2 !important;
4585+
background-color: rgba(51, 51, 51, 0.95) !important;
45834586
color: white !important;
4584-
padding: 10px 12px !important;
4587+
padding: 10px 14px !important;
45854588
border-radius: 6px !important;
45864589
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
45874590
font-family: Arial, sans-serif !important;
45884591
font-size: 13px !important;
45894592
line-height: 1.4 !important;
45904593
z-index: 2147483647 !important;
4591-
pointer-events: none !important;
45924594
text-align: center !important;
45934595
max-width: 90% !important;
45944596
box-sizing: border-box !important;
45954597
animation: slideUp 0.3s ease-out !important;
45964598
}
45974599
4600+
.toast-message {
4601+
margin-bottom: 6px !important;
4602+
}
4603+
4604+
.toast-button {
4605+
background: none !important;
4606+
border: none !important;
4607+
color: #A0A0A0 !important;
4608+
cursor: pointer !important;
4609+
font-size: 12px !important;
4610+
font-family: Arial, sans-serif !important;
4611+
text-decoration: none !important;
4612+
pointer-events: auto !important;
4613+
transition: opacity 0.2s !important;
4614+
}
4615+
4616+
.toast-button:hover {
4617+
opacity: 0.8 !important;
4618+
text-decoration: underline !important;
4619+
}
4620+
45984621
@keyframes slideUp {
45994622
from {
46004623
opacity: 0;
@@ -4607,16 +4630,37 @@ function RemoteFunctions(config = {}) {
46074630
}
46084631
`;
46094632

4610-
shadow.innerHTML = `<style>${styles}</style><div class="toast-container">${message}</div>`;
4633+
const content = `
4634+
<div class="toast-container">
4635+
<div class="toast-message">${message}</div>
4636+
<button class="toast-button">Don't show again</button>
4637+
</div>
4638+
`;
4639+
4640+
shadow.innerHTML = `<style>${styles}</style>${content}`;
46114641
window.document.body.appendChild(toast);
46124642

4613-
// Auto-dismiss after 3 seconds
4643+
// add click handler to "Don't show again" button
4644+
const button = shadow.querySelector('.toast-button');
4645+
button.addEventListener('click', () => {
4646+
// save to localStorage to never show again and close toast rn
4647+
localStorage.setItem('phoenix-hide-dynamic-toast', 'true');
4648+
if (toast && toast.parentNode) {
4649+
toast.remove();
4650+
}
4651+
if (_toastTimeout) {
4652+
clearTimeout(_toastTimeout);
4653+
_toastTimeout = null;
4654+
}
4655+
});
4656+
4657+
// Auto-dismiss after 6 seconds
46144658
_toastTimeout = setTimeout(() => {
46154659
if (toast && toast.parentNode) {
46164660
toast.remove();
46174661
}
46184662
_toastTimeout = null;
4619-
}, 3000);
4663+
}, 6000);
46204664
}
46214665

46224666
/**

0 commit comments

Comments
 (0)