(props: { class?: string })
| 20 | ] |
| 21 | |
| 22 | export function ShimmerText(props: { class?: string }) { |
| 23 | const [index, setIndex] = createSignal(Math.floor(Math.random() * WORDS.length)) |
| 24 | |
| 25 | onMount(() => { |
| 26 | const interval = setInterval(() => { |
| 27 | setIndex(Math.floor(Math.random() * WORDS.length)) |
| 28 | }, 4000) |
| 29 | onCleanup(() => clearInterval(interval)) |
| 30 | }) |
| 31 | |
| 32 | const word = createMemo(() => WORDS[index()] + "...") |
| 33 | const chars = createMemo(() => word().split("")) |
| 34 | |
| 35 | return ( |
| 36 | <span data-component="shimmer-text" class={props.class}> |
| 37 | <span class="shimmer-bullet">● </span> |
| 38 | <For each={chars()}> |
| 39 | {(char, i) => ( |
| 40 | <span |
| 41 | class="shimmer-char" |
| 42 | style={{ "--char-index": i() }} |
| 43 | > |
| 44 | {char} |
| 45 | </span> |
| 46 | )} |
| 47 | </For> |
| 48 | </span> |
| 49 | ) |
| 50 | } |
nothing calls this directly
no outgoing calls
no test coverage detected