mirror of
https://github.com/wukko/cobalt.git
synced 2025-04-29 22:14:26 +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">
|
||||
export let id = "";
|
||||
export let expanded = false;
|
||||
export let popoverAction: () => void;
|
||||
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;
|
||||
|
||||
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();
|
||||
}
|
||||
};
|
||||
$: if (expanded && !renderPopover) renderPopover = true;
|
||||
</script>
|
||||
|
||||
<div {id} class="popover {expandStart}" aria-hidden={!expanded} class:expanded>
|
||||
|
@ -47,11 +47,14 @@
|
||||
|
||||
$: indeterminate = queue.length > 0 && totalProgress === 0;
|
||||
|
||||
const popoverAction = async () => {
|
||||
const popoverAction = () => {
|
||||
expanded = !expanded;
|
||||
if (expanded) updateQuota();
|
||||
};
|
||||
|
||||
$: if (expanded) {
|
||||
updateQuota();
|
||||
}
|
||||
|
||||
onNavigate(() => {
|
||||
expanded = false;
|
||||
});
|
||||
@ -59,21 +62,20 @@
|
||||
onMount(() => {
|
||||
// clear old files from storage on first page load
|
||||
clearFileStorage();
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
<div id="processing-queue" class:expanded>
|
||||
<ProcessingStatus
|
||||
progress={totalProgress * 100}
|
||||
{indeterminate}
|
||||
expandAction={popover?.showPopover}
|
||||
expandAction={popoverAction}
|
||||
/>
|
||||
|
||||
<PopoverContainer
|
||||
bind:this={popover}
|
||||
id="processing-popover"
|
||||
{expanded}
|
||||
{popoverAction}
|
||||
expandStart="right"
|
||||
>
|
||||
<div id="processing-header">
|
||||
|
@ -41,7 +41,7 @@
|
||||
<button
|
||||
id="services-button"
|
||||
class="button"
|
||||
on:click={popover?.showPopover}
|
||||
on:click={popoverAction}
|
||||
aria-label={$t(`save.services.title_${expanded ? "hide" : "show"}`)}
|
||||
>
|
||||
<div class="expand-icon">
|
||||
@ -54,7 +54,6 @@
|
||||
bind:this={popover}
|
||||
id="services-popover"
|
||||
{expanded}
|
||||
{popoverAction}
|
||||
>
|
||||
<div
|
||||
id="services-container"
|
||||
|
Loading…
x
Reference in New Issue
Block a user