squashme
This commit is contained in:
parent
b3d291c3ee
commit
d9cd2bda60
4 changed files with 77 additions and 5 deletions
|
@ -197,4 +197,11 @@
|
||||||
@apply rounded-md;
|
@apply rounded-md;
|
||||||
@apply p-1;
|
@apply p-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
@apply list-inside list-disc;
|
||||||
|
}
|
||||||
|
ol {
|
||||||
|
@apply list-inside list-decimal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,76 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { TodoDetailPage } from './+page';
|
import type { TodoDetailPage } from './+page';
|
||||||
|
import type { TodoItem } from '$lib/api/types';
|
||||||
import { markdownToHtml } from '$lib/utils/markdown';
|
import { markdownToHtml } from '$lib/utils/markdown';
|
||||||
|
|
||||||
export let data: TodoDetailPage;
|
export let data: TodoDetailPage;
|
||||||
|
|
||||||
|
let todo: TodoItem = data.todo;
|
||||||
|
let editingEnabled = true;
|
||||||
|
|
||||||
|
function adjustTextareaRows(event: InputEvent) {
|
||||||
|
const textarea = event.target as HTMLTextAreaElement;
|
||||||
|
const scrollHeight = textarea.scrollHeight;
|
||||||
|
|
||||||
|
const computedStyle = getComputedStyle(textarea);
|
||||||
|
const lineHeight = parseFloat(computedStyle.lineHeight);
|
||||||
|
const paddingTop = parseFloat(computedStyle.paddingTop);
|
||||||
|
const paddingBottom = parseFloat(computedStyle.paddingBottom);
|
||||||
|
|
||||||
|
const contentHeight = scrollHeight - paddingTop - paddingBottom;
|
||||||
|
const rows = Math.ceil(contentHeight / lineHeight);
|
||||||
|
|
||||||
|
textarea.rows = rows
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function handleFormSubmit() {
|
||||||
|
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h1>{data.todo.title}</h1>
|
<div class="flex flex-col w-full h-full p-4 sm:p-8 gap-4 max-w-7xl">
|
||||||
<div>
|
<form action="" method="post" on:submit={handleFormSubmit}>
|
||||||
{@html markdownToHtml(data.todo.description)}
|
<fieldset>
|
||||||
|
<div class="field-pair">
|
||||||
|
<textarea id="title" bind:value={todo.title} disabled={!editingEnabled} on:input={adjustTextareaRows} rows="1" cols="1"></textarea>
|
||||||
|
<label for="title">Title</label>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<div class="text-display">
|
||||||
|
{@html markdownToHtml(data.todo.description)}
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
h1 {
|
||||||
|
@apply font-semibold;
|
||||||
|
@apply w-full;
|
||||||
|
}
|
||||||
|
span.title-heading {
|
||||||
|
@apply text-xl text-secondary font-bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-display {
|
||||||
|
@apply text-start;
|
||||||
|
@apply border-2 border-secondary rounded-md;
|
||||||
|
@apply w-full p-4;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.field-pair {
|
||||||
|
@apply flex flex-col gap-0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
@apply w-full;
|
||||||
|
}
|
||||||
|
input:disabled {
|
||||||
|
@apply bg-background border-none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-pair label {
|
||||||
|
@apply border-t;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="grow flex flex-col items-center gap-y-4 px-4">
|
<div class="grow flex flex-col items-center justify-center gap-y-4 px-4">
|
||||||
{#if user.id === data.user.id}
|
{#if user.id === data.user.id}
|
||||||
<h1>My Profile</h1>
|
<h1>My Profile</h1>
|
||||||
{:else}
|
{:else}
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
const table = {
|
const table = {
|
||||||
caption: user.id === data.user.id ? 'My TODOs' : `${data.user.first_name} ${data.user.last_name}'s TODOs`,
|
caption: user.id === data.user.id ? 'My TODOs' : `${data.user.first_name} ${data.user.last_name}'s TODOs`,
|
||||||
columns: columns,
|
columns: user.isAdmin ? columns : columns.slice(1, -1),
|
||||||
getItemsEndpoint: {
|
getItemsEndpoint: {
|
||||||
callable: readTodos,
|
callable: readTodos,
|
||||||
args: [
|
args: [
|
||||||
|
|
Loading…
Add table
Reference in a new issue