diff --git a/.changeset/wicked-seals-tie.md b/.changeset/wicked-seals-tie.md new file mode 100644 index 000000000..bc166258b --- /dev/null +++ b/.changeset/wicked-seals-tie.md @@ -0,0 +1,5 @@ +--- +'@churros/app': minor +--- + +feat(app): improve skeleton UI appearance diff --git a/packages/app/src/lib/components/LoadingText.svelte b/packages/app/src/lib/components/LoadingText.svelte index b85aeddc8..ee269b1ae 100644 --- a/packages/app/src/lib/components/LoadingText.svelte +++ b/packages/app/src/lib/components/LoadingText.svelte @@ -6,6 +6,20 @@ export let tag: string = 'span'; export let lines: number | undefined = undefined; export let value: MaybeLoading | null | undefined = PendingValue; + + let loadingTextSlotContent: HTMLSpanElement | null = null; + + // Text to use as skeleton UI is either the text given in the default slot, or lines of lorem ipsum if lines is specified, or a fallback + function loadingTextLines() { + let output: string[] = []; + if (lines) output = LOREM_IPSUM.split('\n').slice(0, lines); + else if (loadingTextSlotContent?.textContent) + output = loadingTextSlotContent.textContent.split('\n'); + + output = output.filter(Boolean); + if (output.length > 0) return output; + return ['Chargement...']; + } {#if !loaded(value) || value === null} @@ -13,9 +27,13 @@ this={tag === 'code' ? 'span' : tag} {...$$restProps} class="skeleton-text skeleton-effect-wave" - >{lines ? LOREM_IPSUM.split('\n').slice(0, lines).join('\n') : 'Chargement...'} + {#each loadingTextLines() as line} + {line} +
+ {/each} + + {:else} {value} @@ -23,7 +41,7 @@ {/if}