mirror of
https://github.com/wukko/cobalt.git
synced 2025-05-01 06:44:24 +02:00
web/PopoverContainer: refactor & simplify code
why the fuck was it that way in the first place
This commit is contained in:
parent
3935396709
commit
714e71751e
@ -1,22 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let id = "";
|
export let id = "";
|
||||||
export let expanded = false;
|
export let expanded = false;
|
||||||
export let popoverAction: () => void;
|
|
||||||
export let expandStart: "left" | "center" | "right" = "center";
|
export let expandStart: "left" | "center" | "right" = "center";
|
||||||
|
|
||||||
|
/*
|
||||||
|
a popover isn't pre-rendered by default, because the user might never open it.
|
||||||
|
but if they do, we render only once, and then keep it the dom :3
|
||||||
|
*/
|
||||||
|
|
||||||
$: renderPopover = false;
|
$: renderPopover = false;
|
||||||
|
$: if (expanded && !renderPopover) renderPopover = true;
|
||||||
export const showPopover = async () => {
|
|
||||||
const timeout = !renderPopover;
|
|
||||||
renderPopover = true;
|
|
||||||
|
|
||||||
// 10ms delay to let the popover render for the first time
|
|
||||||
if (timeout) {
|
|
||||||
setTimeout(popoverAction, 10);
|
|
||||||
} else {
|
|
||||||
popoverAction();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div {id} class="popover {expandStart}" aria-hidden={!expanded} class:expanded>
|
<div {id} class="popover {expandStart}" aria-hidden={!expanded} class:expanded>
|
||||||
|
@ -47,11 +47,14 @@
|
|||||||
|
|
||||||
$: indeterminate = queue.length > 0 && totalProgress === 0;
|
$: indeterminate = queue.length > 0 && totalProgress === 0;
|
||||||
|
|
||||||
const popoverAction = async () => {
|
const popoverAction = () => {
|
||||||
expanded = !expanded;
|
expanded = !expanded;
|
||||||
if (expanded) updateQuota();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$: if (expanded) {
|
||||||
|
updateQuota();
|
||||||
|
}
|
||||||
|
|
||||||
onNavigate(() => {
|
onNavigate(() => {
|
||||||
expanded = false;
|
expanded = false;
|
||||||
});
|
});
|
||||||
@ -59,21 +62,20 @@
|
|||||||
onMount(() => {
|
onMount(() => {
|
||||||
// clear old files from storage on first page load
|
// clear old files from storage on first page load
|
||||||
clearFileStorage();
|
clearFileStorage();
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div id="processing-queue" class:expanded>
|
<div id="processing-queue" class:expanded>
|
||||||
<ProcessingStatus
|
<ProcessingStatus
|
||||||
progress={totalProgress * 100}
|
progress={totalProgress * 100}
|
||||||
{indeterminate}
|
{indeterminate}
|
||||||
expandAction={popover?.showPopover}
|
expandAction={popoverAction}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<PopoverContainer
|
<PopoverContainer
|
||||||
bind:this={popover}
|
bind:this={popover}
|
||||||
id="processing-popover"
|
id="processing-popover"
|
||||||
{expanded}
|
{expanded}
|
||||||
{popoverAction}
|
|
||||||
expandStart="right"
|
expandStart="right"
|
||||||
>
|
>
|
||||||
<div id="processing-header">
|
<div id="processing-header">
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
<button
|
<button
|
||||||
id="services-button"
|
id="services-button"
|
||||||
class="button"
|
class="button"
|
||||||
on:click={popover?.showPopover}
|
on:click={popoverAction}
|
||||||
aria-label={$t(`save.services.title_${expanded ? "hide" : "show"}`)}
|
aria-label={$t(`save.services.title_${expanded ? "hide" : "show"}`)}
|
||||||
>
|
>
|
||||||
<div class="expand-icon">
|
<div class="expand-icon">
|
||||||
@ -54,7 +54,6 @@
|
|||||||
bind:this={popover}
|
bind:this={popover}
|
||||||
id="services-popover"
|
id="services-popover"
|
||||||
{expanded}
|
{expanded}
|
||||||
{popoverAction}
|
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
id="services-container"
|
id="services-container"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user