adding entry cover
This commit is contained in:
@@ -1,15 +1,21 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
let {
|
import Editor from '$lib/components/editor/index.svelte'
|
||||||
date = $bindable('')
|
import { today } from '$lib/date'
|
||||||
} = $props()
|
let { date = $bindable(today()) } = $props();
|
||||||
|
|
||||||
|
let edit = $state(false);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col items-center justify-center">
|
{#if edit}
|
||||||
<button class="bg-white/20 p-4 rounded-xl w-full hover:brightness-80 transition-all">
|
<Editor newEntryDate={date} edit={true}/>
|
||||||
<p class="rounded-full bg-white/30 p-2 h-10 w-10">+</p>
|
{:else}
|
||||||
<p>Add Entry for {date}</p>
|
<div class="flex flex-col items-center justify-center">
|
||||||
</button>
|
<button
|
||||||
|
class="bg-white/20 p-4 rounded-xl w-full hover:brightness-80 transition-all"
|
||||||
<!-- <p class="text-white/60">Select an entry to view/edit</p> -->
|
onclick={() => edit = true}
|
||||||
</div>
|
>
|
||||||
|
<p class="rounded-full bg-white/30 p-2 h-10 w-10">+</p>
|
||||||
|
<p>Add Entry for {date}</p>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|||||||
@@ -3,13 +3,15 @@
|
|||||||
import TextEditor from "./textEditor.svelte";
|
import TextEditor from "./textEditor.svelte";
|
||||||
import { formatDate } from "$lib/date.ts";
|
import { formatDate } from "$lib/date.ts";
|
||||||
|
|
||||||
let { entry = $bindable({}), edit = $bindable(false) } = $props();
|
let { newEntryDate, entry = $bindable(), edit = $bindable(false) } = $props();
|
||||||
|
|
||||||
|
let newEntry = $state({ date: newEntryDate, image: "", content: "" });
|
||||||
|
|
||||||
let editModeText = $derived(edit ? "done" : "edit")
|
let editModeText = $derived(edit ? "done" : "edit")
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-row mb-2">
|
<div class="flex flex-row mb-2">
|
||||||
<p class="text-3xl font-bold">{formatDate(entry.date)}</p>
|
<p class="text-3xl font-bold">{entry ? formatDate(entry.date) : formatDate(newEntryDate)}</p>
|
||||||
<button
|
<button
|
||||||
class="bg-white/20 px-3 rounded-lg ml-auto"
|
class="bg-white/20 px-3 rounded-lg ml-auto"
|
||||||
onclick={() => edit = !edit}
|
onclick={() => edit = !edit}
|
||||||
@@ -18,5 +20,10 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ImageTarget bind:image={entry.image} bind:edit />
|
{#if entry}
|
||||||
<TextEditor bind:content={entry.content} bind:edit />
|
<ImageTarget bind:image={entry.image} bind:edit />
|
||||||
|
<TextEditor bind:content={entry.content} bind:edit />
|
||||||
|
{:else}
|
||||||
|
<ImageTarget bind:image={newEntry.image} bind:edit />
|
||||||
|
<TextEditor bind:content={newEntry.content} bind:edit />
|
||||||
|
{/if}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
let selectedDate = $state(today())
|
let selectedDate = $state(today())
|
||||||
|
|
||||||
let selectEntry = async (hasEntry: boolean, data: string | null) => {
|
let selectEntry = async (hasEntry: boolean, data: string | null) => {
|
||||||
console.log(data)
|
|
||||||
// data should be the entryID if hasEntry == true, or the date if there is no entry
|
// data should be the entryID if hasEntry == true, or the date if there is no entry
|
||||||
if (hasEntry) {
|
if (hasEntry) {
|
||||||
const res = await fetch(`/api/entry?id=${data}`)
|
const res = await fetch(`/api/entry?id=${data}`)
|
||||||
@@ -27,7 +26,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Calendar entries={data.all} dayClickCallback={async (entryID: string) => await selectEntry(entryID)} />
|
<Calendar entries={data.all} dayClickCallback={selectEntry} />
|
||||||
|
|
||||||
<div class="flex flex-col md:flex-row space-y-4 w-full mt-6">
|
<div class="flex flex-col md:flex-row space-y-4 w-full mt-6">
|
||||||
|
|
||||||
@@ -42,7 +41,7 @@
|
|||||||
<div class="md:w-1/2 md:mr-4">
|
<div class="md:w-1/2 md:mr-4">
|
||||||
<ul>
|
<ul>
|
||||||
{#each data.all as entry}
|
{#each data.all as entry}
|
||||||
<EntrySummaryView clickCB={async () => await selectEntry(entry.id)} {entry} />
|
<EntrySummaryView clickCB={async () => await selectEntry(true, entry.id)} {entry} />
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user