Spaces:
Running on Zero
Running on Zero
Part 677: Fix dropdown positioning and add missing --panel CSS variable
Browse files- static/chat.html +19 -7
static/chat.html
CHANGED
|
@@ -14,7 +14,7 @@
|
|
| 14 |
|
| 15 |
/* ============ TOKENS ============ */
|
| 16 |
|
| 17 |
-
:root{
|
| 18 |
|
| 19 |
--bg:#ffffff;--bg-secondary:#f7f7f8;--bg-tertiary:#ececf1;
|
| 20 |
|
|
@@ -2635,7 +2635,7 @@ function chatItemEl(c){
|
|
| 2635 |
${pinnedChats.has(c.id) ? '<span style="font-size:10px;color:var(--accent);">PIN</span>' : ''}
|
| 2636 |
<div class="chat-menu-wrapper" style="position:relative;">
|
| 2637 |
<button class="icon-btn chat-menu-btn" title="More options" style="opacity:0;transition:opacity .15s;"><svg viewBox="0 0 24 24" fill="currentColor" style="width:14px;height:14px;"><circle cx="12" cy="5" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="12" cy="19" r="2"/></svg></button>
|
| 2638 |
-
<div class="chat-dropdown" style="display:none;background:
|
| 2639 |
<button class="chat-menu-item" data-action="rename" style="width:100%;text-align:left;padding:8px 12px;background:none;border:none;color:var(--text);cursor:pointer;font-size:12px;border-radius:4px;">Rename</button>
|
| 2640 |
<button class="chat-menu-item" data-action="pin" style="width:100%;text-align:left;padding:8px 12px;background:none;border:none;color:var(--text);cursor:pointer;font-size:12px;border-radius:4px;">${pinnedChats.has(c.id) ? 'Unpin' : 'Pin'}</button>
|
| 2641 |
<button class="chat-menu-item" data-action="share" style="width:100%;text-align:left;padding:8px 12px;background:none;border:none;color:var(--text);cursor:pointer;font-size:12px;border-radius:4px;">Share</button>
|
|
@@ -2656,17 +2656,29 @@ function chatItemEl(c){
|
|
| 2656 |
const isOpen = dropdown.style.display === 'block';
|
| 2657 |
document.querySelectorAll('.chat-dropdown').forEach(d => d.style.display = 'none');
|
| 2658 |
if (!isOpen) {
|
| 2659 |
-
const rect = menuBtn.getBoundingClientRect();
|
| 2660 |
dropdown.style.display = 'block';
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2661 |
const ddRect = dropdown.getBoundingClientRect();
|
| 2662 |
-
|
| 2663 |
-
let left = rect.right
|
| 2664 |
-
|
| 2665 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2666 |
dropdown.style.position = 'fixed';
|
| 2667 |
dropdown.style.top = top + 'px';
|
| 2668 |
dropdown.style.left = left + 'px';
|
| 2669 |
dropdown.style.right = 'auto';
|
|
|
|
| 2670 |
}
|
| 2671 |
menuBtn.style.opacity = '1';
|
| 2672 |
});
|
|
|
|
| 14 |
|
| 15 |
/* ============ TOKENS ============ */
|
| 16 |
|
| 17 |
+
:root{ --panel: #12161f; --border: #232a38;
|
| 18 |
|
| 19 |
--bg:#ffffff;--bg-secondary:#f7f7f8;--bg-tertiary:#ececf1;
|
| 20 |
|
|
|
|
| 2635 |
${pinnedChats.has(c.id) ? '<span style="font-size:10px;color:var(--accent);">PIN</span>' : ''}
|
| 2636 |
<div class="chat-menu-wrapper" style="position:relative;">
|
| 2637 |
<button class="icon-btn chat-menu-btn" title="More options" style="opacity:0;transition:opacity .15s;"><svg viewBox="0 0 24 24" fill="currentColor" style="width:14px;height:14px;"><circle cx="12" cy="5" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="12" cy="19" r="2"/></svg></button>
|
| 2638 |
+
<div class="chat-dropdown" style="display:none;background:#12161f;border:1px solid #232a38;border-radius:8px;padding:4px;min-width:160px;box-shadow:0 4px 12px rgba(0,0,0,0.3);">
|
| 2639 |
<button class="chat-menu-item" data-action="rename" style="width:100%;text-align:left;padding:8px 12px;background:none;border:none;color:var(--text);cursor:pointer;font-size:12px;border-radius:4px;">Rename</button>
|
| 2640 |
<button class="chat-menu-item" data-action="pin" style="width:100%;text-align:left;padding:8px 12px;background:none;border:none;color:var(--text);cursor:pointer;font-size:12px;border-radius:4px;">${pinnedChats.has(c.id) ? 'Unpin' : 'Pin'}</button>
|
| 2641 |
<button class="chat-menu-item" data-action="share" style="width:100%;text-align:left;padding:8px 12px;background:none;border:none;color:var(--text);cursor:pointer;font-size:12px;border-radius:4px;">Share</button>
|
|
|
|
| 2656 |
const isOpen = dropdown.style.display === 'block';
|
| 2657 |
document.querySelectorAll('.chat-dropdown').forEach(d => d.style.display = 'none');
|
| 2658 |
if (!isOpen) {
|
|
|
|
| 2659 |
dropdown.style.display = 'block';
|
| 2660 |
+
dropdown.style.visibility = 'hidden';
|
| 2661 |
+
// Force layout
|
| 2662 |
+
const _ = dropdown.offsetHeight;
|
| 2663 |
+
const rect = menuBtn.getBoundingClientRect();
|
| 2664 |
const ddRect = dropdown.getBoundingClientRect();
|
| 2665 |
+
// Position to the right of the button (over main content)
|
| 2666 |
+
let left = rect.right + 8;
|
| 2667 |
+
let top = rect.top;
|
| 2668 |
+
// If no room on right, place to the left
|
| 2669 |
+
if (left + ddRect.width > window.innerWidth - 8) {
|
| 2670 |
+
left = rect.left - ddRect.width - 8;
|
| 2671 |
+
}
|
| 2672 |
+
// Keep in viewport vertically
|
| 2673 |
+
if (top + ddRect.height > window.innerHeight - 8) {
|
| 2674 |
+
top = window.innerHeight - ddRect.height - 8;
|
| 2675 |
+
}
|
| 2676 |
+
if (top < 8) top = 8;
|
| 2677 |
dropdown.style.position = 'fixed';
|
| 2678 |
dropdown.style.top = top + 'px';
|
| 2679 |
dropdown.style.left = left + 'px';
|
| 2680 |
dropdown.style.right = 'auto';
|
| 2681 |
+
dropdown.style.visibility = 'visible';
|
| 2682 |
}
|
| 2683 |
menuBtn.style.opacity = '1';
|
| 2684 |
});
|