Skip to content

Commit 199db6e

Browse files
best UI experience
1 parent db78359 commit 199db6e

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

src/lib/components/ModelDropdown.svelte

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import type { ModelInfo } from '$lib/types';
1111
1212
let isDropdownOpen = false;
13+
let buttonRef: HTMLButtonElement;
14+
let dropdownPosition = { top: 0, left: 0 };
1315
1416
// Filter models for mobile devices
1517
$: filteredModels = $availableModels.filter((model) => {
@@ -58,6 +60,14 @@
5860
console.log('Toggle dropdown clicked, current state:', isDropdownOpen);
5961
isDropdownOpen = !isDropdownOpen;
6062
console.log('New state:', isDropdownOpen);
63+
64+
if (isDropdownOpen && buttonRef) {
65+
const rect = buttonRef.getBoundingClientRect();
66+
dropdownPosition = {
67+
top: rect.bottom + 8,
68+
left: rect.right - 448 // 28rem = 448px
69+
};
70+
}
6171
}
6272
6373
// Close dropdown when clicking outside
@@ -78,6 +88,7 @@
7888
class:border-red-500={isDropdownOpen}
7989
>
8090
<button
91+
bind:this={buttonRef}
8192
class="btn btn-sm variant-ghost-surface flex items-center space-x-2"
8293
on:click={() => {
8394
console.log('Button click event fired');
@@ -96,7 +107,8 @@
96107

97108
{#if isDropdownOpen}
98109
<div
99-
class="absolute top-full right-0 mt-2 w-[28rem] bg-surface-100-800-token border border-surface-300-600-token rounded-lg shadow-xl z-[9999] max-h-[32rem] overflow-y-auto"
110+
class="fixed w-[28rem] bg-surface-100-800-token border border-surface-300-600-token rounded-lg shadow-xl max-h-[32rem] overflow-y-auto"
111+
style="z-index: 999999 !important; top: {dropdownPosition.top}px; left: {dropdownPosition.left}px;"
100112
>
101113
<div class="p-4 border-b border-surface-300-600-token">
102114
<h3 class="font-semibold text-lg text-surface-700-200-token">Select LLM Model</h3>

src/lib/components/RAGContext.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@
175175
{#if featureManager.isEnabled('clientSideRAG')}
176176
<!-- Debug: RAG Panel is rendering -->
177177
<div
178-
class="fixed top-16 right-0 bg-surface-100-800-token border-l border-surface-300-600-token p-4 w-80 flex flex-col shadow-lg z-40 transition-transform duration-300"
178+
class="fixed top-16 right-0 bg-surface-100-800-token border-l
179+
border-surface-300-600-token p-4 w-80 flex flex-col shadow-lg z-1
180+
transition-transform duration-300"
179181
class:translate-x-0={isVisible}
180182
class:translate-x-full={!isVisible}
181183
style="height: calc(100vh - 4rem);"

src/lib/components/ThemeSwitcher.svelte

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import type { Theme } from '$lib/types';
44
55
let isDropdownOpen = false;
6+
let buttonRef: HTMLButtonElement;
7+
let dropdownPosition = { top: 0, left: 0 };
68
79
const themes: { name: Theme; label: string; description: string; preview: string }[] = [
810
{
@@ -68,6 +70,14 @@
6870
console.log('Theme dropdown clicked, current state:', isDropdownOpen);
6971
isDropdownOpen = !isDropdownOpen;
7072
console.log('New theme dropdown state:', isDropdownOpen);
73+
74+
if (isDropdownOpen && buttonRef) {
75+
const rect = buttonRef.getBoundingClientRect();
76+
dropdownPosition = {
77+
top: rect.bottom + 8,
78+
left: rect.right - 320 // 20rem = 320px
79+
};
80+
}
7181
}
7282
7383
// Close dropdown when clicking outside
@@ -88,6 +98,7 @@
8898
class:border-blue-500={isDropdownOpen}
8999
>
90100
<button
101+
bind:this={buttonRef}
91102
class="btn btn-sm variant-ghost-surface flex items-center space-x-2"
92103
on:click={() => {
93104
console.log('Theme button click event fired');
@@ -111,7 +122,8 @@
111122

112123
{#if isDropdownOpen}
113124
<div
114-
class="absolute top-full right-0 mt-2 w-80 bg-surface-100-800-token border border-surface-300-600-token rounded-lg shadow-xl z-[9999] max-h-96 overflow-y-auto"
125+
class="fixed w-80 bg-surface-100-800-token border border-surface-300-600-token rounded-lg shadow-xl max-h-96 overflow-y-auto"
126+
style="z-index: 999999 !important; top: {dropdownPosition.top}px; left: {dropdownPosition.left}px;"
115127
>
116128
<div class="p-4 border-b border-surface-300-600-token">
117129
<h3 class="font-semibold text-lg text-surface-700-200-token">Choose Theme</h3>

0 commit comments

Comments
 (0)