-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b67c52
commit 24cd5c0
Showing
6 changed files
with
87 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<script lang="ts"> | ||
import { maybe_global } from 'functional-utilities'; | ||
import { SvelteComponent, onMount, onDestroy } from 'svelte'; | ||
export let components: (typeof SvelteComponent<{}>)[]; | ||
export let active = 0; | ||
let elements: HTMLElement[] = []; | ||
let outer_ref: HTMLElement; | ||
let resizeObserver: ResizeObserver; | ||
function recalculate_size() { | ||
const { width, height } = elements.reduce( | ||
(acc, el) => { | ||
const { width, height } = el.getBoundingClientRect(); | ||
return { | ||
width: Math.max(acc.width, width), | ||
height: Math.max(acc.height, height) | ||
}; | ||
}, | ||
{ width: 0, height: 0 } | ||
); | ||
outer_ref.style.width = `${width}px`; | ||
outer_ref.style.height = `${height}px`; | ||
} | ||
function setupListeners() { | ||
resizeObserver = new ResizeObserver(() => { | ||
recalculate_size(); | ||
}); | ||
elements.forEach((el) => { | ||
resizeObserver.observe(el); | ||
}); | ||
maybe_global('window')?.addEventListener('resize', recalculate_size) | ||
} | ||
onMount(() => { | ||
setupListeners(); | ||
recalculate_size(); | ||
}); | ||
onDestroy(() => { | ||
if (resizeObserver) { | ||
resizeObserver.disconnect(); | ||
} | ||
maybe_global('window')?.removeEventListener('resize', recalculate_size); | ||
}); | ||
</script> | ||
|
||
<div class="outer" bind:this={outer_ref}> | ||
{#each components as component, i} | ||
<div class:active={i === active} class="inner" bind:this={elements[i]}> | ||
<svelte:component this={component} /> | ||
</div> | ||
{/each} | ||
</div> | ||
|
||
<style> | ||
.outer { | ||
position: relative; | ||
height: 845px; | ||
} | ||
.inner { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
visibility: hidden; | ||
} | ||
.inner.active { | ||
visibility: visible; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24cd5c0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
tagaro-tpanel – ./
tagaro-tpanel.vercel.app
tagaro-tpanel-jeremymoeglich.vercel.app
tagaro-tpanel-git-main-jeremymoeglich.vercel.app
admin.tagaro.de