Skip to content

Commit

Permalink
refac: move article editor in separate component
Browse files Browse the repository at this point in the history
  • Loading branch information
xnought committed Nov 28, 2023
1 parent f4875fe commit ac6448b
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 45 deletions.
60 changes: 60 additions & 0 deletions frontend/src/lib/ArticleEditor.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<script lang="ts">
import {
Card,
Tabs,
TabItem,
Heading,
Label,
Textarea,
} from "flowbite-svelte";
import Markdown from "$lib/Markdown.svelte";
import References from "$lib/References.svelte";
export let refs = "";
export let content = "";
</script>

<Card
class="max-w-full"
style="height: 600px; overflow-y: scroll; padding: 0; padding-top: 4px; padding-left: 4px;"
>
<Tabs contentClass="bg-none p-5" style="underline">
<TabItem title="article content" open>
<div>
<Label for="content" class="block mb-2"
>Protein Article (Markdown)</Label
>
<Textarea
id="content"
placeholder="Enter markdown..."
rows={12}
bind:value={content}
/>
</div>

<div class="mt-3">
<Label for="refs" class="block mb-2">References (BibTeX)</Label>
<Textarea
id="refs"
placeholder="Enter bibtex with atleast an id, title, and author (optionally url and year)"
rows={4}
bind:value={refs}
/>
</div>
</TabItem>
<TabItem title="preview">
{#if content.length > 0 || refs.length > 0}
<Card class="max-w-full">
<Heading tag="h4">Article</Heading>
<Markdown text={content} />
</Card>

<Card class="max-w-full mt-5">
<Heading tag="h4">References</Heading>
<References bibtex={String.raw`${refs}`} />
</Card>
{:else}
No content to render/preview
{/if}
</TabItem>
</Tabs>
</Card>
49 changes: 4 additions & 45 deletions frontend/src/routes/upload/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import { formatProteinName } from "$lib/format";
import Markdown from "$lib/Markdown.svelte";
import References from "$lib/References.svelte";
import ArticleEditor from "$lib/ArticleEditor.svelte";
let name: string = "";
let content: string = "";
Expand Down Expand Up @@ -59,51 +60,9 @@
{/if}
</div>

<Card
class="max-w-full"
style="height: 600px; overflow-y: scroll; padding: 0; padding-top: 4px; padding-left: 4px;"
>
<Tabs contentClass="bg-none p-5" style="underline">
<TabItem title="article content" open>
<div>
<Label for="content" class="block mb-2"
>Protein Article (Markdown)</Label
>
<Textarea
id="content"
placeholder="Enter markdown..."
rows={12}
bind:value={content}
/>
</div>

<div class="mt-3">
<Label for="refs" class="block mb-2">References (BibTeX)</Label>
<Textarea
id="refs"
placeholder="Enter bibtex with atleast an id, title, and author (optionally url and year)"
rows={4}
bind:value={refs}
/>
</div>
</TabItem>
<TabItem title="preview">
{#if content.length > 0 || refs.length > 0}
<Card class="max-w-full">
<Heading tag="h4">Article</Heading>
<Markdown text={content} />
</Card>

<Card class="max-w-full mt-5">
<Heading tag="h4">References</Heading>
<References bibtex={String.raw`${refs}`} />
</Card>
{:else}
No content to render/preview
{/if}
</TabItem>
</Tabs>
</Card>
<div>
<ArticleEditor bind:content bind:refs />
</div>

<div>
<Fileupload class="w-100" bind:files />
Expand Down

0 comments on commit ac6448b

Please sign in to comment.