feat(frontend): add expandable text component for long fields
Some checks failed
CI / Unit & Component Tests (push) Has been cancelled
CI / Backend Unit Tests (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
CI / Unit & Component Tests (pull_request) Has been cancelled
CI / Backend Unit Tests (pull_request) Has been cancelled
CI / E2E Tests (pull_request) Has been cancelled
Some checks failed
CI / Unit & Component Tests (push) Has been cancelled
CI / Backend Unit Tests (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
CI / Unit & Component Tests (pull_request) Has been cancelled
CI / Backend Unit Tests (pull_request) Has been cancelled
CI / E2E Tests (pull_request) Has been cancelled
Adds ExpandableText.svelte which clamps text to 10 lines and shows a toggle button only when the content actually overflows. Applied to the summary and transcription fields on the document detail page. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -238,5 +238,7 @@
|
|||||||
"admin_system_backfill_heading": "Verlaufsdaten auffüllen",
|
"admin_system_backfill_heading": "Verlaufsdaten auffüllen",
|
||||||
"admin_system_backfill_description": "Erstellt einen initialen Verlaufseintrag für alle Dokumente, die noch keinen Verlauf haben (z.B. importierte Dokumente). Dadurch werden beim nächsten Bearbeiten nur die tatsächlich geänderten Felder hervorgehoben.",
|
"admin_system_backfill_description": "Erstellt einen initialen Verlaufseintrag für alle Dokumente, die noch keinen Verlauf haben (z.B. importierte Dokumente). Dadurch werden beim nächsten Bearbeiten nur die tatsächlich geänderten Felder hervorgehoben.",
|
||||||
"admin_system_backfill_btn": "Jetzt auffüllen",
|
"admin_system_backfill_btn": "Jetzt auffüllen",
|
||||||
"admin_system_backfill_success": "{count} Dokumente wurden aufgefüllt."
|
"admin_system_backfill_success": "{count} Dokumente wurden aufgefüllt.",
|
||||||
|
"comp_expandable_show_more": "Mehr anzeigen",
|
||||||
|
"comp_expandable_show_less": "Weniger anzeigen"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,5 +238,7 @@
|
|||||||
"admin_system_backfill_heading": "Backfill history data",
|
"admin_system_backfill_heading": "Backfill history data",
|
||||||
"admin_system_backfill_description": "Creates an initial history entry for all documents that do not have one yet (e.g. imported documents). This ensures that future edits only highlight actually changed fields.",
|
"admin_system_backfill_description": "Creates an initial history entry for all documents that do not have one yet (e.g. imported documents). This ensures that future edits only highlight actually changed fields.",
|
||||||
"admin_system_backfill_btn": "Backfill now",
|
"admin_system_backfill_btn": "Backfill now",
|
||||||
"admin_system_backfill_success": "{count} documents were backfilled."
|
"admin_system_backfill_success": "{count} documents were backfilled.",
|
||||||
|
"comp_expandable_show_more": "Show more",
|
||||||
|
"comp_expandable_show_less": "Show less"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,5 +238,7 @@
|
|||||||
"admin_system_backfill_heading": "Completar datos de historial",
|
"admin_system_backfill_heading": "Completar datos de historial",
|
||||||
"admin_system_backfill_description": "Crea una entrada de historial inicial para todos los documentos que aún no tienen ninguna (p.ej. documentos importados). Así, en la próxima edición solo se resaltarán los campos realmente modificados.",
|
"admin_system_backfill_description": "Crea una entrada de historial inicial para todos los documentos que aún no tienen ninguna (p.ej. documentos importados). Así, en la próxima edición solo se resaltarán los campos realmente modificados.",
|
||||||
"admin_system_backfill_btn": "Completar ahora",
|
"admin_system_backfill_btn": "Completar ahora",
|
||||||
"admin_system_backfill_success": "{count} documentos fueron completados."
|
"admin_system_backfill_success": "{count} documentos fueron completados.",
|
||||||
|
"comp_expandable_show_more": "Mostrar más",
|
||||||
|
"comp_expandable_show_less": "Mostrar menos"
|
||||||
}
|
}
|
||||||
|
|||||||
33
frontend/src/lib/components/ExpandableText.svelte
Normal file
33
frontend/src/lib/components/ExpandableText.svelte
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { m } from '$lib/paraglide/messages.js';
|
||||||
|
|
||||||
|
let { text, maxLines = 10 }: { text: string; maxLines?: number } = $props();
|
||||||
|
|
||||||
|
let expanded = $state(false);
|
||||||
|
let el = $state<HTMLElement | undefined>(undefined);
|
||||||
|
let isClamped = $state(false);
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
if (el && !expanded) {
|
||||||
|
isClamped = el.scrollHeight > el.clientHeight;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
bind:this={el}
|
||||||
|
style={!expanded ? `overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: ${maxLines}` : ''}
|
||||||
|
class="rounded border border-brand-sand bg-brand-sand/30 p-5 font-serif text-sm leading-relaxed whitespace-pre-wrap text-brand-navy"
|
||||||
|
>
|
||||||
|
{text}
|
||||||
|
</div>
|
||||||
|
{#if isClamped || expanded}
|
||||||
|
<button
|
||||||
|
onclick={() => (expanded = !expanded)}
|
||||||
|
class="mt-2 font-sans text-xs text-gray-400 transition hover:text-brand-navy"
|
||||||
|
>
|
||||||
|
{expanded ? m.comp_expandable_show_less() : m.comp_expandable_show_more()}
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
import { m } from '$lib/paraglide/messages.js';
|
import { m } from '$lib/paraglide/messages.js';
|
||||||
import { formatDate } from '$lib/utils/date';
|
import { formatDate } from '$lib/utils/date';
|
||||||
import { diffWords } from 'diff';
|
import { diffWords } from 'diff';
|
||||||
|
import ExpandableText from '$lib/components/ExpandableText.svelte';
|
||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
|
|
||||||
@@ -592,11 +593,7 @@ function versionLabel(v: VersionSummary, index: number): string {
|
|||||||
<span class="mb-2 block font-sans text-xs text-gray-400 uppercase"
|
<span class="mb-2 block font-sans text-xs text-gray-400 uppercase"
|
||||||
>{m.doc_label_summary()}</span
|
>{m.doc_label_summary()}</span
|
||||||
>
|
>
|
||||||
<div
|
<ExpandableText text={doc.summary} />
|
||||||
class="rounded border border-brand-sand bg-brand-sand/30 p-5 font-serif text-sm leading-relaxed whitespace-pre-wrap text-brand-navy"
|
|
||||||
>
|
|
||||||
{doc.summary}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
@@ -605,11 +602,7 @@ function versionLabel(v: VersionSummary, index: number): string {
|
|||||||
<span class="mb-2 block font-sans text-xs text-gray-400 uppercase"
|
<span class="mb-2 block font-sans text-xs text-gray-400 uppercase"
|
||||||
>{m.form_label_transcription()}</span
|
>{m.form_label_transcription()}</span
|
||||||
>
|
>
|
||||||
<div
|
<ExpandableText text={doc.transcription} />
|
||||||
class="rounded border border-brand-sand bg-brand-sand/30 p-5 font-serif text-sm leading-relaxed whitespace-pre-wrap text-brand-navy"
|
|
||||||
>
|
|
||||||
{doc.transcription}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user