fix, style: static footer size
ci/woodpecker/push/woodpecker Pipeline was successful Details

feat/type-attributes
Tomáš Mládek 2023-08-26 15:12:22 +02:00
parent ef7be5c314
commit e6b3916180
1 changed files with 12 additions and 48 deletions

View File

@ -1,59 +1,22 @@
<script lang="ts"> <script lang="ts">
import { createEventDispatcher, onMount } from "svelte"; import Icon from "../utils/Icon.svelte"
import IconButton from "../utils/IconButton.svelte";
import Jobs from "./Jobs.svelte"; import Jobs from "./Jobs.svelte";
import Notifications from "./Notifications.svelte"; import Notifications from "./Notifications.svelte";
import { i18n } from "../../i18n"; import { i18n } from "../../i18n";
const dispatch = createEventDispatcher();
let rootEl: HTMLElement;
let contentEl: HTMLElement;
let contentHeight = 0;
let hidden = true; let hidden = true;
let activeJobs: number; let activeJobs: number;
onMount(() => { let infoHeight = -1;
const rootObserver = new ResizeObserver((entries) => {
// should be only one
entries.forEach((entry) => {
dispatch("resize", entry.contentRect.height);
});
});
rootObserver.observe(rootEl);
const contentObserver = new ResizeObserver((entries) => {
entries.forEach((entry) => {
contentHeight = entry.contentRect.height;
});
});
contentObserver.observe(contentEl);
rootEl.style.top = `${rootEl.getBoundingClientRect().top}px`;
});
function toggleHidden() {
if (hidden) {
rootEl.style.top = "unset";
}
hidden = !hidden;
}
function onTransitionEnd(ev: TransitionEvent) {
if (ev.propertyName === "bottom" && hidden) {
rootEl.style.top = `${rootEl.getBoundingClientRect().top}px`;
}
}
</script> </script>
<footer <footer
id="footer" id="footer"
bind:this={rootEl}
class:hidden class:hidden
style="--contentHeight: {contentHeight}px" style="--info-height: -{infoHeight}px"
on:transitionend={onTransitionEnd}
> >
<div class="status"> <!-- svelte-ignore a11y-click-events-have-key-events -->
<div class="status" bind:clientHeight={infoHeight} on:click={() => hidden = !hidden}>
<div class="info"> <div class="info">
{#if activeJobs > 0} {#if activeJobs > 0}
{$i18n.t("Active jobs:")} {activeJobs} {$i18n.t("Active jobs:")} {activeJobs}
@ -62,15 +25,12 @@
{/if} {/if}
</div> </div>
<div class="icons"> <div class="icons">
{#if contentHeight > 0} <Icon
<IconButton
name="{hidden ? 'up' : 'down'}-arrow" name="{hidden ? 'up' : 'down'}-arrow"
on:click={toggleHidden}
/> />
{/if}
</div> </div>
</div> </div>
<div class="content" bind:this={contentEl}> <div class="content">
<Notifications /> <Notifications />
<Jobs bind:active={activeJobs} /> <Jobs bind:active={activeJobs} />
</div> </div>
@ -90,7 +50,7 @@
} }
footer.hidden { footer.hidden {
bottom: calc(var(--contentHeight) * -1); bottom: -20vh;
} }
.status { .status {
@ -102,6 +62,8 @@
top: 0; top: 0;
width: 100%; width: 100%;
cursor: pointer;
.info { .info {
flex-grow: 1; flex-grow: 1;
opacity: 0.75; opacity: 0.75;
@ -110,6 +72,8 @@
.content { .content {
margin-top: 2em; margin-top: 2em;
overflow-y: scroll;
height: 20vh;
} }
:global(#footer .content > *) { :global(#footer .content > *) {