Fix position of alert

This commit is contained in:
ernstmul committed 2025-03-10 14:07:05 +01:00
1 parent 0411af7d49
commit 39ee6ad5bf
2 files changed
+46 -4

No files matched your search

+32 -1
View File
@@ -1,9 +1,37 @@
<script lang="ts">
import { onDestroy, onMount } from 'svelte';
import { isTabletViewport } from '$lib/stores/viewport';
export let title: string;
export let type: 'info' | 'success' | 'warning' | 'error' | 'default' = 'info';
let container;
function setNavigationHeight() {
const alertHeight = container ? container.getBoundingClientRect().height : 0;
const header: HTMLHeadingElement = document.querySelector('main > header');
const sidebar: HTMLElement = document.querySelector('main > div > nav');
if (header) {
header.style.top = `${alertHeight}px`;
}
if (sidebar) {
sidebar.style.top = `${alertHeight + ($isTabletViewport ? 0 : header.getBoundingClientRect().height)}px`;
}
}
onMount(() => {
setNavigationHeight();
});
onDestroy(() => {
container = null;
setNavigationHeight();
});
</script>
<svelte:window on:resize={setNavigationHeight} />
<section
bind:this={container}
class="alert is-action is-action-and-top-sticky u-sep-block-end"
class:is-success={type === 'success'}
class:is-warning={type === 'warning'}
@@ -40,7 +68,10 @@
<style>
.alert {
padding: 1rem 1rem 0.75rem 1.5rem;
margin-block-start: 18px;
position: absolute;
top: 0;
width: 100%;
z-index: 100;
}
.alert-content {
+14 -3
View File
@@ -134,7 +134,11 @@
<svelte:window on:resize={handleResize} />
<svelte:body use:style={$bodyStyle} />
{#if $activeHeaderAlert?.show}
<svelte:component this={$activeHeaderAlert.component} />
{/if}
<main
class:has-alert={$activeHeaderAlert?.show}
class:is-open={$showSubNavigation}
class:u-hide={$wizard.show || $log.show || $wizard.cover}
class:is-fixed-layout={$activeHeaderAlert?.show}
@@ -157,9 +161,6 @@
class:icons-content={state === 'icons'}
class:no-sidebar={!showSideNavigation}>
<section class="main-content" data-test={showSideNavigation}>
{#if $activeHeaderAlert?.show}
<svelte:component this={$activeHeaderAlert.component} />
{/if}
{#if $page.data?.header}
<svelte:component this={$page.data.header} />
{/if}
@@ -247,4 +248,14 @@
grid-template-columns: auto 1fr !important;
}
}
//
//:global(main.has-alert > header) {
// top: 70px;
//}
//:global(main.has-alert > div nav) {
// @media (min-width: 1024px) {
// top: calc(48px + 70px) !important;
// height: calc(100vh - (48px + 70px)) !important;
// }
//}
</style>