From 3e9480a3faee0df50aace58e515f869751beb04b Mon Sep 17 00:00:00 2001 From: Darshan Date: Wed, 24 Sep 2025 18:39:10 +0530 Subject: [PATCH] fic: notification spacing on phone. --- .../project-[region]-[project]/+layout.svelte | 5 + .../(suggestions)/empty.svelte | 260 ++++++++++-------- .../(suggestions)/options.svelte | 41 ++- .../table-[table]/layout/sidesheet.svelte | 2 +- 4 files changed, 189 insertions(+), 119 deletions(-) diff --git a/src/routes/(console)/project-[region]-[project]/+layout.svelte b/src/routes/(console)/project-[region]-[project]/+layout.svelte index a7679879d..f233956c0 100644 --- a/src/routes/(console)/project-[region]-[project]/+layout.svelte +++ b/src/routes/(console)/project-[region]-[project]/+layout.svelte @@ -140,6 +140,11 @@ .layout-level-progress-bars { width: 100%; align-items: center; + box-sizing: border-box; + } + + :global(main:has([data-side-sheet-visible='true']) .layout-level-progress-bars) { + visibility: hidden; } } diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte index bcbeacf20..d1c79f638 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte @@ -103,7 +103,6 @@ // hook the actual horizontal scroller once if (!hScroller || !hScroller.isConnected) { - // TODO: @itznotabug, might not need this. check later. const previousScrollLeft = hScroller?.scrollLeft || 0; hScroller = findHorizontalScroller(headerElement); if (hScroller) { @@ -205,6 +204,32 @@ spreadsheetContainer.style.setProperty('--group-width', `${width + 2}px`); }; + // only for mobile, we can remove if not needed! + const scrollToFirstCustomColumn = () => { + if (!$isSmallViewport || customColumns.length === 0) return; + + if (!headerElement || !headerElement.isConnected) { + headerElement = spreadsheetContainer.querySelector('[role="rowheader"]'); + } + + if (!headerElement) return; + + const firstCustomColumnCell = headerElement.querySelector( + `[role="cell"][data-header="true"][data-column-id="${customColumns[0]?.key}"]` + ); + + if (firstCustomColumnCell && hScroller) { + const cellRect = firstCustomColumnCell.getBoundingClientRect(); + const scrollerRect = hScroller.getBoundingClientRect(); + const scrollLeft = hScroller.scrollLeft + cellRect.left - scrollerRect.left - 40; + + hScroller.scrollTo({ + left: Math.max(0, scrollLeft), + behavior: 'smooth' + }); + } + }; + const recalcAll = () => { updateOverlayHeight(); updateOverlayBounds(); @@ -301,7 +326,7 @@ $tableColumnSuggestions.thinking = true; try { - await sleep(5000); + await sleep(1250); const suggestedColumns = isDev ? mockSuggestions : ((await sdk @@ -325,6 +350,8 @@ // Set hasTransitioned to disable future animations after initial state change if (customColumns.length > 0) { setTimeout(() => (hasTransitioned = true), 300); // After transition completes + + setTimeout(() => scrollToFirstCustomColumn(), 100); } } catch (error) { addNotification({ @@ -343,6 +370,10 @@ function onPopoverShowStateChanged(value: boolean) { showFloatingBar = !value; + if ($isSmallViewport && rangeOverlayEl) { + rangeOverlayEl.style.opacity = value ? '0' : '1'; + } + const currentScrollLeft = hScroller?.scrollLeft || 0; tick().then(() => { @@ -502,6 +533,10 @@ cancelAnimationFrame(scrollAnimationFrame); } }); + + function isCustomColumn(id: string) { + return !['$id', '$createdAt', '$updatedAt', 'actions'].includes(id); + } @@ -520,67 +555,6 @@ class:thinking={$tableColumnSuggestions.thinking} class:no-transition={hasTransitioned && customColumns.length > 0}> - - {#if $tableColumnSuggestions.thinking} -
- - - - - - Thinking of column suggestions - - - - - { - $tableColumnSuggestions.context = null; - $tableColumnSuggestions.enabled = false; - $tableColumnSuggestions.thinking = false; - }} - >Cancel - - - -
- {:else if customColumns.length > 0 && showFloatingBar} -
- - - {#if creatingColumns} - - {/if} - - - {creatingColumns - ? 'Creating columns...' - : $isSmallViewport - ? 'Review and edit columns' - : 'Review and edit suggested columns before applying'} - - - - - {#if !creatingColumns} - - (confirmDismiss = true)} - >Dismiss - - Apply - - - {/if} - - -
- {/if} @@ -592,6 +566,7 @@ bottomActionClick={() => {}}> {#each spreadsheetColumns as column, index (index)} + {@const isColumnInteractable = isCustomColumn(column.id)} {#if column.isAction} @@ -607,12 +582,18 @@ ? '--non-overlay-icon-color' : '--overlay-icon-color'} - + {#snippet children(toggle)} + on:contextmenu={(event) => { + if (isColumnInteractable) { + toggle(event); + } + }}> + disabled={!isColumnInteractable} + on:click={(event) => { + if (isColumnInteractable) { + toggle(event); + } + }}> - - - + + - { - const newOption = columnOptions.find( - (opt) => opt.name === e.detail - ); - if (newOption) { - updateColumn(column.id, { - type: newOption.type, - format: newOption.format || null - }); - } - }} - options={basicColumnOptions.map((col) => { - return { - label: col.name, - value: col.name, - leadingIcon: col.icon - }; - })} /> - + { + const newOption = columnOptions.find( + (opt) => opt.name === e.detail + ); + if (newOption) { + updateColumn(column.id, { + type: newOption.type, + format: newOption.format || null + }); + } + }} + options={basicColumnOptions.map((col) => { + return { + label: col.name, + value: col.name, + leadingIcon: col.icon + }; + })} /> + {#if ColumnComponent} {/if} @@ -749,8 +735,70 @@
+ style="height: var(--overlay-height);" + style:opacity={showFloatingBar ? '1' : '0'}>
+ + {#if $tableColumnSuggestions.thinking} +
+ + + + + + Thinking of column suggestions + + + + + { + $tableColumnSuggestions.context = null; + $tableColumnSuggestions.enabled = false; + $tableColumnSuggestions.thinking = false; + }} + >Cancel + + + +
+ {:else if customColumns.length > 0 && showFloatingBar} +
+ + + {#if creatingColumns} + + {/if} + + + {creatingColumns + ? 'Creating columns...' + : $isSmallViewport + ? 'Review and edit columns' + : 'Review and edit suggested columns before applying'} + + + + + {#if !creatingColumns} + + (confirmDismiss = true)} + >Dismiss + + Apply + + + {/if} + + +
+ {/if} void]>; tooltipChildren: Snippet<[toggle: (event: Event) => void]>; - toggleOnTapClick: boolean; + toggleOnTapClick?: boolean; onShowStateChanged?: (showing: boolean) => void; + enabled?: boolean; } = $props(); + + let showSheet = $state(false); + + $effect(() => { + if (!$isSmallViewport) { + showSheet = false; + } + }); - - {onShowStateChanged?.(showing)} + + {onShowStateChanged?.(showing || showSheet)} {#if toggleOnTapClick && $isSmallViewport} - {:else} - {@render children(toggle)} + {/if} -
+
{@render tooltipChildren(toggle)}
+ +{#if $isSmallViewport} + { + showSheet = false; + } + }}> + {@render tooltipChildren(() => (showSheet = false))} + +{/if} diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/layout/sidesheet.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/layout/sidesheet.svelte index 816c51d65..68b981d3a 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/layout/sidesheet.svelte +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/layout/sidesheet.svelte @@ -46,7 +46,7 @@ let copyText = $state(undefined); -
+