Skip to content

Commit 7df2601

Browse files
committed
fix: ai box width set on smaller screens
1 parent 63ae9f8 commit 7df2601

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,25 +1562,16 @@ function RemoteFunctions(config) {
15621562
let topPos = offset.top - boxHeight - 6; // 6 for just some little space to breathe
15631563
let leftPos = offset.left + elemBounds.width - boxWidth;
15641564

1565-
// check if the box would go off the top of the viewport
1565+
// Check if the box would go off the top of the viewport
15661566
if (elemBounds.top - boxHeight < 6) {
15671567
topPos = offset.top + elemBounds.height + 6;
15681568
}
15691569

1570-
// check if the box would go off the left of the viewport
1571-
if (leftPos < 6) {
1570+
// Check if the box would go off the left of the viewport
1571+
if (leftPos < 0) {
15721572
leftPos = offset.left;
15731573
}
15741574

1575-
// check if the box would go off the right of the viewport
1576-
const viewportWidth = window.innerWidth;
1577-
if (leftPos + boxWidth > viewportWidth - 6) {
1578-
leftPos = viewportWidth - boxWidth - 6;
1579-
}
1580-
1581-
// ensure leftPos is never negative
1582-
leftPos = Math.max(6, leftPos);
1583-
15841575
return {topPos: topPos, leftPos: leftPos};
15851576
},
15861577

@@ -1594,14 +1585,23 @@ function RemoteFunctions(config) {
15941585
let boxWidth, boxHeight;
15951586

15961587
if (viewportWidth >= 400) {
1597-
boxWidth = Math.min(310, viewportWidth * 0.75); // Max 310px or 75% of viewport
1588+
boxWidth = Math.min(310, viewportWidth * 0.85);
15981589
boxHeight = 60;
1590+
} else if (viewportWidth >= 350) {
1591+
boxWidth = Math.min(275, viewportWidth * 0.85);
1592+
boxHeight = 70;
15991593
} else if (viewportWidth >= 300) {
1600-
boxWidth = Math.min(280, viewportWidth * 0.85); // Smaller width for medium screens
1601-
boxHeight = 80; // Increase height for better usability
1594+
boxWidth = Math.min(230, viewportWidth * 0.85);
1595+
boxHeight = 80;
1596+
} else if (viewportWidth >= 250) {
1597+
boxWidth = Math.min(180, viewportWidth * 0.85);
1598+
boxHeight = 100;
1599+
} else if (viewportWidth >= 200) {
1600+
boxWidth = Math.min(130, viewportWidth * 0.85);
1601+
boxHeight = 120;
16021602
} else {
1603-
boxWidth = Math.min(250, viewportWidth * 0.9); // Very narrow screens
1604-
boxHeight = 100; // Even more height for very small screens
1603+
boxWidth = Math.min(100, viewportWidth * 0.85);
1604+
boxHeight = 140;
16051605
}
16061606

16071607
const styles = `
@@ -1615,6 +1615,7 @@ function RemoteFunctions(config) {
16151615
z-index: 2147483647;
16161616
width: ${boxWidth}px;
16171617
padding: 0;
1618+
box-sizing: border-box;
16181619
}
16191620
16201621
.phoenix-ai-prompt-input-container {

0 commit comments

Comments
 (0)