Skip to content

Commit 90a34c2

Browse files
committed
feat: also show elements dimensions in info box
1 parent e74e07c commit 90a34c2

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1744,8 +1744,19 @@ function RemoteFunctions(config = {}) {
17441744
const id = this.element.id;
17451745
const classes = Array.from(this.element.classList || []);
17461746

1747+
// get the dimensions of the element
1748+
const elemBounds = this.element.getBoundingClientRect();
1749+
// we only show integers, because showing decimal places will take up a lot more space
1750+
const elemWidth = Math.round(elemBounds.width);
1751+
const elemHeight = Math.round(elemBounds.height);
1752+
17471753
let content = ""; // this will hold the main content that will be displayed
1748-
content += "<div class='tag-name'>" + this.element.tagName.toLowerCase() + "</div>"; // add element tag name
1754+
1755+
// add the tag name and dimensions in the same line
1756+
content += "<div class='tag-line'>";
1757+
content += "<span class='tag-name'>" + this.element.tagName.toLowerCase() + "</span>";
1758+
content += `<span class='elem-dimensions'>${elemWidth} × ${elemHeight}</span>`;
1759+
content += "</div>";
17491760

17501761
// Add ID if present
17511762
if (id) {
@@ -1792,10 +1803,24 @@ function RemoteFunctions(config = {}) {
17921803
pointer-events: none !important;
17931804
}
17941805
1806+
.tag-line {
1807+
display: flex !important;
1808+
align-items: baseline !important;
1809+
justify-content: space-between !important;
1810+
}
1811+
17951812
.tag-name {
17961813
font-weight: bold !important;
17971814
}
17981815
1816+
.elem-dimensions {
1817+
font-size: 9px !important;
1818+
font-weight: 500 !important;
1819+
opacity: 0.9 !important;
1820+
margin-left: 7px !important;
1821+
flex-shrink: 0 !important;
1822+
}
1823+
17991824
.id-name,
18001825
.class-name {
18011826
margin-top: 3px !important;

0 commit comments

Comments
 (0)