Add support for new "disabled" derived var

This commit is contained in:
Realmy 2024-11-12 13:15:33 +01:00
commit 71736035f6
1 changed files with 5 additions and 7 deletions

View File

@ -20,6 +20,8 @@
let converter = $derived(converters.find((c) => c.name === converterName))!; let converter = $derived(converters.find((c) => c.name === converterName))!;
let disabled = $derived(files.files.some((f) => !f.result));
onMount(() => { onMount(() => {
finisheds.forEach((_, i) => { finisheds.forEach((_, i) => {
const duration = 750 + i * 50 - 32; const duration = 750 + i * 50 - 32;
@ -198,19 +200,15 @@
<button <button
onclick={convertAll} onclick={convertAll}
class={clsx("btn flex-grow", { class={clsx("btn flex-grow", {
"btn-highlight": !files.files.find((i) => i.result), "btn-highlight": disabled,
})} })}
>Convert{files.files.length > 1 ? " All" : ""}</button >Convert{files.files.length > 1 ? " All" : ""}</button
> >
<button <button
onclick={() => downloadAll} onclick={() => downloadAll}
class={clsx("btn flex-grow", { class={clsx("btn flex-grow", {
"opacity-50 pointer-events-none": files.files.find( "opacity-50 pointer-events-none": disabled,
(i) => !i.result, "btn-highlight": !disabled,
),
"btn-highlight": !files.files.find(
(i) => !i.result,
),
})} })}
>Download{files.files.length > 1 ? " All" : ""}</button >Download{files.files.length > 1 ? " All" : ""}</button
> >