|
1 | 1 | <script lang="ts"> |
2 | | - import { Card } from 'flowbite-svelte'; |
3 | 2 | import LineCard from './LineCard.svelte'; |
| 3 | + import { DEFAULT_TOKEN_SPLIT_CHARS, MAX_LINES } from '$lib/serialization/schema.js'; |
4 | 4 | import { projectStore } from '$lib/state/project.svelte.js'; |
5 | | - import { MAX_LINES } from '$lib/serialization/schema.js'; |
| 5 | + import { settingsStore } from '$lib/state/settings.svelte.js'; |
| 6 | +
|
| 7 | + let editorExpanded = $state(true); |
6 | 8 | </script> |
7 | 9 |
|
8 | | -<Card class="w-full max-w-none p-4 sm:p-6" aria-labelledby="editor-heading"> |
9 | | - <div class="mb-3 flex flex-wrap items-center justify-between gap-x-4 gap-y-2"> |
10 | | - <h2 |
11 | | - id="editor-heading" |
12 | | - class="font-heading text-lg font-semibold text-gray-900 dark:text-white" |
13 | | - > |
14 | | - Editor |
15 | | - </h2> |
16 | | - </div> |
17 | | - <p class="mb-4 w-full text-base text-gray-600 dark:text-gray-400"> |
18 | | - Each row is a line of text with its own font and size. In the preview, click a word, then click |
19 | | - a word on an <strong>adjacent</strong> line to connect them. Connectors only run between neighboring |
20 | | - lines. Click a connector to remove it. Click the same word again to deselect. |
21 | | - </p> |
22 | | - {#each projectStore.lines as line, i (line.id)} |
23 | | - <LineCard {line} index={i} total={projectStore.lines.length} /> |
24 | | - {/each} |
25 | | - <div class="mt-2 flex flex-wrap items-center gap-3"> |
| 10 | +<section class="mb-8" aria-labelledby="editor-heading"> |
| 11 | + <div class="mb-2 flex flex-wrap items-center justify-between gap-2"> |
26 | 12 | <button |
27 | 13 | type="button" |
28 | | - class="rounded-none border border-primary-600 bg-primary-600 px-3 py-2 text-sm font-medium text-white hover:bg-primary-700 disabled:opacity-50 dark:border-primary-500 dark:bg-primary-600 dark:hover:bg-primary-500" |
29 | | - disabled={projectStore.lines.length >= MAX_LINES} |
30 | | - onclick={() => projectStore.addLine()} |
| 14 | + class="flex items-center gap-2 rounded-none border-0 bg-transparent p-0 text-left text-gray-900 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 dark:text-white dark:focus-visible:outline-primary-500" |
| 15 | + onclick={() => (editorExpanded = !editorExpanded)} |
| 16 | + aria-expanded={editorExpanded} |
| 17 | + aria-controls="editor-collapsible" |
31 | 18 | > |
32 | | - Add line |
| 19 | + <svg |
| 20 | + class="h-4 w-4 shrink-0 text-gray-500 transition-transform dark:text-gray-400 {editorExpanded |
| 21 | + ? 'rotate-90' |
| 22 | + : ''}" |
| 23 | + viewBox="0 0 20 20" |
| 24 | + fill="currentColor" |
| 25 | + aria-hidden="true" |
| 26 | + > |
| 27 | + <path |
| 28 | + fill-rule="evenodd" |
| 29 | + d="M7.21 14.77a.75.75 0 0 1 .02-1.06L10.94 10 7.23 6.29a.75.75 0 0 1 1.06-1.06l4.24 4.24a.75.75 0 0 1 0 1.06l-4.24 4.24a.75.75 0 0 1-1.08.0Z" |
| 30 | + clip-rule="evenodd" |
| 31 | + /> |
| 32 | + </svg> |
| 33 | + <span id="editor-heading" class="font-heading text-lg font-semibold">Editor</span> |
33 | 34 | </button> |
34 | | - {#if projectStore.lines.length >= MAX_LINES} |
35 | | - <p class="text-sm text-amber-700 dark:text-amber-400"> |
36 | | - Soft limit: {MAX_LINES} lines — consider simplifying for shorter share links. |
37 | | - </p> |
38 | | - {/if} |
39 | 35 | </div> |
40 | | -</Card> |
| 36 | + |
| 37 | + {#if editorExpanded} |
| 38 | + <div id="editor-collapsible"> |
| 39 | + <p class="mb-3 w-full text-sm leading-snug text-gray-600 dark:text-gray-400"> |
| 40 | + Whitespace splits words. Extra split characters (from Linguistics in settings) also split |
| 41 | + within the line (currently |
| 42 | + <code class="rounded-none bg-gray-200 px-1 dark:bg-gray-700" |
| 43 | + >{settingsStore.settings.tokenSplitChars || DEFAULT_TOKEN_SPLIT_CHARS}</code |
| 44 | + >). Use the preview to link words, change fonts, and add or remove lines. |
| 45 | + </p> |
| 46 | + {#each projectStore.lines as line, i (line.id)} |
| 47 | + <LineCard {line} index={i} /> |
| 48 | + {/each} |
| 49 | + <div class="mt-2 flex flex-wrap items-center gap-3"> |
| 50 | + <button |
| 51 | + type="button" |
| 52 | + class="rounded-none border border-primary-600 bg-primary-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-primary-700 disabled:opacity-50 dark:border-primary-500 dark:bg-primary-600 dark:hover:bg-primary-500" |
| 53 | + disabled={projectStore.lines.length >= MAX_LINES} |
| 54 | + onclick={() => projectStore.addLine()} |
| 55 | + > |
| 56 | + Add line |
| 57 | + </button> |
| 58 | + {#if projectStore.lines.length >= MAX_LINES} |
| 59 | + <p class="text-xs text-amber-700 dark:text-amber-400"> |
| 60 | + Soft limit: {MAX_LINES} lines — consider simplifying for shorter share links. |
| 61 | + </p> |
| 62 | + {/if} |
| 63 | + </div> |
| 64 | + </div> |
| 65 | + {/if} |
| 66 | +</section> |
0 commit comments