Skip to content

Commit 3387cd8

Browse files
committed
refactor: move toast and dialog overlay styles to remote helper file
1 parent 464abbf commit 3387cd8

2 files changed

Lines changed: 80 additions & 72 deletions

File tree

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 8 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,19 +2153,17 @@ function RemoteFunctions(config = {}) {
21532153
// if element is non-editable we use gray bg color in info box, otherwise normal blue color
21542154
const bgColor = this.element.hasAttribute(GLOBALS.DATA_BRACKETS_ID_ATTR) ? '#4285F4' : '#3C3F41';
21552155

2156-
// we need to insert some dynamic values in the info box styles
2157-
const styles = `
2156+
// add everything to the shadow box with CSS variables for dynamic values
2157+
shadow.innerHTML = `
21582158
<style>
21592159
${config.styles.infoBox}
21602160
:host {
21612161
--info-box-bg-color: ${bgColor};
21622162
--info-box-left-pos: ${leftPos}px;
21632163
}
21642164
</style>
2165+
<div class="phoenix-node-info-box">${content}</div>
21652166
`;
2166-
2167-
// add everything to the shadow box
2168-
shadow.innerHTML = `<style>${styles}</style><div class="phoenix-node-info-box">${content}</div>`;
21692167
this._shadow = shadow;
21702168
},
21712169

@@ -4158,43 +4156,17 @@ function RemoteFunctions(config = {}) {
41584156
const overlay = window.document.createElement('div');
41594157
overlay.setAttribute(GLOBALS.PHCODE_INTERNAL_ATTR, 'true');
41604158

4161-
const styles = `
4162-
<style>
4163-
.phoenix-dialog-overlay {
4164-
position: fixed !important;
4165-
top: 0 !important;
4166-
left: 0 !important;
4167-
width: 100% !important;
4168-
height: 100% !important;
4169-
background: rgba(0, 0, 0, 0.5) !important;
4170-
z-index: 2147483646 !important;
4171-
pointer-events: auto !important;
4172-
}
4173-
4174-
.phoenix-dialog-message-bar {
4175-
position: absolute !important;
4176-
top: 50% !important;
4177-
left: 50% !important;
4178-
transform: translate(-50%, -50%) !important;
4179-
color: #ffffff !important;
4180-
background-color: #333333 !important;
4181-
padding: 1em 1.5em !important;
4182-
text-align: center !important;
4183-
font-size: 16px !important;
4184-
border-radius: 3px !important;
4185-
font-family: "SourceSansPro", Helvetica, Arial, sans-serif !important;
4186-
z-index: 2147483647 !important;
4187-
}
4188-
</style>
4189-
`;
4159+
// use shadow DOM for style isolation
4160+
const shadow = overlay.attachShadow({ mode: 'open' });
4161+
const styles = config.styles.dialogOverlay;
41904162

41914163
const content = `
41924164
<div class="phoenix-dialog-overlay">
41934165
<div class="phoenix-dialog-message-bar">${config.strings.imageGalleryDialogOverlayMessage}</div>
41944166
</div>
41954167
`;
41964168

4197-
overlay.innerHTML = styles + content;
4169+
shadow.innerHTML = `<style>${styles}</style>${content}`;
41984170
window.document.body.appendChild(overlay);
41994171
_dialogOverlay = overlay;
42004172
}
@@ -5235,42 +5207,7 @@ function RemoteFunctions(config = {}) {
52355207
toast.setAttribute(GLOBALS.PHCODE_INTERNAL_ATTR, "true");
52365208
const shadow = toast.attachShadow({ mode: 'open' });
52375209

5238-
const styles = `
5239-
:host {
5240-
all: initial !important;
5241-
}
5242-
5243-
.toast-container {
5244-
position: fixed !important;
5245-
bottom: 30px !important;
5246-
left: 50% !important;
5247-
transform: translateX(-50%) translateY(0) !important;
5248-
background-color: rgba(51, 51, 51, 0.95) !important;
5249-
color: white !important;
5250-
padding: 10px 14px !important;
5251-
border-radius: 6px !important;
5252-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
5253-
font-family: Arial, sans-serif !important;
5254-
font-size: 13px !important;
5255-
line-height: 1.4 !important;
5256-
z-index: 2147483647 !important;
5257-
text-align: center !important;
5258-
max-width: 90% !important;
5259-
box-sizing: border-box !important;
5260-
animation: slideUp 0.3s ease-out !important;
5261-
}
5262-
5263-
@keyframes slideUp {
5264-
from {
5265-
opacity: 0;
5266-
transform: translateY(20px);
5267-
}
5268-
to {
5269-
opacity: 1;
5270-
transform: translateY(0);
5271-
}
5272-
}
5273-
`;
5210+
const styles = config.styles.toastMessage;
52745211

52755212
const content = `
52765213
<div class="toast-container">

src/LiveDevelopment/RemoteHelper.js

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,82 @@ define(function (require, exports, module) {
383383
}
384384
`;
385385

386+
const toastMessageStyles = `
387+
:host {
388+
all: initial !important;
389+
}
390+
391+
.toast-container {
392+
position: fixed !important;
393+
bottom: 30px !important;
394+
left: 50% !important;
395+
transform: translateX(-50%) translateY(0) !important;
396+
background-color: rgba(51, 51, 51, 0.95) !important;
397+
color: white !important;
398+
padding: 10px 14px !important;
399+
border-radius: 6px !important;
400+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
401+
font-family: Arial, sans-serif !important;
402+
font-size: 13px !important;
403+
line-height: 1.4 !important;
404+
z-index: 2147483647 !important;
405+
text-align: center !important;
406+
max-width: 90% !important;
407+
box-sizing: border-box !important;
408+
animation: slideUp 0.3s ease-out !important;
409+
}
410+
411+
@keyframes slideUp {
412+
from {
413+
opacity: 0;
414+
transform: translateY(20px);
415+
}
416+
to {
417+
opacity: 1;
418+
transform: translateY(0);
419+
}
420+
}
421+
`;
422+
423+
const dialogOverlayStyles = `
424+
:host {
425+
all: initial !important;
426+
}
427+
428+
.phoenix-dialog-overlay {
429+
position: fixed !important;
430+
top: 0 !important;
431+
left: 0 !important;
432+
width: 100% !important;
433+
height: 100% !important;
434+
background: rgba(0, 0, 0, 0.5) !important;
435+
z-index: 2147483646 !important;
436+
pointer-events: auto !important;
437+
}
438+
439+
.phoenix-dialog-message-bar {
440+
position: absolute !important;
441+
top: 50% !important;
442+
left: 50% !important;
443+
transform: translate(-50%, -50%) !important;
444+
color: #ffffff !important;
445+
background-color: #333333 !important;
446+
padding: 1em 1.5em !important;
447+
text-align: center !important;
448+
font-size: 16px !important;
449+
border-radius: 3px !important;
450+
font-family: "SourceSansPro", Helvetica, Arial, sans-serif !important;
451+
z-index: 2147483647 !important;
452+
}
453+
`;
454+
386455
const remoteStyles = {
387456
optionsBox: optionsBoxStyles,
388457
optionsBoxImageGallerySelected: optionsBoxImageGallerySelectedStyles,
389458
optionsBoxDropdown: optionsBoxDropdownStyles,
390-
infoBox: infoBoxStyles
459+
infoBox: infoBoxStyles,
460+
toastMessage: toastMessageStyles,
461+
dialogOverlay: dialogOverlayStyles
391462
};
392463

393464
exports.remoteStrings = remoteStrings;

0 commit comments

Comments
 (0)