mirror of
https://github.com/thiloho/archtika.git
synced 2025-11-22 10:51:36 +01:00
Refactor web app code and add background color setting
This commit is contained in:
@@ -6,16 +6,15 @@
|
||||
import SuccessOrError from "$lib/components/SuccessOrError.svelte";
|
||||
import type { ActionData, PageServerData } from "./$types";
|
||||
import LoadingSpinner from "$lib/components/LoadingSpinner.svelte";
|
||||
import { enhanceForm } from "$lib/utils";
|
||||
import { sending } from "$lib/runes.svelte";
|
||||
|
||||
const { form, data }: { form: ActionData; data: PageServerData } = $props();
|
||||
|
||||
let sending = $state(false);
|
||||
let loadingDelay: number;
|
||||
</script>
|
||||
|
||||
<SuccessOrError success={form?.success} message={form?.message} />
|
||||
|
||||
{#if sending}
|
||||
{#if sending.value}
|
||||
<LoadingSpinner />
|
||||
{/if}
|
||||
|
||||
@@ -27,19 +26,7 @@
|
||||
<Modal id="create-website" text="Create website">
|
||||
<h3>Create website</h3>
|
||||
|
||||
<form
|
||||
method="POST"
|
||||
action="?/createWebsite"
|
||||
use:enhance={() => {
|
||||
loadingDelay = window.setTimeout(() => (sending = true), 500);
|
||||
return async ({ update }) => {
|
||||
await update();
|
||||
window.clearTimeout(loadingDelay);
|
||||
window.location.hash = "!";
|
||||
sending = false;
|
||||
};
|
||||
}}
|
||||
>
|
||||
<form method="POST" action="?/createWebsite" use:enhance={enhanceForm({ closeModal: true })}>
|
||||
<label>
|
||||
Type:
|
||||
<select name="content-type">
|
||||
@@ -121,15 +108,7 @@
|
||||
<form
|
||||
method="POST"
|
||||
action="?/updateWebsite"
|
||||
use:enhance={() => {
|
||||
loadingDelay = window.setTimeout(() => (sending = true), 500);
|
||||
return async ({ update }) => {
|
||||
await update({ reset: false });
|
||||
window.clearTimeout(loadingDelay);
|
||||
window.location.hash = "!";
|
||||
sending = false;
|
||||
};
|
||||
}}
|
||||
use:enhance={enhanceForm({ reset: false, closeModal: true })}
|
||||
>
|
||||
<input type="hidden" name="id" value={id} />
|
||||
<label>
|
||||
@@ -157,15 +136,7 @@
|
||||
<form
|
||||
method="POST"
|
||||
action="?/deleteWebsite"
|
||||
use:enhance={() => {
|
||||
loadingDelay = window.setTimeout(() => (sending = true), 500);
|
||||
return async ({ update }) => {
|
||||
await update();
|
||||
window.clearTimeout(loadingDelay);
|
||||
window.location.hash = "!";
|
||||
sending = false;
|
||||
};
|
||||
}}
|
||||
use:enhance={enhanceForm({ closeModal: true })}
|
||||
>
|
||||
<input type="hidden" name="id" value={id} />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user