Skip to content

Commit 49535c6

Browse files
committed
fix: onboarding card positioned to the right of sidebar items
1 parent 7814274 commit 49535c6

2 files changed

Lines changed: 37 additions & 16 deletions

File tree

public/css/style.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4500,6 +4500,17 @@ tbody tr:hover {
45004500
border-bottom: none;
45014501
}
45024502

4503+
.onboarding-card .card-arrow.left {
4504+
left: -8px;
4505+
top: 50%;
4506+
margin-top: -7px;
4507+
transform: rotate(-45deg);
4508+
border-left-color: var(--border);
4509+
border-top-color: var(--border);
4510+
border-right: none;
4511+
border-bottom: none;
4512+
}
4513+
45034514
.onboarding-card h2 {
45044515
font-size: 1.3rem;
45054516
font-weight: 700;

public/js/app.js

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4112,28 +4112,38 @@ function positionOnboardingCard(selector) {
41124112
arrow.className = 'card-arrow';
41134113
card.appendChild(arrow);
41144114

4115-
let top, arrowDir;
4116-
4117-
// Try below first
4118-
const spaceBelow = window.innerHeight - elRect.bottom;
4119-
const spaceAbove = elRect.top;
4115+
let top, left, arrowDir;
41204116
const approxCardH = Math.min(360, cardMaxH);
41214117

4122-
if (spaceBelow >= approxCardH + gap + 20) {
4123-
top = elRect.bottom + gap;
4124-
arrowDir = 'up';
4125-
} else if (spaceAbove >= approxCardH + gap + 20) {
4126-
top = elRect.top - gap - approxCardH;
4127-
arrowDir = 'down';
4118+
// Try right first (sidebar items are on the left)
4119+
const spaceRight = window.innerWidth - elRect.right;
4120+
if (spaceRight >= cardW + gap + 30) {
4121+
left = elRect.right + gap;
4122+
top = elRect.top + elRect.height / 2 - approxCardH / 2;
4123+
arrowDir = 'left';
41284124
} else {
4129-
// Center as fallback
4130-
top = Math.max(20, (window.innerHeight - approxCardH) / 2);
4131-
arrowDir = null;
4125+
// Try below
4126+
const spaceBelow = window.innerHeight - elRect.bottom;
4127+
const spaceAbove = elRect.top;
4128+
if (spaceBelow >= approxCardH + gap + 20) {
4129+
top = elRect.bottom + gap;
4130+
left = elRect.left + elRect.width / 2 - cardW / 2;
4131+
arrowDir = 'up';
4132+
} else if (spaceAbove >= approxCardH + gap + 20) {
4133+
top = elRect.top - gap - approxCardH;
4134+
left = elRect.left + elRect.width / 2 - cardW / 2;
4135+
arrowDir = 'down';
4136+
} else {
4137+
// Center as fallback
4138+
top = Math.max(20, (window.innerHeight - approxCardH) / 2);
4139+
left = Math.max(16, (window.innerWidth - cardW) / 2);
4140+
arrowDir = null;
4141+
}
41324142
}
41334143

4134-
// Center card horizontally under the element, but clamp to viewport
4135-
let left = elRect.left + elRect.width / 2 - cardW / 2;
4144+
// Clamp to viewport
41364145
left = Math.max(16, Math.min(left, window.innerWidth - cardW - 16));
4146+
top = Math.max(16, Math.min(top, window.innerHeight - approxCardH - 16));
41374147

41384148
top = Math.max(16, Math.min(top, window.innerHeight - approxCardH - 16));
41394149

0 commit comments

Comments
 (0)