Skip to content

Commit 15b9baf

Browse files
committed
refactor: change naming convention from node info box to info box
1 parent 82e7a7d commit 15b9baf

File tree

4 files changed

+40
-40
lines changed

4 files changed

+40
-40
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function RemoteFunctions(config = {}) {
4444
let _localHighlight;
4545
let _hoverHighlight;
4646
let _clickHighlight;
47-
let _nodeInfoBox;
47+
let _infoBox;
4848
let _nodeMoreOptionsBox;
4949
let _moreOptionsDropdown;
5050
let _setup = false;
@@ -479,9 +479,9 @@ function RemoteFunctions(config = {}) {
479479
return false;
480480
}
481481
}
482-
} else if (boxType === 'options-box' && _nodeInfoBox) {
483-
const infoBoxElement = _nodeInfoBox._shadow &&
484-
_nodeInfoBox._shadow.querySelector('.phoenix-node-info-box');
482+
} else if (boxType === 'options-box' && _infoBox) {
483+
const infoBoxElement = _infoBox._shadow &&
484+
_infoBox._shadow.querySelector('.phoenix-info-box');
485485
if (infoBoxElement) {
486486
const infoBoxBounds = infoBoxElement.getBoundingClientRect();
487487
const infoBoxRect = _coordsToRect(
@@ -515,7 +515,7 @@ function RemoteFunctions(config = {}) {
515515
const fallbackPos = { leftPos: -1000, topPos: -1000 };
516516

517517
// Get the box element to determine dimensions
518-
const boxSelector = boxType === 'info-box' ? '.phoenix-node-info-box' : '.phoenix-more-options-box';
518+
const boxSelector = boxType === 'info-box' ? '.phoenix-info-box' : '.phoenix-more-options-box';
519519
const boxElement = boxInstance._shadow &&
520520
boxInstance._shadow.querySelector(boxSelector);
521521

@@ -884,14 +884,14 @@ function RemoteFunctions(config = {}) {
884884
}
885885
};
886886

887-
// Node info box to display DOM node ID and classes on hover
888-
function NodeInfoBox(element) {
887+
// Info box to display DOM element ID and classes on hover
888+
function InfoBox(element) {
889889
this.element = element;
890890
this.remove = this.remove.bind(this);
891891
this.create();
892892
}
893893

894-
NodeInfoBox.prototype = {
894+
InfoBox.prototype = {
895895
_style: function() {
896896
this.body = window.document.createElement("div");
897897
this.body.setAttribute(GLOBALS.PHCODE_INTERNAL_ATTR, "true");
@@ -961,7 +961,7 @@ function RemoteFunctions(config = {}) {
961961
--info-box-bg-color: ${bgColor};
962962
}
963963
</style>
964-
<div class="phoenix-node-info-box">${content}</div>
964+
<div class="phoenix-info-box">${content}</div>
965965
`;
966966
this._shadow = shadow;
967967
},
@@ -981,7 +981,7 @@ function RemoteFunctions(config = {}) {
981981

982982
// initially when we append the box the body, we position it by -1000px on top as well as left
983983
// and then once its added to the body then we reposition it to the actual place
984-
const boxElement = this._shadow.querySelector('.phoenix-node-info-box');
984+
const boxElement = this._shadow.querySelector('.phoenix-info-box');
985985
if (boxElement) {
986986
const boxPos = _calcBoxPosition(this.element, 'info-box', this);
987987
boxElement.style.left = boxPos.leftPos + 'px';
@@ -1378,8 +1378,8 @@ function RemoteFunctions(config = {}) {
13781378
_hoverHighlight.add(element, false);
13791379

13801380
// Create info box for the hovered element
1381-
dismissNodeInfoBox();
1382-
_nodeInfoBox = new NodeInfoBox(element);
1381+
dismissInfoBox();
1382+
_infoBox = new InfoBox(element);
13831383
}
13841384
}
13851385

@@ -1393,7 +1393,7 @@ function RemoteFunctions(config = {}) {
13931393
if (_hoverHighlight && shouldShowHighlightOnHover()) {
13941394
_hoverHighlight.clear();
13951395
clearElementBackground(element);
1396-
dismissNodeInfoBox();
1396+
dismissInfoBox();
13971397
}
13981398
}
13991399
}
@@ -1420,7 +1420,7 @@ function RemoteFunctions(config = {}) {
14201420
function selectElement(element) {
14211421
dismissNodeMoreOptionsBox();
14221422
dismissMoreOptionsDropdown();
1423-
dismissNodeInfoBox();
1423+
dismissInfoBox();
14241424
cleanupPreviousElementState();
14251425

14261426
// this should also be there when users are in highlight mode
@@ -1446,7 +1446,7 @@ function RemoteFunctions(config = {}) {
14461446
_nodeMoreOptionsBox = new NodeMoreOptionsBox(element);
14471447
}
14481448
// Always show info box for inspectable elements
1449-
_nodeInfoBox = new NodeInfoBox(element);
1449+
_infoBox = new InfoBox(element);
14501450

14511451
// Notify handlers about element selection
14521452
getAllNodeMoreOptionsHandlers().forEach(handler => {
@@ -1631,10 +1631,10 @@ function RemoteFunctions(config = {}) {
16311631
_nodeMoreOptionsBox = new NodeMoreOptionsBox(element);
16321632
}
16331633

1634-
if (_nodeInfoBox) {
1635-
const element = _nodeInfoBox.element;
1636-
_nodeInfoBox.remove();
1637-
_nodeInfoBox = new NodeInfoBox(element);
1634+
if (_infoBox) {
1635+
const element = _infoBox.element;
1636+
_infoBox.remove();
1637+
_infoBox = new InfoBox(element);
16381638
}
16391639
}
16401640

@@ -1684,33 +1684,33 @@ function RemoteFunctions(config = {}) {
16841684

16851685
// 4 is just for pixelated differences
16861686
if (Math.abs(calcNewDifference - prevDifference) > 4) {
1687-
dismissNodeInfoBox();
1687+
dismissInfoBox();
16881688
dismissNodeMoreOptionsBox();
16891689
cleanupPreviousElementState();
16901690
}
16911691
}
16921692
}
1693-
} else if (_nodeInfoBox && _nodeInfoBox.element && _nodeInfoBox._shadow) {
1693+
} else if (_infoBox && _infoBox.element && _infoBox._shadow) {
16941694
// if more options box didn't exist, we check with info box (logic is same)
1695-
const infoBoxElement = _nodeInfoBox._shadow.querySelector('.phoenix-node-info-box');
1695+
const infoBoxElement = _infoBox._shadow.querySelector('.phoenix-info-box');
16961696
if (infoBoxElement) {
16971697
// here just we make sure that the element is same
1698-
if(!_nodeInfoBox._prevElement) {
1699-
_nodeInfoBox._prevElement = _nodeInfoBox.element;
1700-
} else if(_nodeInfoBox._prevElement !== _nodeInfoBox.element) {
1698+
if(!_infoBox._prevElement) {
1699+
_infoBox._prevElement = _infoBox.element;
1700+
} else if(_infoBox._prevElement !== _infoBox.element) {
17011701
return;
17021702
} else {
17031703
const infoBoxBounds = infoBoxElement.getBoundingClientRect();
1704-
const elementBounds = _nodeInfoBox.element.getBoundingClientRect();
1704+
const elementBounds = _infoBox.element.getBoundingClientRect();
17051705

1706-
if(!_nodeInfoBox._possDifference) {
1707-
_nodeInfoBox._possDifference = infoBoxBounds.top - elementBounds.top;
1706+
if(!_infoBox._possDifference) {
1707+
_infoBox._possDifference = infoBoxBounds.top - elementBounds.top;
17081708
} else {
17091709
const calcNewDifference = infoBoxBounds.top - elementBounds.top;
1710-
const prevDifference = _nodeInfoBox._possDifference;
1710+
const prevDifference = _infoBox._possDifference;
17111711

17121712
if (Math.abs(calcNewDifference - prevDifference) > 4) {
1713-
dismissNodeInfoBox();
1713+
dismissInfoBox();
17141714
dismissNodeMoreOptionsBox();
17151715
cleanupPreviousElementState();
17161716
}
@@ -2109,12 +2109,12 @@ function RemoteFunctions(config = {}) {
21092109
}
21102110

21112111
/**
2112-
* Helper function to dismiss NodeInfoBox if it exists
2112+
* Helper function to dismiss InfoBox if it exists
21132113
*/
2114-
function dismissNodeInfoBox() {
2115-
if (_nodeInfoBox) {
2116-
_nodeInfoBox.remove();
2117-
_nodeInfoBox = null;
2114+
function dismissInfoBox() {
2115+
if (_infoBox) {
2116+
_infoBox.remove();
2117+
_infoBox = null;
21182118
}
21192119
}
21202120

@@ -2124,7 +2124,7 @@ function RemoteFunctions(config = {}) {
21242124
function dismissAllUIBoxes() {
21252125
dismissNodeMoreOptionsBox();
21262126
dismissMoreOptionsDropdown();
2127-
dismissNodeInfoBox();
2127+
dismissInfoBox();
21282128
getAllNodeMoreOptionsHandlers().forEach(handler => (handler.dismiss && handler.dismiss()));
21292129
}
21302130

src/extensionsIntegrated/phoenix-pro/browser-css/info-box.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
all: initial !important;
33
}
44

5-
.phoenix-node-info-box {
5+
.phoenix-info-box {
66
background-color: var(--info-box-bg-color) !important;
77
color: white !important;
88
border-radius: 3px !important;

src/extensionsIntegrated/phoenix-pro/remote-styles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ define(function (require, exports, module) {
88
const optionsBoxStyles = require("text!./browser-css/options-box.css");
99
// this is the more options dropdown that comes up when clicking the ... icon in the option box.
1010
const optionsBoxDropdownStyles = require("text!./browser-css/more-options-dropdown.css");
11-
// this is the info box about the div that shows the element tyle(like div/image etc), css class, dimensions, etc..
11+
// this is the info box that shows the element type (like div/image etc), css class, dimensions, etc.
1212
const infoBoxStyles = require("text!./browser-css/info-box.css");
1313
// this is the rulers and guidelines feature
1414
const rulerStyles = require("text!./browser-css/rulers.css");

src/extensionsIntegrated/phoenix-pro/unit-tests/LivePreviewEdit-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ define(function (require, exports, module) {
268268
const shadowHosts = Array.from(document.body.children).filter(el => el.shadowRoot);
269269
let hasInfoBox = false;
270270
shadowHosts.forEach(host => {
271-
if (host.shadowRoot && host.shadowRoot.innerHTML.includes('phoenix-node-info-box')) {
271+
if (host.shadowRoot && host.shadowRoot.innerHTML.includes('phoenix-info-box')) {
272272
hasInfoBox = true;
273273
}
274274
});
@@ -311,7 +311,7 @@ define(function (require, exports, module) {
311311
const shadowHosts = Array.from(document.body.children).filter(el => el.shadowRoot);
312312
for (const host of shadowHosts) {
313313
const shadow = host.shadowRoot;
314-
const el = shadow.querySelector('.phoenix-node-info-box');
314+
const el = shadow.querySelector('.phoenix-info-box');
315315
const el2 = shadow.querySelector('.phoenix-more-options-box');
316316
if (!el && !el2) {
317317
return true;

0 commit comments

Comments
 (0)