2024-08-01 18:09:35 +02:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { enhance } from "$app/forms";
|
|
|
|
|
import WebsiteEditor from "$lib/components/WebsiteEditor.svelte";
|
|
|
|
|
import { ALLOWED_MIME_TYPES } from "$lib/utils";
|
2024-08-02 16:36:21 +02:00
|
|
|
import SuccessOrError from "$lib/components/SuccessOrError.svelte";
|
2024-08-05 14:38:44 +02:00
|
|
|
import type { ActionData, PageServerData } from "./$types";
|
2024-08-09 16:17:33 +02:00
|
|
|
import Modal from "$lib/components/Modal.svelte";
|
2024-07-31 07:23:32 +02:00
|
|
|
|
2024-08-05 14:38:44 +02:00
|
|
|
const { data, form } = $props<{ data: PageServerData; form: ActionData }>();
|
2024-08-01 18:09:35 +02:00
|
|
|
</script>
|
2024-07-31 07:23:32 +02:00
|
|
|
|
2024-08-02 16:36:21 +02:00
|
|
|
<SuccessOrError success={form?.success} message={form?.message} />
|
2024-08-01 18:09:35 +02:00
|
|
|
|
|
|
|
|
<WebsiteEditor
|
|
|
|
|
id={data.website.id}
|
|
|
|
|
title={data.website.title}
|
|
|
|
|
previewContent={data.home.main_content}
|
|
|
|
|
>
|
|
|
|
|
<section>
|
2024-08-02 15:33:18 +02:00
|
|
|
<h2>Global</h2>
|
|
|
|
|
<form
|
|
|
|
|
action="?/updateGlobal"
|
|
|
|
|
method="POST"
|
|
|
|
|
enctype="multipart/form-data"
|
|
|
|
|
use:enhance={() => {
|
|
|
|
|
return async ({ update }) => {
|
|
|
|
|
await update({ reset: false });
|
|
|
|
|
};
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<label>
|
|
|
|
|
Light accent color:
|
|
|
|
|
<input
|
|
|
|
|
type="color"
|
|
|
|
|
name="accent-color-light"
|
|
|
|
|
value={data.globalSettings.accent_color_light_theme}
|
2024-08-05 16:03:07 +02:00
|
|
|
pattern="\S(.*\S)?"
|
|
|
|
|
required
|
2024-08-02 15:33:18 +02:00
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
<label>
|
2024-08-03 18:07:27 +02:00
|
|
|
Dark accent color:
|
2024-08-02 15:33:18 +02:00
|
|
|
<input
|
|
|
|
|
type="color"
|
|
|
|
|
name="accent-color-dark"
|
|
|
|
|
value={data.globalSettings.accent_color_dark_theme}
|
2024-08-05 16:03:07 +02:00
|
|
|
pattern="\S(.*\S)?"
|
|
|
|
|
required
|
2024-08-02 15:33:18 +02:00
|
|
|
/>
|
|
|
|
|
</label>
|
2024-08-09 16:17:33 +02:00
|
|
|
<div class="file-field">
|
|
|
|
|
<label>
|
|
|
|
|
Favicon:
|
|
|
|
|
<input type="file" name="favicon" accept={ALLOWED_MIME_TYPES.join(", ")} />
|
|
|
|
|
</label>
|
|
|
|
|
{#if data.globalSettings.media}
|
|
|
|
|
<Modal id="preview-favicon-global-{data.globalSettings.website_id}" text="Preview">
|
|
|
|
|
<img
|
|
|
|
|
src={`http://localhost:5173/${data.globalSettings.media.file_system_path}`}
|
|
|
|
|
alt={data.globalSettings.media.original_name}
|
|
|
|
|
/>
|
|
|
|
|
</Modal>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
2024-08-01 18:09:35 +02:00
|
|
|
|
2024-08-02 15:33:18 +02:00
|
|
|
<button type="submit">Submit</button>
|
|
|
|
|
</form>
|
|
|
|
|
</section>
|
2024-08-01 18:09:35 +02:00
|
|
|
|
2024-08-02 15:33:18 +02:00
|
|
|
<section>
|
|
|
|
|
<h2>Header</h2>
|
2024-08-01 18:09:35 +02:00
|
|
|
|
2024-08-02 15:33:18 +02:00
|
|
|
<form
|
|
|
|
|
action="?/updateHeader"
|
|
|
|
|
method="POST"
|
|
|
|
|
enctype="multipart/form-data"
|
|
|
|
|
use:enhance={() => {
|
|
|
|
|
return async ({ update }) => {
|
|
|
|
|
await update({ reset: false });
|
|
|
|
|
};
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<label>
|
|
|
|
|
Logo type:
|
|
|
|
|
<select name="logo-type">
|
|
|
|
|
<option value="text" selected={"text" === data.header.logo_type}>Text</option>
|
|
|
|
|
<option value="image" selected={"image" === data.header.logo_type}>Image</option>
|
|
|
|
|
</select>
|
|
|
|
|
</label>
|
|
|
|
|
<label>
|
|
|
|
|
Logo text:
|
2024-08-05 16:03:07 +02:00
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
name="logo-text"
|
|
|
|
|
value={data.header.logo_text}
|
|
|
|
|
pattern="\S(.*\S)?"
|
|
|
|
|
required={data.header.logo_type === "text"}
|
|
|
|
|
/>
|
2024-08-02 15:33:18 +02:00
|
|
|
</label>
|
2024-08-09 16:17:33 +02:00
|
|
|
<div class="file-field">
|
|
|
|
|
<label>
|
|
|
|
|
Logo image:
|
|
|
|
|
<input
|
|
|
|
|
type="file"
|
|
|
|
|
name="logo-image"
|
|
|
|
|
accept={ALLOWED_MIME_TYPES.join(", ")}
|
|
|
|
|
required={data.header.logo_type === "image"}
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
{#if data.header.media}
|
|
|
|
|
<Modal id="preview-logo-header-{data.header.website_id}" text="Preview">
|
|
|
|
|
<img
|
|
|
|
|
src={`http://localhost:5173/${data.header.media.file_system_path}`}
|
|
|
|
|
alt={data.header.media.original_name}
|
|
|
|
|
/>
|
|
|
|
|
</Modal>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
2024-08-01 18:09:35 +02:00
|
|
|
|
2024-08-02 15:33:18 +02:00
|
|
|
<button type="submit">Submit</button>
|
|
|
|
|
</form>
|
|
|
|
|
</section>
|
2024-08-01 18:09:35 +02:00
|
|
|
|
2024-08-02 15:33:18 +02:00
|
|
|
<section>
|
|
|
|
|
<h2>Home</h2>
|
2024-08-01 18:09:35 +02:00
|
|
|
|
2024-08-02 15:33:18 +02:00
|
|
|
<form
|
|
|
|
|
action="?/updateHome"
|
|
|
|
|
method="POST"
|
|
|
|
|
use:enhance={() => {
|
|
|
|
|
return async ({ update }) => {
|
|
|
|
|
await update({ reset: false });
|
|
|
|
|
};
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<label>
|
|
|
|
|
Main content:
|
2024-08-05 16:03:07 +02:00
|
|
|
<textarea name="main-content" rows="20" required>{data.home.main_content}</textarea>
|
2024-08-02 15:33:18 +02:00
|
|
|
</label>
|
2024-08-01 18:09:35 +02:00
|
|
|
|
2024-08-02 15:33:18 +02:00
|
|
|
<button type="submit">Submit</button>
|
|
|
|
|
</form>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section>
|
|
|
|
|
<h2>Footer</h2>
|
2024-08-01 18:09:35 +02:00
|
|
|
|
2024-08-02 15:33:18 +02:00
|
|
|
<form
|
|
|
|
|
action="?/updateFooter"
|
|
|
|
|
method="POST"
|
|
|
|
|
use:enhance={() => {
|
|
|
|
|
return async ({ update }) => {
|
|
|
|
|
await update({ reset: false });
|
|
|
|
|
};
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<label>
|
|
|
|
|
Additional text:
|
2024-08-05 16:03:07 +02:00
|
|
|
<textarea name="additional-text" rows="5" maxlength="250" required
|
|
|
|
|
>{data.footer.additional_text}</textarea
|
|
|
|
|
>
|
2024-08-02 15:33:18 +02:00
|
|
|
</label>
|
2024-08-01 18:09:35 +02:00
|
|
|
|
2024-08-02 15:33:18 +02:00
|
|
|
<button type="submit">Submit</button>
|
|
|
|
|
</form>
|
2024-08-01 18:09:35 +02:00
|
|
|
</section>
|
|
|
|
|
</WebsiteEditor>
|