update: improved logic.

This commit is contained in:
Darshan committed 2025-11-26 14:41:13 +05:30
1 parent 9c9d5b7be6
commit 57af06a9fe
6 files changed
+22 -25

No files matched your search

@@ -5,7 +5,6 @@
import { IconX } from '@appwrite.io/pink-icons-svelte';
import { isTabletViewport } from '$lib/stores/viewport';
import PinkBackground from '$lib/images/pink-background.svg';
import { bannerSpacing } from '$lib/layout/headerAlert.svelte';
import { createEventDispatcher, onMount, onDestroy } from 'svelte';
import { headerAlert } from '$lib/stores/headerAlert';
import { ProfileMode, resolvedProfile } from '$lib/profiles/index.svelte';
@@ -37,7 +36,6 @@
sidebar.style.height = `calc(100vh - ${offset}px)`;
// for sidebar and sub-navigation!
bannerSpacing.set(`${alertHeight}px`);
headerAlert.setTopSpacing(alertHeight);
}
@@ -46,7 +44,7 @@
}
if (contentDiv && resolvedProfile.id === ProfileMode.STUDIO) {
const headerHeight = header?.getBoundingClientRect().height ?? 0;
const headerHeight = header?.getBoundingClientRect().height ?? 48;
// push the content enough to show the borders of the content view!
contentDiv.style.marginBlockStart = `${alertHeight + headerHeight}px`;
}
+2 -2
View File
@@ -57,7 +57,7 @@
import type { Models } from '@appwrite.io/console';
import { organization } from '$lib/stores/organization';
import { resolvedProfile } from '$lib/profiles/index.svelte';
import { bannerSpacing } from '$lib/layout/headerAlert.svelte';
import { headerAlert } from '$lib/stores/headerAlert';
let showSupport = false;
@@ -121,7 +121,7 @@
beforeNavigate(() => (showAccountMenu = false));
</script>
<Navbar.Base --border-width-s="none" style="top: {$bannerSpacing || '0px'};">
<Navbar.Base --border-width-s="none" style="top: {$headerAlert.top}px;">
<div slot="left" class="left">
<div class="only-mobile-tablet">
<button
+5 -5
View File
@@ -37,12 +37,12 @@
import { getSidebarState, isInDatabasesRoute, updateSidebarState } from '$lib/helpers/sidebar';
import { isSmallViewport, isTabletViewport } from '$lib/stores/viewport';
import { Click, trackEvent } from '$lib/actions/analytics';
import { bannerSpacing } from '$lib/layout/headerAlert.svelte';
import type { HTMLAttributes } from 'svelte/elements';
import type { Models } from '@appwrite.io/console';
import { noWidthTransition } from '$lib/stores/sidebar';
import { base } from '$app/paths';
import type { Models } from '@appwrite.io/console';
import type { HTMLAttributes } from 'svelte/elements';
import { headerAlert } from '$lib/stores/headerAlert';
import { noWidthTransition } from '$lib/stores/sidebar';
import { ProfileMode, resolvedProfile } from '$lib/profiles/index.svelte';
type Props = HTMLAttributes<HTMLElement> & {
@@ -399,7 +399,7 @@
</Sidebar.Base>
</div>
<div style:--banner-spacing={$bannerSpacing ? $bannerSpacing : undefined}>
<div style:--banner-spacing={$headerAlert.top ? `${$headerAlert.top}px` : undefined}>
{#if subNavigation}
{@const SubNavigation = subNavigation}
<div
+1 -10
View File
@@ -1,10 +1,3 @@
<script module lang="ts">
import { writable } from 'svelte/store';
// this is for backwards compatibility rn.
export const bannerSpacing = writable<string | null>(null);
</script>
<script lang="ts">
import { onDestroy, onMount } from 'svelte';
import { isTabletViewport } from '$lib/stores/viewport';
@@ -38,10 +31,8 @@
if (alertHeight) {
// for sidebar and sub-navigation!
bannerSpacing.set(`${alertHeight}px`);
headerAlert.setTopSpacing(alertHeight);
} else {
bannerSpacing.set(undefined);
headerAlert.setTopSpacing(0);
}
@@ -62,7 +53,7 @@
}
if (contentDiv && resolvedProfile.id === ProfileMode.STUDIO) {
const headerHeight = header?.getBoundingClientRect().height ?? 0;
const headerHeight = header?.getBoundingClientRect().height ?? 48;
// push the content enough to show the borders of the content view!
contentDiv.style.marginBlockStart = `${alertHeight + headerHeight}px`;
}
+10 -2
View File
@@ -1,5 +1,5 @@
import type { Component } from 'svelte';
import { writable } from 'svelte/store';
import { writable, type Readable } from 'svelte/store';
export type HeaderAlert = {
id: string;
@@ -13,7 +13,15 @@ export type HeaderAlertStore = {
components: HeaderAlert[];
};
function createHeaderAlertStore() {
export type HeaderAlertStoreType = Readable<HeaderAlertStore> & {
set: (value: HeaderAlertStore) => void;
add: (component: HeaderAlert) => void;
get: () => HeaderAlert;
setTopSpacing: (value: number) => void;
getTopSpacing: () => number;
};
function createHeaderAlertStore(): HeaderAlertStoreType {
const { set, update, subscribe } = writable<HeaderAlertStore>({
top: 0,
components: []
@@ -3,7 +3,6 @@
import { page } from '$app/state';
import type { PageData } from './$types';
import { showSubNavigation } from '$lib/stores/layout';
import { bannerSpacing } from '$lib/layout/headerAlert.svelte';
import { showCreateTable, databaseSubNavigationItems } from './store';
import {
@@ -28,6 +27,7 @@
import { sdk } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import { subNavigation } from '$lib/stores/database';
import { headerAlert } from '$lib/stores/headerAlert';
const data = $derived(page.data) as PageData;
@@ -58,8 +58,8 @@
// If banner open, adjust bottom position to account for banner container.
// 70.5px is the size of the container of the banner holder and not just the banner!
// Needed because things vary a bit much on how different browsers treat bottom layouts.
const bottomNavOffset = $derived($bannerSpacing ? '70.5px' : '0px');
const tableContentPadding = $derived($bannerSpacing ? '210px' : '140px');
const bottomNavOffset = $derived($headerAlert.top !== 0 ? '70.5px' : '0px');
const tableContentPadding = $derived($headerAlert.top !== 0 ? '210px' : '140px');
async function loadTables() {
tables = await sdk.forProject(region, project).tablesDB.listTables({