2024-08-01 18:09:35 +02:00
|
|
|
<script lang="ts">
|
|
|
|
|
import type { Snippet } from "svelte";
|
2024-08-04 16:15:09 +02:00
|
|
|
import { md } from "$lib/utils";
|
2024-08-24 20:46:10 +02:00
|
|
|
import { page } from "$app/stores";
|
2024-08-01 18:09:35 +02:00
|
|
|
|
2024-08-03 18:07:27 +02:00
|
|
|
const {
|
|
|
|
|
id,
|
2024-08-27 16:39:29 +02:00
|
|
|
contentType,
|
2024-08-03 18:07:27 +02:00
|
|
|
title,
|
|
|
|
|
children,
|
|
|
|
|
fullPreview = false,
|
2024-08-17 16:05:14 +02:00
|
|
|
previewContent,
|
|
|
|
|
previewScrollTop = 0
|
2024-08-20 19:17:05 +02:00
|
|
|
}: {
|
2024-08-01 18:09:35 +02:00
|
|
|
id: string;
|
2024-08-27 16:39:29 +02:00
|
|
|
contentType: string;
|
2024-08-01 18:09:35 +02:00
|
|
|
title: string;
|
|
|
|
|
children: Snippet;
|
2024-08-03 18:07:27 +02:00
|
|
|
fullPreview?: boolean;
|
2024-08-01 18:09:35 +02:00
|
|
|
previewContent: string;
|
2024-08-17 16:05:14 +02:00
|
|
|
previewScrollTop?: number;
|
2024-08-20 19:17:05 +02:00
|
|
|
} = $props();
|
2024-08-17 16:05:14 +02:00
|
|
|
|
|
|
|
|
let previewElement: HTMLDivElement;
|
|
|
|
|
|
|
|
|
|
$effect(() => {
|
|
|
|
|
const scrollHeight = previewElement.scrollHeight - previewElement.clientHeight;
|
|
|
|
|
previewElement.scrollTop = (previewScrollTop / 100) * scrollHeight;
|
|
|
|
|
});
|
2024-08-01 18:09:35 +02:00
|
|
|
</script>
|
|
|
|
|
|
2024-08-15 16:26:32 +02:00
|
|
|
<input type="checkbox" id="toggle-mobile-preview" hidden />
|
|
|
|
|
<label for="toggle-mobile-preview">Preview</label>
|
|
|
|
|
|
2024-08-01 18:09:35 +02:00
|
|
|
<div class="operations">
|
|
|
|
|
<h1>{title}</h1>
|
|
|
|
|
|
2024-08-02 15:33:18 +02:00
|
|
|
<nav class="operations__nav">
|
2024-08-23 18:43:52 +02:00
|
|
|
<ul class="unpadded">
|
2024-08-15 16:26:32 +02:00
|
|
|
<li>
|
|
|
|
|
<a href="/website/{id}">Settings</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="/website/{id}/articles">Articles</a>
|
|
|
|
|
</li>
|
2024-08-27 16:39:29 +02:00
|
|
|
{#if contentType === "Docs"}
|
|
|
|
|
<a href="/website/{id}/categories">Categories</a>
|
|
|
|
|
{/if}
|
2024-08-15 16:26:32 +02:00
|
|
|
<li>
|
|
|
|
|
<a href="/website/{id}/collaborators">Collaborators</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="/website/{id}/publish">Publish</a>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
2024-08-02 15:33:18 +02:00
|
|
|
</nav>
|
2024-08-01 18:09:35 +02:00
|
|
|
|
|
|
|
|
{@render children()}
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-08-17 16:05:14 +02:00
|
|
|
<div class="preview" bind:this={previewElement}>
|
2024-08-03 18:07:27 +02:00
|
|
|
{#if fullPreview}
|
2024-08-07 19:13:39 +02:00
|
|
|
<iframe src={previewContent} title="Preview"></iframe>
|
2024-08-03 18:07:27 +02:00
|
|
|
{:else}
|
2024-08-24 20:46:10 +02:00
|
|
|
{@html md(previewContent, Object.keys($page.params).length > 1 ? true : false)}
|
2024-08-03 18:07:27 +02:00
|
|
|
{/if}
|
2024-08-01 18:09:35 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<style>
|
2024-08-15 16:26:32 +02:00
|
|
|
label[for="toggle-mobile-preview"] {
|
|
|
|
|
position: absolute;
|
|
|
|
|
inset-block-start: -0.0625rem;
|
|
|
|
|
inset-inline-start: 50%;
|
|
|
|
|
transform: translateX(-50%);
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: var(--space-2xs);
|
2024-08-01 18:09:35 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-15 16:26:32 +02:00
|
|
|
#toggle-mobile-preview:checked ~ .operations {
|
|
|
|
|
display: none;
|
2024-08-01 18:09:35 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-15 16:26:32 +02:00
|
|
|
#toggle-mobile-preview:checked ~ .preview {
|
2024-08-03 18:07:27 +02:00
|
|
|
display: flex;
|
2024-08-02 15:33:18 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-15 16:26:32 +02:00
|
|
|
.operations,
|
2024-08-01 18:09:35 +02:00
|
|
|
.preview {
|
2024-08-15 16:26:32 +02:00
|
|
|
padding: var(--space-s);
|
|
|
|
|
padding-block-start: var(--space-xl);
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.operations__nav > ul {
|
|
|
|
|
margin-block: var(--space-s) var(--space-m);
|
2024-08-03 13:49:41 +02:00
|
|
|
display: flex;
|
2024-08-15 16:26:32 +02:00
|
|
|
flex-wrap: wrap;
|
|
|
|
|
column-gap: var(--space-s);
|
|
|
|
|
row-gap: var(--space-3xs);
|
2024-08-01 18:09:35 +02:00
|
|
|
}
|
2024-08-03 18:07:27 +02:00
|
|
|
|
|
|
|
|
iframe {
|
|
|
|
|
inline-size: 100%;
|
|
|
|
|
block-size: 100%;
|
|
|
|
|
border: var(--border-primary);
|
|
|
|
|
}
|
2024-08-15 16:26:32 +02:00
|
|
|
|
|
|
|
|
.preview {
|
|
|
|
|
display: none;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: var(--space-s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media (min-width: 640px) {
|
|
|
|
|
label[for="toggle-mobile-preview"] {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.operations {
|
|
|
|
|
border-inline-end: var(--border-primary);
|
|
|
|
|
padding-block-start: var(--space-s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.preview {
|
|
|
|
|
display: flex;
|
|
|
|
|
padding-block-start: var(--space-s);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-01 18:09:35 +02:00
|
|
|
</style>
|