From 03dcf812a59160abaef31bea6519a50716163321 Mon Sep 17 00:00:00 2001 From: Rotimi Best Date: Sun, 7 Jun 2026 23:21:19 +0100 Subject: [PATCH] feat: fit ai chat trigger to center of page - Updated the CSS classes for the AI assistant bar to adjust positioning based on the new side panel width variable. - Introduced a new `onWidthPreview` prop in the SidePanelRail component to handle live resizing and update the side panel width dynamically. - Added width state management in the SidePanelStore to ensure proper width handling during panel interactions. - Improved layout handling in the course layout component to accommodate the new side panel width adjustments. --- .../ai-assistant/content-ask-ai-bar.svelte | 4 +-- .../side-panel/side-panel-rail.svelte | 26 +++++++++++++------ .../features/side-panel/utils/store.svelte.ts | 2 ++ .../routes/(app)/courses/[id]/+layout.svelte | 8 ++++-- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/apps/dashboard/src/lib/features/ai-assistant/content-ask-ai-bar.svelte b/apps/dashboard/src/lib/features/ai-assistant/content-ask-ai-bar.svelte index 3d3fef5b..88b245fc 100644 --- a/apps/dashboard/src/lib/features/ai-assistant/content-ask-ai-bar.svelte +++ b/apps/dashboard/src/lib/features/ai-assistant/content-ask-ai-bar.svelte @@ -114,7 +114,7 @@ {#if expanded}
@@ -135,7 +135,7 @@
{:else}
diff --git a/apps/dashboard/src/lib/features/side-panel/side-panel-rail.svelte b/apps/dashboard/src/lib/features/side-panel/side-panel-rail.svelte index 9a86530a..1afcd227 100644 --- a/apps/dashboard/src/lib/features/side-panel/side-panel-rail.svelte +++ b/apps/dashboard/src/lib/features/side-panel/side-panel-rail.svelte @@ -5,7 +5,16 @@ import { t } from '$lib/utils/functions/translations'; import { sidePanel } from './utils/store.svelte'; - let railShellElement: HTMLDivElement | null = $state(null); + interface Props { + /** + * Live-resize hook. The host writes `--side-panel-width` directly to the + * shared shell element so the panel and fixed siblings (e.g. the Ask AI + * bar) follow the drag without a per-frame reactivity round-trip. + */ + onWidthPreview?: (width: number) => void; + } + + let { onWidthPreview }: Props = $props(); let railWidth = $state(0); let isWidthLoaded = $state(false); @@ -65,6 +74,12 @@ isWidthLoaded = true; }); + // Publish the effective width so the shared ancestor can expose it as a CSS + // variable that fixed siblings (e.g. the Ask AI bar) can offset against. + $effect(() => { + sidePanel.width = activeDefinition ? railWidth : 0; + }); + $effect(() => { if (!isWidthLoaded) return; @@ -100,7 +115,7 @@ startWidth, resolveWidth: ({ startWidth, deltaX }) => clampWidth(startWidth - deltaX), onPreview: (width) => { - railShellElement?.style.setProperty('--side-panel-width', `${width}px`); + onWidthPreview?.(width); }, onCommit: ({ width }) => { railWidth = width; @@ -129,12 +144,7 @@ {#if activeDefinition} {@const def = activeDefinition} -
+