Download tools/server/webui/src/lib/components/app/misc/TruncatedText.svelte from echodict/llama.cpp: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/datasets/echodict/llama.cpp/resolve/main/tools/server/webui/src/lib/components/app/misc/TruncatedText.svelte
- Command line
-
hf download hf://datasets/echodict/llama.cpp/tools/server/webui/src/lib/components/app/misc/TruncatedText.svelte
-
curl -L -o TruncatedText.svelte https://huggingface.co/datasets/echodict/llama.cpp/resolve/main/tools/server/webui/src/lib/components/app/misc/TruncatedText.svelte
1.05 kB
| <script lang="ts"> | |
| import * as Tooltip from '$lib/components/ui/tooltip'; | |
| interface Props { | |
| text: string; | |
| class?: string; | |
| showTooltip?: boolean; | |
| } | |
| let { text, class: className = '', showTooltip = true }: Props = $props(); | |
| let textElement: HTMLSpanElement | undefined = $state(); | |
| let isTruncated = $state(false); | |
| function checkTruncation() { | |
| if (textElement) { | |
| isTruncated = textElement.scrollWidth > textElement.clientWidth; | |
| } | |
| } | |
| $effect(() => { | |
| if (textElement) { | |
| checkTruncation(); | |
| const observer = new ResizeObserver(checkTruncation); | |
| observer.observe(textElement); | |
| return () => observer.disconnect(); | |
| } | |
| }); | |
| </script> | |
| {#if isTruncated && showTooltip} | |
| <Tooltip.Root> | |
| <Tooltip.Trigger class={className}> | |
| <span bind:this={textElement} class="block truncate"> | |
| {text} | |
| </span> | |
| </Tooltip.Trigger> | |
| <Tooltip.Content class="z-[9999]"> | |
| <p>{text}</p> | |
| </Tooltip.Content> | |
| </Tooltip.Root> | |
| {:else} | |
| <span bind:this={textElement} class="{className} block truncate"> | |
| {text} | |
| </span> | |
| {/if} | |